Answer : Answer David Schwartz 's question

Answer : Answer David Schwartz 's question

Post by zhoux » Wed, 06 Apr 2005 16:14:44


Oh,that is to say when in the middle of 'malloc', if stopped it,the
thread may not allocate the memory.

Or is there anything else? Please give me more infomation in detail.
Thank you very much, I am a newbie of NPTL:-)
 
 
 

Answer : Answer David Schwartz 's question

Post by David Schw » Wed, 06 Apr 2005 17:31:39


There are two possible cases:

1) You don't have the cooperation of the other thread, the thread might
be doing anything at all, and you can't do anything safely while you've
stopped it.

2) You do have the cooperation of the other thread and you have control
over what the other thread is doing. In this case, you can do anything
safely. However, if you had the cooperation of the the other thread, it's
unlikely you would have asked how to stop it, since it would be obvious, you
code the other thread to call 'usleep' or 'pthread_cond_wait' or whatever.

The textbook answer to the question "how do I stop all other thread" is:
There is probably a better way to do whatever it is you're trying to do. But
the answer is that without the other thread's cooperation, it is impossible
to do safely. With their cooperation, any method you like will work just
fine. (For example, you can use condition variables and mutexes to
coordinate the other threads blocking at a safe point until released.)

DS

 
 
 

Answer : Answer David Schwartz 's question

Post by Joe Seig » Wed, 06 Apr 2005 19:57:16


The question is why do you think signals are in any way useful?


--
Joe Seigh