Hi all, Hi Marc,
I have a question regarding thread-interrupt!. Does the thunk used as the interrupt body executed in the interrupted thread, or in the interrupting thread?
I think that it is ran in the interrupting thread because I ran into concurrency problems that were (I believe) due to fact that the interrupted thread seemed to take back the control while the interrupt body was not finished... is it possible? o_O
Thanks!
-- David
Afficher les réponses par date
Date: Sun, 27 Sep 2009 15:59:06 -0400 From: David St-Hilaire sthilaid@iro.umontreal.ca
I have a question regarding thread-interrupt!. Does the thunk used as the interrupt body executed in the interrupted thread, or in the interrupting thread?
I can't imagine that it would run in the interrupting thread: what would it do, then, beyond (define (thread-interrupt! t p) (p))?
I think that it is ran in the interrupting thread because I ran into concurrency problems that were (I believe) due to fact that the interrupted thread seemed to take back the control while the interrupt body was not finished... is it possible? o_O
What are you using THREAD-INTERRUPT! for?
Ultimately ##thread-interrupt! calls ##thread-int! in _thread.scm
Thread-int! sets thread-result of interrupted thread to (lambda () (your-thunk) (##void)) and insert interrupted thread on run-queue.
thread-result is passed as second argument to thread-restore! and if you look at ___JUMP_THREAD_RESTORE2 in gambit.h , the last step is a jump to this procedure.
So it is executed in the interrupted thread. If interrupting thread and interrupted thread are the same, then it is just a call to the function.