<p>The difference between <code>thread_sleep()</code>/<code>thread_wakeup()</code> and <code>thread_await_signal()</code>/<code>thread_signal()</code> is the following:</p>
<h4>Legend:</h4>
<table>
<thead>
<tr>
<th>Symbol</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>T1</code></td>
<td>Thread 1 (or interrupt context); Sender of wakeup signal</td>
</tr>
<tr>
<td><code>T2</code></td>
<td>Thread 2; Sleeping until woken up</td>
</tr>
<tr>
<td><code>b</code></td>
<td>Thread is blocked/sleeping</td>
</tr>
<tr>
<td><code>-</code></td>
<td>Thread is runnable, but not running</td>
</tr>
<tr>
<td><code>=</code></td>
<td>Thread is running</td>
</tr>
<tr>
<td><code>S</code></td>
<td>Thread send wake up signal</td>
</tr>
<tr>
<td><code>B</code></td>
<td>Thread called <code>thread_sleep()</code>/<code>thread_await_signal()</code></td>
</tr>
</tbody>
</table>
<p>All other reasons for sleeping/being blocked and thread priorities/scheduling decisions are simply ignored below to not complicate the diagram with unrelated details.</p>
<h4><code>thread_sleep()</code>/<code>thread_wakeup()</code>:</h4>
<pre><code>                    Signal was lost, sleeps forever
                    |

T1: ==Bbbb---===----Bbbbbbbbbbbb
T2: ---==S------=S=-------------

                 |
                 No one sleeping, signal gets lost
</code></pre>
<h4><code>thread_await_signal()</code>/<code>thread_signal()</code>:</h4>
<pre><code>                    SIGNAL_RECEIVED-flag was set, does not block/sleep here
                    |

T1: ==Bbbb---===----B==========
T2: ---==S------=S=-------------

                 |
                 No one sleeping, SIGNAL_RECEIVED-flag is set
</code></pre>
<p>On more to show how multiple signals between <code>thread_await_signal()</code> are handled:</p>
<pre><code>                    Flag cleared                 Flag cleared
                    |                            |

T1: ==Bbbb---===----B===Bbbb--====-------=====B==Bbbbb
T2: ---==S------=S=--------=S=--------=S=-------------

                 |          |          |
                 Flag set   Flag set   Flag not changed
</code></pre>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/RIOT-OS/RIOT/pull/11006#issuecomment-463144489">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AEn7YHv68ohfcgqRyLLL63TBcChvJFnKks5vM-gUgaJpZM4a21Hc">mute the thread</a>.<img src="https://github.com/notifications/beacon/AEn7YLL2QD4ENcXIZ-BeI9J271FQkoqhks5vM-gUgaJpZM4a21Hc.gif" height="1" width="1" alt="" /></p>
<script type="application/json" data-scope="inboxmarkup">{"api_version":"1.0","publisher":{"api_key":"05dde50f1d1a384dd78767c55493e4bb","name":"GitHub"},"entity":{"external_key":"github/RIOT-OS/RIOT","title":"RIOT-OS/RIOT","subtitle":"GitHub repository","main_image_url":"https://github.githubassets.com/images/email/message_cards/header.png","avatar_image_url":"https://github.githubassets.com/images/email/message_cards/avatar.png","action":{"name":"Open in GitHub","url":"https://github.com/RIOT-OS/RIOT"}},"updates":{"snippets":[{"icon":"PERSON","message":"@maribu in #11006: The difference between `thread_sleep()`/`thread_wakeup()` and `thread_await_signal()`/`thread_signal()` is the following:\r\n\r\n#### Legend:\r\n\r\n| Symbol | Description                                              |\r\n|--------|----------------------------------------------------------|\r\n| `T1`   | Thread 1 (or interrupt context); Sender of wakeup signal |\r\n| `T2`   | Thread 2; Sleeping until woken up                        |\r\n| `b`    | Thread is blocked/sleeping                               |\r\n| `-`    | Thread is runnable, but not running                      |\r\n| `=`    | Thread is running                                        |\r\n| `S`    | Thread send wake up signal                               |\r\n| `B`    | Thread called `thread_sleep()`/`thread_await_signal()`   |\r\n\r\nAll other reasons for sleeping/being blocked and thread priorities/scheduling decisions are simply ignored below to not complicate the diagram with unrelated details.\r\n\r\n#### `thread_sleep()`/`thread_wakeup()`:\r\n```\r\n                    Signal was lost, sleeps forever\r\n                    |\r\n\r\nT1: ==Bbbb---===----Bbbbbbbbbbbb\r\nT2: ---==S------=S=-------------\r\n\r\n                 |\r\n                 No one sleeping, signal gets lost\r\n```\r\n\r\n#### `thread_await_signal()`/`thread_signal()`:\r\n```\r\n                    SIGNAL_RECEIVED-flag was set, does not block/sleep here\r\n                    |\r\n\r\nT1: ==Bbbb---===----B==========\r\nT2: ---==S------=S=-------------\r\n\r\n                 |\r\n                 No one sleeping, SIGNAL_RECEIVED-flag is set\r\n```\r\n\r\nOn more to show how multiple signals between `thread_await_signal()` are handled:\r\n\r\n```\r\n                    Flag cleared                 Flag cleared\r\n                    |                            |\r\n\r\nT1: ==Bbbb---===----B===Bbbb--====-------=====B==Bbbbb\r\nT2: ---==S------=S=--------=S=--------=S=-------------\r\n\r\n                 |          |          |\r\n                 Flag set   Flag set   Flag not changed\r\n```"}],"action":{"name":"View Pull Request","url":"https://github.com/RIOT-OS/RIOT/pull/11006#issuecomment-463144489"}}}</script>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/RIOT-OS/RIOT/pull/11006#issuecomment-463144489",
"url": "https://github.com/RIOT-OS/RIOT/pull/11006#issuecomment-463144489",
"name": "View Pull Request"
},
"description": "View this Pull Request on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>