spall
2017-9-14 17:28:20

@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?


spall
2017-9-14 17:29:48

For example: (begin (define f (future (lambda () (thread-send (current-thread) "msg")))) (touch f) (thread-receive))


spall
2017-9-14 17:30:49

I know this is meant to result in “msg” but I am not sure if the current system implements this behavior correctly.


spall
2017-9-14 17:45:45

although I see I am missing some commits marked thread repair so I will try rebasing and see if this clears things up


mflatt
2017-9-14 17:47:59

Does thread-send run in the touching thread?


spall
2017-9-14 17:49:10

I believe so?


spall
2017-9-14 17:49:33

There should only be one thread


samth
2017-9-14 17:55:42

@spall I think that @mflatt is asking if thread-send blocks and runs in the continuation of the touch


spall
2017-9-14 17:56:06

No, it does not block


spall
2017-9-14 17:56:43

I am confused why that would matter


mflatt
2017-9-14 17:57:38

I think (current-thread) only makes sense except as a blocking operation (i.e., should be run in the context of a touch)


mflatt
2017-9-14 17:58:16

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


mflatt
2017-9-14 17:58:53

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


spall
2017-9-14 17:59:35

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.


mflatt
2017-9-14 18:00:44

The existing external-signal mechanism lives in the “io” layer; probably the sandman API should have an external-signal callback


spall
2017-9-14 18:00:58

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?


mflatt
2017-9-14 18:02:47

(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.)


spall
2017-9-14 18:03:53

okay great thanks!