3

In pthreads, is it possible for a thread to wake up another thread given only the other thread's id?

(Kind of like, calling pthread_cond_signal() but with also a specific, known, thread id in mind)

ManRow
  • 1,563
  • 4
  • 21
  • 40

2 Answers2

4

You may try using sigaction() and pthread_kill().

sam hocevar
  • 11,853
  • 5
  • 49
  • 68
  • Beat me by 33 seconds though ;) once I get some more votes, I'll visit again. :) (It's a good thing there is a daily vote limit though, otherwise I might never go to bed. :) – sarnold Mar 12 '11 at 11:48
3

See the discussion between @Sam Hocevar and myself in response to this question; the documentation says pthread_kill(3) delivers a signal to a specific thread, and I'm less sure about the Linux implementation sticking true to this requirement.

Community
  • 1
  • 1
sarnold
  • 102,305
  • 22
  • 181
  • 238
  • Correct, sane Linux implementations follow this requirement. Only the legacy LinuxThreads junk (and dietlibc's lite LinuxThreads workalike) have the bogus behavior where threads act like processes. – R.. GitHub STOP HELPING ICE Mar 12 '11 at 13:32