* [9fans] alarm() and threads..
@ 2005-12-06 22:16 ISHWAR RATTAN
2005-12-06 22:24 ` Russ Cox
0 siblings, 1 reply; 6+ messages in thread
From: ISHWAR RATTAN @ 2005-12-06 22:16 UTC (permalink / raw)
To: 9fans
What is the behavior of using alarm() in one of the threads
in a multi-threaded program? Which will thread will get the
note? Or it is undefined -- alarm() can be used at process
level.
Also, where can I find sample code to handle terminal
abort/interrupt?
-ishwar
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [9fans] alarm() and threads..
2005-12-06 22:16 [9fans] alarm() and threads ISHWAR RATTAN
@ 2005-12-06 22:24 ` Russ Cox
2005-12-07 14:29 ` ISHWAR RATTAN
0 siblings, 1 reply; 6+ messages in thread
From: Russ Cox @ 2005-12-06 22:24 UTC (permalink / raw)
To: Fans of the OS Plan 9 from Bell Labs
> What is the behavior of using alarm() in one of the threads
> in a multi-threaded program? Which will thread will get the
> note?
Threads don't get notes. Processes do. The function you
register with threadnotify will run in the same proc that
got the note, and if that proc was in a system call, that
system call will have been interrupted, regardless of which
thread inside the proc was running the system call.
If your code looks like:
alarm(10);
read();
alarm(0);
then you can be sure that your thread's read is the one that
will be interrupted should the alarm go off.
> Also, where can I find sample code to handle terminal
> abort/interrupt?
Depends on what you mean by this. If you mean when
the user types Delete to kill a program, that turns into
a "interrupt" note.
Russ
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2005-12-07 18:43 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-12-06 22:16 [9fans] alarm() and threads ISHWAR RATTAN
2005-12-06 22:24 ` Russ Cox
2005-12-07 14:29 ` ISHWAR RATTAN
2005-12-07 14:32 ` Russ Cox
2005-12-07 17:11 ` ISHWAR RATTAN
2005-12-07 18:43 ` Russ Cox
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).