On Thu, Sep 29, 2011 at 03:26:22PM +0200, Jörg F. Wittenberger wrote: > Attempt work around: defer the signal even more: until next schedule > time. I'm not yet satisfied with that solution. (But at least it > allows me to run arbitrary code in the signal handler.) > (I intended so far to try whether it would be better to run it close > to the finalizers; that is at the end of garbage collection. > But that again is just an experiment TBD.) > > Given your situation I hope we can devise a better way. > > I'd need to understand your situation better. > > >I need a way to deliver deferred signals after a syscall returns > >EINTR, before restarting that syscall. > > I see. I understand you need "minimum latency" - right? > > May I ask for more details. I need to understand where this > latency requirement is important. >
Let me try a demonstration showing just the main thread: (define (restart-read fd buf isize) ; call read(2), on the self-pipe, which blocks (let ((r (file-read fd buf isize))) (if (= -1 r) ; ah, a signal was delivered. In Chicken, the signal ; delivery to the prcoess causes this error, but the ; Scheme code signal handler might not have been ; delivered. In this case, it means that I haven't ; written a byte to the self-pipe yet. ; (if (= errno EINTR) ; restart the read. Normally, we would have written ; to our self-pipe already (as the signal is delivered ; the moment we return from our syscall.), but in ; Chicken, I'm not sure our deferred Scheme code has ; been called. When does that happen? If it hasn't ; happened yet, I'll block in this routine, and the ; deferred signal handler will never run. ; ; I need a way to guarantee that the deferred signal ; handler has already been run, before I call any other ; syscall. ; (restart-read fd buf isize)) ; something else went wrong, die. (io-error "read")))) Does that story make more sense? Chicken may already behave this way, I'm not sure how long it waits/when it delivers a deferred signal. The critically important thing is that it do so before making another syscall. -Alan -- .i ma'a lo bradi cu penmi gi'e du _______________________________________________ Chicken-users mailing list Chicken-users@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-users