tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

interrupting I/O in a thread



Delivering a signal to a process waiting in an I/O system call will
interrupt the system call and cause control to return to userland, if
the signal is handled and not ignored.

In principle, one could do that to a thread, too, with pthread_kill.
However, there doesn't seem to be any way to establish a thread-local
signal handler.  pthread_cancel, as far as I can tell, only interrupts
cooperating userland computations, not system calls doing I/O, so it
is of no use here.

Is there any way for a multithreaded library -- which shouldn't munge
global application state such as the process's signal handlers -- to
interrupt one of its own threads waiting in I/O?


The immediate goal of which this is a subproblem is to support
cancelling asynchronous libusb1 transfers: if transfers are submitted
by creating a thread to do read/write, cancelling a transfer requires
interrupting the read/write in which the thread is waiting.  If we had
a separate mechanism for asynchronous transfers, e.g. via aio, with
which ugen(4) cooperated, this would be unnecessary -- but I expect
this subproblem is likely to recur in other domains too.


Home | Main Index | Thread Index | Old Index