1<html><head><meta http-equiv="Content-Type" content="text/html; charset=ANSI_X3.4-1968"><title>synchronize_srcu</title><meta name="generator" content="DocBook XSL Stylesheets V1.78.1"><link rel="home" href="index.html" title="Linux Device Drivers"><link rel="up" href="ch01s09.html" title="Kernel utility functions"><link rel="prev" href="API-cleanup-srcu-struct.html" title="cleanup_srcu_struct"><link rel="next" href="API-synchronize-srcu-expedited.html" title="synchronize_srcu_expedited"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center"><span class="phrase">synchronize_srcu</span></th></tr><tr><td width="20%" align="left"><a accesskey="p" href="API-cleanup-srcu-struct.html">Prev</a> </td><th width="60%" align="center">Kernel utility functions</th><td width="20%" align="right"> <a accesskey="n" href="API-synchronize-srcu-expedited.html">Next</a></td></tr></table><hr></div><div class="refentry"><a name="API-synchronize-srcu"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>synchronize_srcu — 2 wait for prior SRCU read-side critical-section completion 3 </p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><div class="funcsynopsis"><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">void <b class="fsfunc">synchronize_srcu </b>(</code></td><td>struct srcu_struct * <var class="pdparam">sp</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div></div></div><div class="refsect1"><a name="idp1108561004"></a><h2>Arguments</h2><div class="variablelist"><dl class="variablelist"><dt><span class="term"><em class="parameter"><code>sp</code></em></span></dt><dd><p> 4 srcu_struct with which to synchronize. 5 </p></dd></dl></div></div><div class="refsect1"><a name="idp1108562620"></a><h2>Description</h2><p> 6 Wait for the count to drain to zero of both indexes. To avoid the 7 possible starvation of <code class="function">synchronize_srcu</code>, it waits for the count of 8 the index=((->completed & 1) ^ 1) to drain to zero at first, 9 and then flip the completed and wait for the count of the other index. 10 </p><p> 11 12 Can block; must be called from process context. 13 </p><p> 14 15 Note that it is illegal to call <code class="function">synchronize_srcu</code> from the corresponding 16 SRCU read-side critical section; doing so will result in deadlock. 17 However, it is perfectly legal to call <code class="function">synchronize_srcu</code> on one 18 srcu_struct from some other srcu_struct's read-side critical section, 19 as long as the resulting graph of srcu_structs is acyclic. 20 </p><p> 21 22 There are memory-ordering constraints implied by <code class="function">synchronize_srcu</code>. 23 On systems with more than one CPU, when <code class="function">synchronize_srcu</code> returns, 24 each CPU is guaranteed to have executed a full memory barrier since 25 the end of its last corresponding SRCU-sched read-side critical section 26 whose beginning preceded the call to <code class="function">synchronize_srcu</code>. In addition, 27 each CPU having an SRCU read-side critical section that extends beyond 28 the return from <code class="function">synchronize_srcu</code> is guaranteed to have executed a 29 full memory barrier after the beginning of <code class="function">synchronize_srcu</code> and before 30 the beginning of that SRCU read-side critical section. Note that these 31 guarantees include CPUs that are offline, idle, or executing in user mode, 32 as well as CPUs that are executing in the kernel. 33 </p><p> 34 35 Furthermore, if CPU A invoked <code class="function">synchronize_srcu</code>, which returned 36 to its caller on CPU B, then both CPU A and CPU B are guaranteed 37 to have executed a full memory barrier during the execution of 38 <code class="function">synchronize_srcu</code>. This guarantee applies even if CPU A and CPU B 39 are the same CPU, but again only if the system has more than one CPU. 40 </p><p> 41 42 Of course, these memory-ordering guarantees apply only when 43 <code class="function">synchronize_srcu</code>, <code class="function">srcu_read_lock</code>, and <code class="function">srcu_read_unlock</code> are 44 passed the same srcu_struct structure. 45</p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="API-cleanup-srcu-struct.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="ch01s09.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="API-synchronize-srcu-expedited.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top"><span class="phrase">cleanup_srcu_struct</span> </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> <span class="phrase">synchronize_srcu_expedited</span></td></tr></table></div></body></html> 46