libnx/semaphore_8h.html
2025-05-08 06:59:12 +00:00

239 lines
12 KiB
HTML

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.9.8"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>libnx: include/switch/kernel/semaphore.h File Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr id="projectrow">
<td id="projectalign">
<div id="projectname">libnx<span id="projectnumber">&#160;v4.9.0</span>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.8 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "search/",'.html');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() {
initMenu('',true,false,'search.php','Search');
$(document).ready(function() { init_search(); });
});
/* @license-end */
</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>
<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<div id="MSearchResults">
<div class="SRPage">
<div id="SRIndex">
<div id="SRResults"></div>
<div class="SRStatus" id="Loading">Loading...</div>
<div class="SRStatus" id="Searching">Searching...</div>
<div class="SRStatus" id="NoMatches">No Matches</div>
</div>
</div>
</div>
</div>
<div id="nav-path" class="navpath">
<ul>
<li class="navelem"><a class="el" href="dir_d44c64559bbebec7f509842c48db8b23.html">include</a></li><li class="navelem"><a class="el" href="dir_42bea3d40f1f1694e41a8f3166c98108.html">switch</a></li><li class="navelem"><a class="el" href="dir_36b4ff30955378a33ed199d75bfba1a9.html">kernel</a></li> </ul>
</div>
</div><!-- top -->
<div class="header">
<div class="summary">
<a href="#nested-classes">Data Structures</a> &#124;
<a href="#func-members">Functions</a> </div>
<div class="headertitle"><div class="title">semaphore.h File Reference</div></div>
</div><!--header-->
<div class="contents">
<p><a class="el" href="structThread.html" title="Thread information structure.">Thread</a> synchronization based on Mutex.
<a href="#details">More...</a></p>
<div class="textblock"><code>#include &quot;<a class="el" href="mutex_8h_source.html">mutex.h</a>&quot;</code><br />
<code>#include &quot;<a class="el" href="condvar_8h_source.html">condvar.h</a>&quot;</code><br />
</div>
<p><a href="semaphore_8h_source.html">Go to the source code of this file.</a></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="nested-classes" name="nested-classes"></a>
Data Structures</h2></td></tr>
<tr class="memitem:"><td class="memItemLeft" align="right" valign="top">struct &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structSemaphore.html">Semaphore</a></td></tr>
<tr class="memdesc:"><td class="mdescLeft">&#160;</td><td class="mdescRight"><a class="el" href="structSemaphore.html" title="Semaphore structure.">Semaphore</a> structure. <a href="structSemaphore.html#details">More...</a><br /></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="func-members" name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:acc3585d7e0aaa4ca8b95321dc638fcf9" id="r_acc3585d7e0aaa4ca8b95321dc638fcf9"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="semaphore_8h.html#acc3585d7e0aaa4ca8b95321dc638fcf9">semaphoreInit</a> (<a class="el" href="structSemaphore.html">Semaphore</a> *s, <a class="el" href="types_8h.html#a3f7e2bcbb0b4c338f3c4f6c937cd4234">u64</a> initial_count)</td></tr>
<tr class="memdesc:acc3585d7e0aaa4ca8b95321dc638fcf9"><td class="mdescLeft">&#160;</td><td class="mdescRight">Initializes a semaphore and its internal counter. <br /></td></tr>
<tr class="separator:acc3585d7e0aaa4ca8b95321dc638fcf9"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a5a5384a10c64d23211c388b18a9e114a" id="r_a5a5384a10c64d23211c388b18a9e114a"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="semaphore_8h.html#a5a5384a10c64d23211c388b18a9e114a">semaphoreSignal</a> (<a class="el" href="structSemaphore.html">Semaphore</a> *s)</td></tr>
<tr class="memdesc:a5a5384a10c64d23211c388b18a9e114a"><td class="mdescLeft">&#160;</td><td class="mdescRight">Increments the <a class="el" href="structSemaphore.html" title="Semaphore structure.">Semaphore</a> to allow other threads to continue. <br /></td></tr>
<tr class="separator:a5a5384a10c64d23211c388b18a9e114a"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a5ad05e570f1a4fe64219f282795c016b" id="r_a5ad05e570f1a4fe64219f282795c016b"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="semaphore_8h.html#a5ad05e570f1a4fe64219f282795c016b">semaphoreWait</a> (<a class="el" href="structSemaphore.html">Semaphore</a> *s)</td></tr>
<tr class="memdesc:a5ad05e570f1a4fe64219f282795c016b"><td class="mdescLeft">&#160;</td><td class="mdescRight">Decrements <a class="el" href="structSemaphore.html" title="Semaphore structure.">Semaphore</a> and waits if 0. <br /></td></tr>
<tr class="separator:a5ad05e570f1a4fe64219f282795c016b"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a4a50b81a6d719096449f7f6f2e9f728c" id="r_a4a50b81a6d719096449f7f6f2e9f728c"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="semaphore_8h.html#a4a50b81a6d719096449f7f6f2e9f728c">semaphoreTryWait</a> (<a class="el" href="structSemaphore.html">Semaphore</a> *s)</td></tr>
<tr class="memdesc:a4a50b81a6d719096449f7f6f2e9f728c"><td class="mdescLeft">&#160;</td><td class="mdescRight">Attempts to get lock without waiting. <br /></td></tr>
<tr class="separator:a4a50b81a6d719096449f7f6f2e9f728c"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p><a class="el" href="structThread.html" title="Thread information structure.">Thread</a> synchronization based on Mutex. </p>
<dl class="section author"><dt>Author</dt><dd>SciresM &amp; Kevoot </dd></dl>
<dl class="section copyright"><dt>Copyright</dt><dd>libnx Authors </dd></dl>
</div><h2 class="groupheader">Function Documentation</h2>
<a id="acc3585d7e0aaa4ca8b95321dc638fcf9" name="acc3585d7e0aaa4ca8b95321dc638fcf9"></a>
<h2 class="memtitle"><span class="permalink"><a href="#acc3585d7e0aaa4ca8b95321dc638fcf9">&#9670;&#160;</a></span>semaphoreInit()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void semaphoreInit </td>
<td>(</td>
<td class="paramtype"><a class="el" href="structSemaphore.html">Semaphore</a> *&#160;</td>
<td class="paramname"><em>s</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype"><a class="el" href="types_8h.html#a3f7e2bcbb0b4c338f3c4f6c937cd4234">u64</a>&#160;</td>
<td class="paramname"><em>initial_count</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Initializes a semaphore and its internal counter. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">s</td><td><a class="el" href="structSemaphore.html" title="Semaphore structure.">Semaphore</a> object. </td></tr>
<tr><td class="paramname">initial_count</td><td>initial value for internal counter (typically the # of free resources). </td></tr>
</table>
</dd>
</dl>
</div>
</div>
<a id="a5a5384a10c64d23211c388b18a9e114a" name="a5a5384a10c64d23211c388b18a9e114a"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a5a5384a10c64d23211c388b18a9e114a">&#9670;&#160;</a></span>semaphoreSignal()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void semaphoreSignal </td>
<td>(</td>
<td class="paramtype"><a class="el" href="structSemaphore.html">Semaphore</a> *&#160;</td>
<td class="paramname"><em>s</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Increments the <a class="el" href="structSemaphore.html" title="Semaphore structure.">Semaphore</a> to allow other threads to continue. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">s</td><td><a class="el" href="structSemaphore.html" title="Semaphore structure.">Semaphore</a> object. </td></tr>
</table>
</dd>
</dl>
</div>
</div>
<a id="a4a50b81a6d719096449f7f6f2e9f728c" name="a4a50b81a6d719096449f7f6f2e9f728c"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a4a50b81a6d719096449f7f6f2e9f728c">&#9670;&#160;</a></span>semaphoreTryWait()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">bool semaphoreTryWait </td>
<td>(</td>
<td class="paramtype"><a class="el" href="structSemaphore.html">Semaphore</a> *&#160;</td>
<td class="paramname"><em>s</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Attempts to get lock without waiting. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">s</td><td><a class="el" href="structSemaphore.html" title="Semaphore structure.">Semaphore</a> object. </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>true if no wait and successful lock, false otherwise. </dd></dl>
</div>
</div>
<a id="a5ad05e570f1a4fe64219f282795c016b" name="a5ad05e570f1a4fe64219f282795c016b"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a5ad05e570f1a4fe64219f282795c016b">&#9670;&#160;</a></span>semaphoreWait()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void semaphoreWait </td>
<td>(</td>
<td class="paramtype"><a class="el" href="structSemaphore.html">Semaphore</a> *&#160;</td>
<td class="paramname"><em>s</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Decrements <a class="el" href="structSemaphore.html" title="Semaphore structure.">Semaphore</a> and waits if 0. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">s</td><td><a class="el" href="structSemaphore.html" title="Semaphore structure.">Semaphore</a> object. </td></tr>
</table>
</dd>
</dl>
</div>
</div>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by&#160;<a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.8
</small></address>
</body>
</html>