[riot-notifications] [RIOT-OS/RIOT] core: Added thread_signal & thread_await_signal (#11006)

Marian Buschsieweke notifications at github.com
Wed Feb 13 11:25:25 CET 2019


The difference between `thread_sleep()`/`thread_wakeup()` and `thread_await_signal()`/`thread_signal()` is the following:

#### Legend:

| Symbol | Description                                              |
|--------|----------------------------------------------------------|
| `T1`   | Thread 1 (or interrupt context); Sender of wakeup signal |
| `T2`   | Thread 2; Sleeping until woken up                        |
| `b`    | Thread is blocked/sleeping                               |
| `-`    | Thread is runnable, but not running                      |
| `=`    | Thread is running                                        |
| `S`    | Thread send wake up signal                               |
| `B`    | Thread called `thread_sleep()`/`thread_await_signal()`   |

All other reasons for sleeping/being blocked and thread priorities/scheduling decisions are simply ignored below to not complicate the diagram with unrelated details.

#### `thread_sleep()`/`thread_wakeup()`:
```
                    Signal was lost, sleeps forever
                    |

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

                 |
                 No one sleeping, signal gets lost
```

#### `thread_await_signal()`/`thread_signal()`:
```
                    SIGNAL_RECEIVED-flag was set, does not block/sleep here
                    |

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

                 |
                 No one sleeping, SIGNAL_RECEIVED-flag is set
```

On more to show how multiple signals between `thread_await_signal()` are handled:

```
                    Flag cleared                 Flag cleared
                    |                            |

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

                 |          |          |
                 Flag set   Flag set   Flag not changed
```

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/pull/11006#issuecomment-463144489
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20190213/ffb3dfe5/attachment.html>


More information about the notifications mailing list