1 <!-- HTML header for doxygen 1.8.20-->
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml">
5 <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
6 <meta http-equiv="X-UA-Compatible" content="IE=9"/>
7 <meta name="generator" content="Doxygen 1.9.4"/>
8 <meta name="viewport" content="width=device-width, initial-scale=1"/>
9 <title>Raspberry Pi Pico SDK: include/pico/lock_core.h File Reference</title>
10 <!-- <link href="tabs.css" rel="stylesheet" type="text/css"/> -->
11 <script type="text/javascript" src="jquery.js"></script>
12 <script type="text/javascript" src="dynsections.js"></script>
13 <link href="navtree.css" rel="stylesheet" type="text/css"/>
14 <script type="text/javascript" src="resize.js"></script>
15 <script type="text/javascript" src="navtreedata.js"></script>
16 <script type="text/javascript" src="navtree.js"></script>
17 <link href="search/search.css" rel="stylesheet" type="text/css"/>
18 <script type="text/javascript" src="search/searchdata.js"></script>
19 <script type="text/javascript" src="search/search.js"></script>
20 <link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500&display=swap" rel="stylesheet">
21 <link href="doxygen.css" rel="stylesheet" type="text/css" />
22 <link href="normalise.css" rel="stylesheet" type="text/css"/>
23 <link href="main.css" rel="stylesheet" type="text/css"/>
24 <link href="styles.css" rel="stylesheet" type="text/css"/>
27 <div class="navigation-mobile">
28 <div class="logo--mobile">
29 <a href="/"><img src="logo-mobile.svg" alt="Raspberry Pi"></a>
31 <div class="navigation-toggle">
32 <span class="line-1"></span>
36 <span class="line-3"></span>
39 <div id="top"><!-- do not remove this div, it is closed by doxygen! -->
41 <a href="index.html"> <img src="logo.svg" alt="Raspberry Pi"></a>
42 <span style="display: inline-block; margin-top: 10px;">
46 <div class="navigation-footer">
47 <img src="logo-mobile.svg" alt="Raspberry Pi">
48 <a href="https://www.raspberrypi.com/" target="_blank">By Raspberry Pi Ltd</a>
50 <!-- <div class="search">
52 <input type="search" name="search" id="search" placeholder="Search">
53 <input type="submit" value="Search">
56 <!-- Generated by Doxygen 1.9.4 -->
57 <script type="text/javascript">
58 /* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
59 var searchBox = new SearchBox("searchBox", "search",'Search','.html');
62 <script type="text/javascript" src="menudata.js"></script>
63 <script type="text/javascript" src="menu.js"></script>
64 <script type="text/javascript">
65 /* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
67 initMenu('',true,false,'search.php','Search');
68 $(document).ready(function() { init_search(); });
72 <div id="main-nav"></div>
74 <div id="side-nav" class="ui-resizable side-nav-resizable">
76 <div id="nav-tree-contents">
77 <div id="nav-sync" class="sync"></div>
80 <div id="splitbar" style="-moz-user-select:none;"
81 class="ui-resizable-handle">
84 <script type="text/javascript">
85 /* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
86 $(document).ready(function(){initNavTree('lock__core_8h.html',''); initResizable(); });
89 <div id="doc-content">
90 <!-- window showing the filter options -->
91 <div id="MSearchSelectWindow"
92 onmouseover="return searchBox.OnSearchSelectShow()"
93 onmouseout="return searchBox.OnSearchSelectHide()"
94 onkeydown="return searchBox.OnSearchSelectKey(event)">
97 <!-- iframe showing the search results (closed by default) -->
98 <div id="MSearchResultsWindow">
99 <iframe src="javascript:void(0)" frameborder="0"
100 name="MSearchResults" id="MSearchResults">
105 <div class="summary">
106 <a href="#nested-classes">Data Structures</a> |
107 <a href="#define-members">Macros</a> |
108 <a href="#typedef-members">Typedefs</a> |
109 <a href="#func-members">Functions</a> </div>
110 <div class="headertitle"><div class="title">lock_core.h File Reference<div class="ingroups"><a class="el" href="group__high__level.html">High Level APIs</a> » <a class="el" href="group__pico__sync.html">pico_sync</a> » <a class="el" href="group__lock__core.html">lock_core</a></div></div></div>
112 <div class="contents">
113 <div class="textblock"><code>#include "<a class="el" href="pico_8h_source.html">pico.h</a>"</code><br />
114 <code>#include "<a class="el" href="common_2pico__time_2include_2pico_2time_8h_source.html">pico/time.h</a>"</code><br />
115 <code>#include "<a class="el" href="rp2__common_2hardware__sync_2include_2hardware_2sync_8h_source.html">hardware/sync.h</a>"</code><br />
116 </div><div class="textblock"><div class="dynheader">
117 Include dependency graph for lock_core.h:</div>
118 <div class="dyncontent">
119 <div class="center"><img src="lock__core_8h__incl.png" border="0" usemap="#ainclude_2pico_2lock__core_8h" alt=""/></div>
120 <map name="ainclude_2pico_2lock__core_8h" id="ainclude_2pico_2lock__core_8h">
121 <area shape="rect" title=" " alt="" coords="350,5,529,32"/>
122 <area shape="rect" href="pico_8h.html" title=" " alt="" coords="409,244,470,271"/>
123 <area shape="rect" href="common_2pico__time_2include_2pico_2time_8h.html" title=" " alt="" coords="307,80,401,107"/>
124 <area shape="rect" href="rp2__common_2hardware__sync_2include_2hardware_2sync_8h.html" title=" " alt="" coords="537,80,667,107"/>
125 <area shape="rect" href="common_2pico__base__headers_2include_2pico_2types_8h_source.html" title=" " alt="" coords="589,468,690,495"/>
126 <area shape="rect" title=" " alt="" coords="235,319,348,345"/>
127 <area shape="rect" href="common_2pico__base__headers_2include_2pico_2config_8h_source.html" title=" " alt="" coords="439,319,543,345"/>
128 <area shape="rect" href="platform_8h.html" title=" " alt="" coords="907,319,1028,345"/>
129 <area shape="rect" href="error_8h_source.html" title=" " alt="" coords="116,319,211,345"/>
130 <area shape="rect" href="assert_8h_source.html" title=" " alt="" coords="436,543,541,569"/>
131 <area shape="rect" title=" " alt="" coords="505,617,587,644"/>
132 <area shape="rect" title=" " alt="" coords="641,543,712,569"/>
133 <area shape="rect" title=" " alt="" coords="737,543,811,569"/>
134 <area shape="rect" title=" " alt="" coords="424,393,588,420"/>
135 <area shape="rect" href="compiler_8h_source.html" title=" " alt="" coords="973,393,1154,420"/>
136 <area shape="rect" href="sections_8h_source.html" title=" " alt="" coords="1178,393,1357,420"/>
137 <area shape="rect" href="panic_8h_source.html" title=" " alt="" coords="613,393,773,420"/>
138 <area shape="rect" title=" " alt="" coords="1381,393,1591,420"/>
139 <area shape="rect" title=" " alt="" coords="797,393,948,420"/>
140 <area shape="rect" title=" " alt="" coords="968,468,1159,495"/>
141 <area shape="rect" href="rp2__common_2hardware__timer_2include_2hardware_2timer_8h.html" title=" " alt="" coords="218,162,351,189"/>
142 <area shape="rect" title=" " alt="" coords="199,244,381,271"/>
143 <area shape="rect" title=" " alt="" coords="5,244,175,271"/>
144 <area shape="rect" href="address__mapped_8h.html" title=" " alt="" coords="701,162,911,189"/>
145 <area shape="rect" href="spin__lock_8h_source.html" title=" " alt="" coords="528,155,676,196"/>
148 </div><div class="textblock"><div class="dynheader">
149 This graph shows which files directly or indirectly include this file:</div>
150 <div class="dyncontent">
151 <div class="center"><img src="lock__core_8h__dep__incl.png" border="0" usemap="#ainclude_2pico_2lock__core_8hdep" alt=""/></div>
152 <map name="ainclude_2pico_2lock__core_8hdep" id="ainclude_2pico_2lock__core_8hdep">
153 <area shape="rect" title=" " alt="" coords="255,5,434,32"/>
154 <area shape="rect" href="critical__section_8h.html" title=" " alt="" coords="5,80,153,121"/>
155 <area shape="rect" href="mutex_8h.html" title=" " alt="" coords="177,87,336,114"/>
156 <area shape="rect" href="sem_8h.html" title=" " alt="" coords="361,87,505,114"/>
157 <area shape="rect" href="queue_8h.html" title=" " alt="" coords="529,87,710,114"/>
158 <area shape="rect" href="common_2pico__sync_2include_2pico_2sync_8h.html" title=" " alt="" coords="97,184,243,211"/>
159 <area shape="rect" href="multicore_8h.html" title=" " alt="" coords="81,273,259,300"/>
160 <area shape="rect" href="async__context__threadsafe__background_8h_source.html" title=" " alt="" coords="267,169,422,225"/>
161 <area shape="rect" href="async__context__poll_8h_source.html" title=" " alt="" coords="447,177,589,218"/>
165 <p><a href="lock__core_8h_source.html">Go to the source code of this file.</a></p>
166 <table class="memberdecls">
167 <tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="nested-classes" name="nested-classes"></a>
168 Data Structures</h2></td></tr>
169 <tr class="memitem:"><td class="memItemLeft" align="right" valign="top">struct  </td><td class="memItemRight" valign="bottom"><a class="el" href="structlock__core.html">lock_core</a></td></tr>
170 <tr class="separator:"><td class="memSeparator" colspan="2"> </td></tr>
171 </table><table class="memberdecls">
172 <tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="define-members" name="define-members"></a>
173 Macros</h2></td></tr>
174 <tr class="memitem:aeef69533b68696315d8657f42b1af6ed"><td class="memItemLeft" align="right" valign="top"><a id="aeef69533b68696315d8657f42b1af6ed" name="aeef69533b68696315d8657f42b1af6ed"></a>
175 #define </td><td class="memItemRight" valign="bottom"><b>PARAM_ASSERTIONS_ENABLED_LOCK_CORE</b>   0</td></tr>
176 <tr class="separator:aeef69533b68696315d8657f42b1af6ed"><td class="memSeparator" colspan="2"> </td></tr>
177 <tr class="memitem:ga7e5b614312aabaada704b6a2350d39bc"><td class="memItemLeft" align="right" valign="top">#define </td><td class="memItemRight" valign="bottom"><a class="el" href="group__lock__core.html#ga7e5b614312aabaada704b6a2350d39bc">lock_owner_id_t</a>   int8_t</td></tr>
178 <tr class="memdesc:ga7e5b614312aabaada704b6a2350d39bc"><td class="mdescLeft"> </td><td class="mdescRight">type to use to store the 'owner' of a lock. <a href="group__lock__core.html#ga7e5b614312aabaada704b6a2350d39bc">More...</a><br /></td></tr>
179 <tr class="separator:ga7e5b614312aabaada704b6a2350d39bc"><td class="memSeparator" colspan="2"> </td></tr>
180 <tr class="memitem:ga56aa223ceb22fdc4f0a3464fff119e14"><td class="memItemLeft" align="right" valign="top">
181 #define </td><td class="memItemRight" valign="bottom"><b>LOCK_INVALID_OWNER_ID</b>   ((<a class="el" href="group__lock__core.html#ga7e5b614312aabaada704b6a2350d39bc">lock_owner_id_t</a>)-1)</td></tr>
182 <tr class="memdesc:ga56aa223ceb22fdc4f0a3464fff119e14"><td class="mdescLeft"> </td><td class="mdescRight">marker value to use for a lock_owner_id_t which does not refer to any valid owner <br /></td></tr>
183 <tr class="separator:ga56aa223ceb22fdc4f0a3464fff119e14"><td class="memSeparator" colspan="2"> </td></tr>
184 <tr class="memitem:gae28f1d974cf1f1b973127500a764245c"><td class="memItemLeft" align="right" valign="top">#define </td><td class="memItemRight" valign="bottom"><a class="el" href="group__lock__core.html#gae28f1d974cf1f1b973127500a764245c">lock_get_caller_owner_id</a>()   ((<a class="el" href="group__lock__core.html#ga7e5b614312aabaada704b6a2350d39bc">lock_owner_id_t</a>)<a class="el" href="group__pico__platform.html#ga58434ad816f519308ee02c639b7965bc">get_core_num</a>())</td></tr>
185 <tr class="memdesc:gae28f1d974cf1f1b973127500a764245c"><td class="mdescLeft"> </td><td class="mdescRight">return the owner id for the caller <a href="group__lock__core.html#gae28f1d974cf1f1b973127500a764245c">More...</a><br /></td></tr>
186 <tr class="separator:gae28f1d974cf1f1b973127500a764245c"><td class="memSeparator" colspan="2"> </td></tr>
187 <tr class="memitem:ad11a50437318f92a9e0b9ae6ff088300"><td class="memItemLeft" align="right" valign="top"><a id="ad11a50437318f92a9e0b9ae6ff088300" name="ad11a50437318f92a9e0b9ae6ff088300"></a>
188 #define </td><td class="memItemRight" valign="bottom"><b>lock_is_owner_id_valid</b>(id)   ((id)>=0)</td></tr>
189 <tr class="separator:ad11a50437318f92a9e0b9ae6ff088300"><td class="memSeparator" colspan="2"> </td></tr>
190 <tr class="memitem:gaaea64ba43b0ff683739ba136fe5a2b29"><td class="memItemLeft" align="right" valign="top">#define </td><td class="memItemRight" valign="bottom"><a class="el" href="group__lock__core.html#gaaea64ba43b0ff683739ba136fe5a2b29">lock_internal_spin_unlock_with_wait</a>(lock, save)   <a class="el" href="group__hardware__sync.html#ga281ce69786da23cab7ba6c42537d4e87">spin_unlock</a>((lock)->spin_lock, save), <a class="el" href="group__hardware__sync.html#ga7799a0b9fc6444d463170266392f5fcd">__wfe</a>()</td></tr>
191 <tr class="memdesc:gaaea64ba43b0ff683739ba136fe5a2b29"><td class="mdescLeft"> </td><td class="mdescRight">Atomically unlock the lock's spin lock, and wait for a notification. <a href="group__lock__core.html#gaaea64ba43b0ff683739ba136fe5a2b29">More...</a><br /></td></tr>
192 <tr class="separator:gaaea64ba43b0ff683739ba136fe5a2b29"><td class="memSeparator" colspan="2"> </td></tr>
193 <tr class="memitem:ga298f38f465c9115393f0f35f56c13279"><td class="memItemLeft" align="right" valign="top">#define </td><td class="memItemRight" valign="bottom"><a class="el" href="group__lock__core.html#ga298f38f465c9115393f0f35f56c13279">lock_internal_spin_unlock_with_notify</a>(lock, save)   <a class="el" href="group__hardware__sync.html#ga281ce69786da23cab7ba6c42537d4e87">spin_unlock</a>((lock)->spin_lock, save), <a class="el" href="group__hardware__sync.html#ga486eada32246494118f8273a80ae6856">__sev</a>()</td></tr>
194 <tr class="memdesc:ga298f38f465c9115393f0f35f56c13279"><td class="mdescLeft"> </td><td class="mdescRight">Atomically unlock the lock's spin lock, and send a notification. <a href="group__lock__core.html#ga298f38f465c9115393f0f35f56c13279">More...</a><br /></td></tr>
195 <tr class="separator:ga298f38f465c9115393f0f35f56c13279"><td class="memSeparator" colspan="2"> </td></tr>
196 <tr class="memitem:ga627a09221ed61634d6dfea6f406e104e"><td class="memItemLeft" align="right" valign="top">#define </td><td class="memItemRight" valign="bottom"><a class="el" href="group__lock__core.html#ga627a09221ed61634d6dfea6f406e104e">lock_internal_spin_unlock_with_best_effort_wait_or_timeout</a>(lock, save, until)</td></tr>
197 <tr class="memdesc:ga627a09221ed61634d6dfea6f406e104e"><td class="mdescLeft"> </td><td class="mdescRight">Atomically unlock the lock's spin lock, and wait for a notification or a timeout. <a href="group__lock__core.html#ga627a09221ed61634d6dfea6f406e104e">More...</a><br /></td></tr>
198 <tr class="separator:ga627a09221ed61634d6dfea6f406e104e"><td class="memSeparator" colspan="2"> </td></tr>
199 <tr class="memitem:ga133eb482d67637b8b4e947dee5133513"><td class="memItemLeft" align="right" valign="top">#define </td><td class="memItemRight" valign="bottom"><a class="el" href="group__lock__core.html#ga133eb482d67637b8b4e947dee5133513">sync_internal_yield_until_before</a>(until)   ((void)0)</td></tr>
200 <tr class="memdesc:ga133eb482d67637b8b4e947dee5133513"><td class="mdescLeft"> </td><td class="mdescRight">yield to other processing until some time before the requested time <a href="group__lock__core.html#ga133eb482d67637b8b4e947dee5133513">More...</a><br /></td></tr>
201 <tr class="separator:ga133eb482d67637b8b4e947dee5133513"><td class="memSeparator" colspan="2"> </td></tr>
202 </table><table class="memberdecls">
203 <tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="typedef-members" name="typedef-members"></a>
204 Typedefs</h2></td></tr>
205 <tr class="memitem:a90b364947043d17f922526c661a03a55"><td class="memItemLeft" align="right" valign="top"><a id="a90b364947043d17f922526c661a03a55" name="a90b364947043d17f922526c661a03a55"></a>
206 typedef struct <a class="el" href="structlock__core.html">lock_core</a> </td><td class="memItemRight" valign="bottom"><b>lock_core_t</b></td></tr>
207 <tr class="separator:a90b364947043d17f922526c661a03a55"><td class="memSeparator" colspan="2"> </td></tr>
208 </table><table class="memberdecls">
209 <tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="func-members" name="func-members"></a>
210 Functions</h2></td></tr>
211 <tr class="memitem:gabc062dfb52c8f7f17ec8427d1c4414d9"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="group__lock__core.html#gabc062dfb52c8f7f17ec8427d1c4414d9">lock_init</a> (<a class="el" href="structlock__core.html">lock_core_t</a> *core, uint lock_num)</td></tr>
212 <tr class="memdesc:gabc062dfb52c8f7f17ec8427d1c4414d9"><td class="mdescLeft"> </td><td class="mdescRight">Initialise a lock structure. <a href="group__lock__core.html#gabc062dfb52c8f7f17ec8427d1c4414d9">More...</a><br /></td></tr>
213 <tr class="separator:gabc062dfb52c8f7f17ec8427d1c4414d9"><td class="memSeparator" colspan="2"> </td></tr>
215 <a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
216 <div class="textblock"><p >Base implementation for locking primitives protected by a spin lock. The spin lock is only used to protect access to the remaining lock state (in primitives using <a class="el" href="structlock__core.html">lock_core</a>); it is never left locked outside of the function implementations </p>
217 </div></div><!-- contents -->
218 </div><!-- doc-content -->
220 <script src="main.js"></script>