summaryrefslogtreecommitdiff
path: root/static/freebsd/man3/pthread_signals_block_np.3 3.html
blob: 04d9dc4d24fbe85bee52249a49f3788b69be9580 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<table class="head">
  <tr>
    <td class="head-ltitle">PTHREAD_SIGNALS_BLOCK_NP(3)</td>
    <td class="head-vol">Library Functions Manual</td>
    <td class="head-rtitle">PTHREAD_SIGNALS_BLOCK_NP(3)</td>
  </tr>
</table>
<div class="manual-text">
<section class="Sh">
<h1 class="Sh" id="NAME"><a class="permalink" href="#NAME">NAME</a></h1>
<p class="Pp"><code class="Nm">pthread_signals_block_np</code>,
    <code class="Nm">pthread_signals_unblock_np</code> &#x2014;
    <span class="Nd">fast asynchronous signals blocking and
  unblocking</span></p>
</section>
<section class="Sh">
<h1 class="Sh" id="LIBRARY"><a class="permalink" href="#LIBRARY">LIBRARY</a></h1>
<p class="Pp"><span class="Lb">POSIX Threads Library (libpthread,
    -lpthread)</span></p>
</section>
<section class="Sh">
<h1 class="Sh" id="SYNOPSIS"><a class="permalink" href="#SYNOPSIS">SYNOPSIS</a></h1>
<p class="Pp"><code class="In">#include
    &lt;<a class="In">pthread_np.h</a>&gt;</code></p>
<p class="Pp"><var class="Ft">void</var>
  <br/>
  <code class="Fn">pthread_signals_block_np</code>(<var class="Fa" style="white-space: nowrap;">void</var>);</p>
<p class="Pp"><var class="Ft">void</var>
  <br/>
  <code class="Fn">pthread_signals_unblock_np</code>(<var class="Fa" style="white-space: nowrap;">void</var>);</p>
</section>
<section class="Sh">
<h1 class="Sh" id="DESCRIPTION"><a class="permalink" href="#DESCRIPTION">DESCRIPTION</a></h1>
<p class="Pp">The
    <a class="permalink" href="#pthread_signals_block_np"><code class="Fn" id="pthread_signals_block_np">pthread_signals_block_np</code></a>()
    and
    <a class="permalink" href="#pthread_signals_unblock_np"><code class="Fn" id="pthread_signals_unblock_np">pthread_signals_unblock_np</code></a>()
    functions provide user programs an interface to the fast asynchronous
    signals blocking facility <a class="Xr">sigfastblock(2)</a>.</p>
<p class="Pp" id="pthread_signals_block_np~2">Blocking signals with
    <a class="permalink" href="#pthread_signals_block_np~2"><code class="Fn">pthread_signals_block_np</code></a>()
    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.</p>
<p class="Pp">Synchronous signal delivery cannot be blocked in general,
    including with these functions.</p>
<p class="Pp" id="pthread_signals_block_np~3">The blocked state established by
    the
    <a class="permalink" href="#pthread_signals_block_np~3"><code class="Fn">pthread_signals_block_np</code></a>()
    is not completely POSIX-compliant. Specifically, system calls executed while
    in a blocked section, might abort sleep and return
    <code class="Er">EINTR</code> upon queuing of an asynchronous signal to the
    thread, but the signal handler is not called until the last unblock is
  done.</p>
<p class="Pp">Calls to <code class="Nm">pthread_signals_block_np</code> can be
    nested, and must be complemented by an equal count of calls to
    <code class="Nm">pthread_signals_unblock_np</code> to return the calling
    thread to the standard mode of signal receiving.</p>
<p class="Pp" id="sigprocmask">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
    (<a class="permalink" href="#sigprocmask"><code class="Fn">sigprocmask</code></a>())
    to establish critical section might be much slower, because
    <code class="Fn">sigprocmask</code>() is system call, while
    <code class="Fn">pthread_signals_block_np</code>() consists of a single
    atomic memory write.</p>
</section>
<section class="Sh">
<h1 class="Sh" id="RETURN_VALUES"><a class="permalink" href="#RETURN_VALUES">RETURN
  VALUES</a></h1>
<p class="Pp">The functions do not return a value.</p>
</section>
<section class="Sh">
<h1 class="Sh" id="ERRORS"><a class="permalink" href="#ERRORS">ERRORS</a></h1>
<p class="Pp">There are no errors reported by the functions.</p>
</section>
<section class="Sh">
<h1 class="Sh" id="SEE_ALSO"><a class="permalink" href="#SEE_ALSO">SEE
  ALSO</a></h1>
<p class="Pp"><a class="Xr">sigfastblock(2)</a>,
    <a class="Xr">sigprocmask(2)</a>, <a class="Xr">pthread_sigmask(3)</a>,
    <a class="Xr">pthread_np(3)</a></p>
</section>
</div>
<table class="foot">
  <tr>
    <td class="foot-date">May 16, 2025</td>
    <td class="foot-os">FreeBSD 15.0</td>
  </tr>
</table>