From owner-freebsd-hackers Mon Jun 22 01:32:16 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id BAA18728 for freebsd-hackers-outgoing; Mon, 22 Jun 1998 01:32:16 -0700 (PDT) (envelope-from owner-freebsd-hackers@FreeBSD.ORG) Received: from zwei (zwei.siemens.at [193.81.246.12]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id BAA18662 for ; Mon, 22 Jun 1998 01:31:48 -0700 (PDT) (envelope-from lada@pc8811.gud.siemens.at) Received: from pc8811.gud.siemens.at (root@[10.1.140.1]) by zwei with ESMTP id KAA18248; Mon, 22 Jun 1998 10:30:32 +0200 (MET DST) Received: from pc8811.gud.siemens.at (pc8811.gud.siemens.at [195.3.22.159]) by pc8811.gud.siemens.at (8.8.8/8.8.8) with ESMTP id KAA11956; Mon, 22 Jun 1998 10:30:58 +0200 (CEST) (envelope-from lada@pc8811.gud.siemens.at) Message-ID: X-Mailer: XFMail 1.2 [p0] on FreeBSD X-Priority: 3 (Normal) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 8bit MIME-Version: 1.0 In-Reply-To: <199806202203.IAA24243@cimlogic.com.au> Date: Mon, 22 Jun 1998 10:30:57 +0200 (CEST) Organization: Siemens Austria AG From: Marino Ladavac To: John Birrell Subject: Re: Signals in POSIX threads Cc: smoergrd@oslo.geco-prakla.slb.com, hackers@FreeBSD.ORG, (Dag-Erling Coidan =?iso-8859-1?Q?Sm=F8rgrav?=) Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG 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