Date: Mon, 22 Jun 1998 10:30:57 +0200 (CEST) From: Marino Ladavac <lada@pc8811.gud.siemens.at> To: John Birrell <jb@cimlogic.com.au> Cc: smoergrd@oslo.geco-prakla.slb.com, hackers@FreeBSD.ORG, (Dag-Erling Coidan =?iso-8859-1?Q?Sm=F8rgrav?=) <dag-erli@ifi.uio.no> Subject: Re: Signals in POSIX threads Message-ID: <XFMail.980622103057.lada@pc8811.gud.siemens.at> In-Reply-To: <199806202203.IAA24243@cimlogic.com.au>
next in thread | previous in thread | raw e-mail | index | archive | help
On 20-Jun-98 John Birrell wrote: > Dag-Erling Coidan Smørgrav wrote: >> What bothers me is data sharing. Since I don't know which thread will >> run the signal handler, I don't know if it will be necessary to >> protect the data it uses with a mutex or if I can access it safely. I >> don't much like the idea of spin-waiting on a mutex lock inside a >> signal handler, either. >> >> If I set all threads except the main() thread to block a specific >> signal (say, SIGHUP), and install a handler for it, will that ensure >> that it runs in the main() thread or will it just disappear down a >> black hole nine out of ten times? > > The easiest way to handle this (IMO) is to create a pipe and have the > signal handler just write a character to the pipe for each non-nasty > signal that it receives. Then have a thread do a blocking read on the pipe. > This way you do next to nothing in the signal handler and the thread > that reads the pipe can block on whatever mutexes it needs to get access > to the data structures. It can then signal condition variables for any > other threads that need to deal with th changed data. > You can also safely sigwait() for SIGHUP. Take a look at the sigwait(2) manpage. And make certain you are the only one sigwaiting for it :) /Marino >> -- >> One two, one two, one two. >> >> ¹ I'm working on real-time visualization of hydrophone data onboard >> seismological exploration vessels. > > That brings back memories. I use to work for Schlumberger as a wireline > engineer. 8-) > > -- > John Birrell - jb@cimlogic.com.au; jb@freebsd.org http://www.cimlogic.com.au/ > CIMlogic Pty Ltd, GPO Box 117A, Melbourne Vic 3001, Australia +61 418 353 137 > > To Unsubscribe: send mail to majordomo@FreeBSD.org > with "unsubscribe freebsd-hackers" in the body of the message ---------------------------------- Marino Ladavac Date: 22-Jun-98 Time: 10:27:23 ---------------------------------- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?XFMail.980622103057.lada>