From owner-freebsd-threads@FreeBSD.ORG Tue Mar 31 04:47:11 2009 Return-Path: Delivered-To: threads@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id AA8F0106564A; Tue, 31 Mar 2009 04:47:11 +0000 (UTC) (envelope-from rrs@lakerest.net) Received: from lakerest.net (unknown [IPv6:2001:240:585:2:203:6dff:fe1a:4ddc]) by mx1.freebsd.org (Postfix) with ESMTP id 456538FC12; Tue, 31 Mar 2009 04:47:11 +0000 (UTC) (envelope-from rrs@lakerest.net) Received: from [10.1.1.53] ([10.1.1.53]) (authenticated bits=0) by lakerest.net (8.14.3/8.14.3) with ESMTP id n2V4lDr2066515 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NOT); Tue, 31 Mar 2009 00:47:13 -0400 (EDT) (envelope-from rrs@lakerest.net) Message-Id: <59795ADA-892B-4FAF-8506-82007D317C12@lakerest.net> From: Randall Stewart To: Alfred Perlstein In-Reply-To: <20090331043245.GZ92757@elvis.mu.org> Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Apple Message framework v930.3) Date: Tue, 31 Mar 2009 00:47:05 -0400 References: <7D4F6788-0F12-4863-9635-7FADA9115D16@lakerest.net> <49D136B1.6060809@delphij.net> <78DBBDDA-5A39-4CEB-8289-F36EFB96461D@lakerest.net> <20090331043245.GZ92757@elvis.mu.org> X-Mailer: Apple Mail (2.930.3) Cc: threads@freebsd.org, d@delphij.net Subject: Re: A mutex for inter-process ;-) X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 31 Mar 2009 04:47:11 -0000 The actual take I took is that both the pid and first tid are recorded. When you start up you validate each pid listed and make sure the main tid matches and the process is alive. Now of course there is a chance that both the tid and pid will wrap.. but both would have to wrap and you would have to have the new pid be assigned the same tid during the wrap. Maybe this would be common.. don't know .. but its a start. Without adding some sort of hook at process death to detect and cleanup the shared memory.. R On Mar 31, 2009, at 12:32 AM, Alfred Perlstein wrote: > One trick to handling pid wrap is to also record process > start time. I sort of wish our signalling code allowed > this as a optional thing to make _really sure_ you weren't > signalling the wrong process. > > -Alfred > > * Randall Stewart [090330 16:29] wrote: >> >> On Mar 30, 2009, at 5:16 PM, Xin LI wrote: >> >>> -----BEGIN PGP SIGNED MESSAGE----- >>> Hash: SHA1 >>> >>> Randall Stewart wrote: >>>> Hi all: >>>> >>>> I have recently written a small set of routines that allow >>>> two process to have a "mutex" between them.. actually it allows >>>> all of the threads in any set of processes to have mutexes between >>>> themselves ;-) >>>> >>>> Anyway it seems to be working fairly well.. I still have to write a >>>> man >>>> page >>>> for it (documentation always last).. and eventually I would like to >>>> port in >>>> some of the WITNESS type features since the mutex's have names.. >>>> >>>> I probably should also think about scaling it up a bit.. right now >>>> its >>>> really >>>> more for a small scale (100 or less mutexes)... >>>> >>>> Who should I talk to about getting this in... having it reviewed >>>> etc. I >>>> think >>>> it belongs in libthr since it really needs the tid of the pthreads >>>> from the >>>> pthread_t type... and for now I have a horrible hack in to get >>>> it ;-) >>> >>> I think davidxu@ deischen@ and julian@? >>> >>> BTW. How do you handle with one process exit (abnormally) without >>> releasing the mutex? Just curious :) >> >> I have a couple of ways of dealing with this.. >> >> 1) Of course the initialization routine calls atexit() to get a >> "cleanup handler" in place. >> 2) Often times, of course, this can fail e.g. you get a SIGSEGV.. or >> some such. When you >> attach the memory, an audit is done. The audit will validate that >> the pid is still alive >> and has the particular tid in it. Of course this is not 100% but >> as long as the tid's have >> not rolled over it should work. The function is also public (need >> to add that and many things >> to the manual pages ;-D) so that one can call it whenever one >> wants :-) >> >> I will ping Julian and the others... >> >> R >> >>> >>> >>> Cheers, >>> - -- >>> Xin LI http://www.delphij.net/ >>> FreeBSD - The Power to Serve! >>> -----BEGIN PGP SIGNATURE----- >>> Version: GnuPG v2.0.11 (FreeBSD) >>> >>> iEYEARECAAYFAknRNrEACgkQi+vbBBjt66DIswCbBWRMJN55c60UTBBIZMRCY4zo >>> 6hcAnixfVXdtdnn0fT/Z31v0EdyVCVlH >>> =JL/U >>> -----END PGP SIGNATURE----- >>> >> >> ------------------------------ >> Randall Stewart >> 803-317-4952 (cell) >> 803-345-0391(direct) >> >> _______________________________________________ >> freebsd-threads@freebsd.org mailing list >> http://lists.freebsd.org/mailman/listinfo/freebsd-threads >> To unsubscribe, send any mail to "freebsd-threads-unsubscribe@freebsd.org >> " > > -- > - Alfred Perlstein > ------------------------------ Randall Stewart 803-317-4952 (cell) 803-345-0391(direct)