libthread: use "interrupt" proc ctl message instead of posting a note for threadint()
threadint() is called to interrupt channel operation or a system call. the kernel provides a new "interrupt" procctl message to interrupt a process commited to or being in a blocking syscall, which is similar, but not the same. the main difference is that "interrupt" condition is not cleared before the process actually attempts to block. also can be cleared with "nointerrupt" ctl message. see proc(3)
This commit is contained in:
parent
a98f911a17
commit
c235046310
1 changed files with 12 additions and 0 deletions
|
@ -79,8 +79,20 @@ threadint(int id)
|
|||
static void
|
||||
tinterrupt(Proc *p, Thread *t)
|
||||
{
|
||||
char buf[64];
|
||||
int fd;
|
||||
|
||||
switch(t->state){
|
||||
case Running:
|
||||
snprint(buf, sizeof(buf), "/proc/%d/ctl", p->pid);
|
||||
fd = open(buf, OWRITE|OCEXEC);
|
||||
if(fd >= 0){
|
||||
if(write(fd, "interrupt", 9) == 9){
|
||||
close(fd);
|
||||
break;
|
||||
}
|
||||
close(fd);
|
||||
}
|
||||
postnote(PNPROC, p->pid, "threadint");
|
||||
break;
|
||||
case Rendezvous:
|
||||
|
|
Loading…
Reference in a new issue