@mflatt Can you explain to me what will happen in the racket7 thread system if the “main” thread is removed from its thread group and is later re-added; and there are no threads in the meantime. It doesn’t seem that select-thread! is called again if this happens?
For example: (begin (define f (future (lambda () (thread-send (current-thread) "msg"))))
(touch f)
(thread-receive))
I know this is meant to result in “msg” but I am not sure if the current system implements this behavior correctly.
although I see I am missing some commits marked thread repair so I will try rebasing and see if this clears things up
Does thread-send
run in the touching thread?
I believe so?
There should only be one thread
@spall I think that @mflatt is asking if thread-send
blocks and runs in the continuation of the touch
No, it does not block
I am confused why that would matter
I think (current-thread)
only makes sense except as a blocking operation (i.e., should be run in the context of a touch
)
Maybe thread-send
can run in a separate OS thread, but it would need to signal the main OS thread to let it know that something changed in the environment
For example (semaphore-wait (make-semaphore))
as the whole program will suspend the main thread and not call select-thread!
anymore; but a Ctl-C sends an extra signal that wakes the scheduler back up
Okay, I think I need to restate the general problem a different way then. I didn’t necessarily mean for this to be something specific to thread-send/thread-receive, but was referring to them because they case a thread to stop and start running again.
The existing external-signal mechanism lives in the “io” layer; probably the sandman API should have an external-signal callback
I suppose what matters is how a future is allowed to interact with a thread. Is it allowed that the main thread wait on a signal from a future? And if so, how can the future get the main thread to run again?
(Right – to be clear, that’s the question I’m trying to answer above. You need to add some wakeup mechanism to interrupt thdo-sleep
callback in a sandman.)
okay great thanks!