9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* Re: [9fans] thread confusion
@ 2005-09-21 15:48 Fco. J. Ballesteros
  0 siblings, 0 replies; 16+ messages in thread
From: Fco. J. Ballesteros @ 2005-09-21 15:48 UTC (permalink / raw)
  To: 9fans

:  Programming with notes or signals is asking for trouble.
:  Always.  I'm sorry that threadint/threadkill are in the
:  library.

Nothing that can't be solved using Cut. :-)
Appart from aquarela and execnet
how many programs are using this?



^ permalink raw reply	[flat|nested] 16+ messages in thread
* Re: [9fans] thread confusion
@ 2005-09-21 14:44 Fco. J. Ballesteros
  2005-09-21 15:05 ` Axel Belinfante
  0 siblings, 1 reply; 16+ messages in thread
From: Fco. J. Ballesteros @ 2005-09-21 14:44 UTC (permalink / raw)
  To: 9fans

AFAIK, you must call threadnotify() to install a handler for your note.
If you don't do that, your process is killed (which is what you are
seeing right now).

You should probably install a handler that says 'it's ok, got the note'.
Use threadnotify to do this. 
I understand that you are interested in the "side effect" of interrupting
the I/O call.

I't funny, anyway, because I had the same problem a few days ago;
I had to abort a connection to a `Broken-maybe' file server. I tried not
to use interrupts and I was nevertheless decided to

alarm(x)
read()
alarm(0)

the call. After letting Russ know, he (once more) suggested me not to
use interrupts and to read the Alef paper (which I had read before, btw).
However, after thinking it twice, I was able to avoid the interrupts.
(The process is kept there, it will sooner or later abort due to a broken
connection).

Thus, excuse me for suggesting this again ;-), have you tried not to use
interrupts? In your case, if "the other end" decides to give up, can't it
let you know so you could shutdown and restart in a clean way?

hth



^ permalink raw reply	[flat|nested] 16+ messages in thread
* [9fans] thread confusion
@ 2005-09-21 13:53 Fco. J. Ballesteros
  2005-09-21 14:32 ` Axel Belinfante
  0 siblings, 1 reply; 16+ messages in thread
From: Fco. J. Ballesteros @ 2005-09-21 13:53 UTC (permalink / raw)
  To: 9fans

:  A/The main weird thing is that after doing threadint on a thread
:  (created with proccreate) which presumably is hanging in a read
:  sometimes(?) the process just disappears without leaving a trace,
:  even though it is packed with syslog calls
:  (of which only the first part gets executed).

Did you call threadnotify()? Put a print there (the handler)
to see what's going on.

Also, forwarding advice Russ gave time before :-), read the alef paper
and don't use interrupts at all.

BTW, if you are debugging, use threadsetname() and then use ps -a.

Let me know if I can help somehow.



^ permalink raw reply	[flat|nested] 16+ messages in thread
* [9fans] thread confusion
@ 2005-09-21 13:25 Axel Belinfante
  0 siblings, 0 replies; 16+ messages in thread
From: Axel Belinfante @ 2005-09-21 13:25 UTC (permalink / raw)
  To: 9fans

I've been wrestling with the thread library trying
to do resource management in my 802.1x thingy.

This has proven to be harder than I envisioned -
I guess I've been spending more time trying to get this right
(I want this right since it may run as a daemon for a long time,
 doing a new tls handshake every 20 minutes or even more often)
than I think I've spent on the protocol/state machine part :-(

One reason may be that I'm still not very experienced with thread(2).
Another may be that weird things are happening.


A/The main weird thing is that after doing threadint on a thread
(created with proccreate) which presumably is hanging in a read
sometimes(?) the process just disappears without leaving a trace,
even though it is packed with syslog calls
(of which only the first part gets executed).

Actually, it does leave a trace, because when invoking
acid on the main process and doing threads() or stacks()
acid complains that setproc cannot read /proc/XXX/mem
where XXX presumably was the pid of the disappeared process.
(this seems to suggest that also the thread administration
 was not aware of the thread/process dying?)

This is hard to track since I'm not really able to reproduce it,
though I may be able to detect it when it happened.

Any ideas of what might be going on here, or how to debug this?


Another weird thing (bug?) is that threapid always returns -1
(I started looking a bit into this, but maybe someone in the know
 sees the problem immediately)


(furthermore thread(2) and thread.h seem to be inconsistent
 regarding return values of (e.g.) threadint*, threadkill*
 but this is not hard to fix; I could/can submit a patch)

Axel.



^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2005-09-27 10:12 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-09-21 15:48 [9fans] thread confusion Fco. J. Ballesteros
  -- strict thread matches above, loose matches on Subject: below --
2005-09-21 14:44 Fco. J. Ballesteros
2005-09-21 15:05 ` Axel Belinfante
2005-09-21 15:42   ` Russ Cox
2005-09-21 20:25     ` Axel Belinfante
2005-09-21 20:32       ` Axel Belinfante
2005-09-21 20:37       ` Russ Cox
2005-09-21 22:34         ` Axel Belinfante
2005-09-21 22:44           ` Russ Cox
2005-09-26 18:40       ` rog
2005-09-26 18:52         ` Russ Cox
2005-09-26 19:20           ` rog
2005-09-27 10:12         ` Axel Belinfante
2005-09-21 13:53 Fco. J. Ballesteros
2005-09-21 14:32 ` Axel Belinfante
2005-09-21 13:25 Axel Belinfante

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).