PTHREAD_SIGNALS_BLOCK_NP(3)

NAME
pthread_signals_block_np, pthread_signals_unblock_np - fast asynchronous signals blocking and unblocking

LIBRARY
libpthread

SYNOPSIS
#include <pthread_np.h>
void
pthread_signals_block_np(void);
void
pthread_signals_unblock_np(void);

DESCRIPTION
The pthread_signals_block_np() and pthread_signals_unblock_np() functions provide user programs an interface to the fast asynchronous signals blocking facility sigfastblock(2).

Blocking signals with pthread_signals_block_np() disables delivery of any asynchronous signal, until unblocked. Signal blocking establishes a critical section where the execution flow of the thread cannot be diverted into a signal handler. Blocking signals is fast, it is performed by a single memory write into a location established with the kernel.

Synchronous signal delivery cannot be blocked in general, including with these functions.

The blocked state established by the pthread_signals_block_np() is not completely POSIX-compliant. Specifically, system calls executed while in a blocked section, might abort sleep and return EINTR upon queuing of an asynchronous signal to the thread, but the signal handler is not called until the last unblock is done.

Calls to pthread_signals_block_np can be nested, and must be complemented by an equal count of calls to pthread_signals_unblock_np to return the calling thread to the standard mode of signal receiving.

An example use of these function might be the construction of the CPU state that cannot be done atomically, and which includes stages where the state of the thread is not ABI compliant. If a signal is delivered while such state is not yet finished, signal handlers would misbehave. Using standard functions (sigprocmask()) to establish critical section might be much slower, because sigprocmask() is system call, while pthread_signals_block_np() consists of a single atomic memory write.

RETURN VALUES
The functions do not return a value.

ERRORS
There are no errors reported by the functions.

SEE ALSO
sigfastblock(2), sigprocmask(2), pthread_sigmask(3), pthread_np(3)