[riot-notifications] [RIOT-OS/RIOT] core/mutex: Add mutex_cancel (#15442)

benpicco notifications at github.com
Sun Nov 15 15:58:17 CET 2020


This certainly allows for some neat hacks, but also dirty ones.
I thought it would be neat for being able to inject shell commands into the shell thread.
Right now it will wait on a mutex in `isrpipe_read()`.

With this we could do (roughly) 

```patch
--- a/sys/shell/shell.c
+++ b/sys/shell/shell.c
@@ -470,6 +470,12 @@ void shell_run_once(const shell_command_t *shell_commands,
     while (1) {
         int res = readline(line_buf, len);
 
+        msg_t m;
+        if (msg_try_receive(&m) == 1) {
+            handle_input_line(shell_commands, m.content.ptr);
+            continue;
+        }
+
         switch (res) {
 
             case EOF:
```

Granted, that *feels* dirty - and I know why: A thread might wait on multiple mutexen. How can we be sure to cancel the right on? 

-- 
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/15442#issuecomment-727582859
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20201115/3529e787/attachment.htm>


More information about the notifications mailing list