raz / commit db917e56

commit
db917e56fc0d790df3c0be0652578e71a1412c7f
author
Luis <42945842+ldiaz94@users.noreply.github.com>
date
parent
e3839b4b
PROPOSALS: a signal to one thread

patch · log

1 file changed, +27 -0

PROPOSALS.md modified +27 -0

@@ -601,3 +601,30 @@
601601
602602 Met in mosaico's `Mconfig`, where `MenuAction.run` and a status block's
603603 kind `run` met; the block's kind was renamed `command`.
604+
605+## A signal to one thread
606+
607+`Sys.kill` signals a process, and the kernel gives the signal to any
608+of its threads that doesn't block it. A program whose thread waits in
609+a system call, a read or a `Sys.ready`, has no way to break into that
610+wait from another thread: the signal may land on the thread that sent
611+it, or on a third.
612+
613+The proposal, in the library:
614+
615+```
616+proc signal*(t: ^Thread; sig: INT): INT; (* sig sent to t alone; 0, or minus an errno *)
617+```
618+
619+in `Thread`, beside `join`: `tgkill(getpid(), t^.tid, sig)` in a
620+program without C, `pthread_kill(t^.tid, sig)` in one with C, as
621+`Thread` already keeps either id in `tid`. With `Sys.handle(sig)` in
622+the program, the wait the thread is in fails with -4, as `^C` makes a
623+wait fail on the main thread today. It breaks no program, so it could
624+come with any release, not only a thaw.
625+
626+Met in arno's screen: a turn runs on a thread of its own, reading the
627+model's reply with rnet. The human's `C-c` is a key on the loop's
628+thread, which can only set a flag that the turn reads after each read
629+of the reply; a server that says nothing for a minute, as a model does
630+while it thinks, keeps the turn going for that minute.