[470] in Pthreads mailing list archive
Re: Re-entrant?
daemon@ATHENA.MIT.EDU (Larry V. Streepy, Jr.)
Tue Oct 22 10:29:55 1996
Date: Tue, 22 Oct 1996 08:08:50 -0600
From: "Larry V. Streepy, Jr." <streepy@healthcare.com>
To: "Alex H.K. Wong" <wong@CS.UCLA.EDU>
Cc: pthreads@MIT.EDU
Alex H.K. Wong wrote:
>
> Hi,
> I was wondering if anybody knows a way (or trick) to make
> pthread_mutex_lock re-entrant?
I'm gonna guess that "re-entrant" isn't the exact word you wanted. I'll
further assume that you're asking for a way to have the same thread call
pthread_mutex_lock more then once and not hang itself. If I'm wrong on
these assumptions, ignore this.
Unfortunately, the POSIX 1003.1 standard says this:
"An atempt by the current owner of a mutex to relock the mutex results
in undefined behavior."
Sigh.
However, the current version 1.6 Beta 5 release of pthreads provides a
mutex type MUTEX_TYPE_COUNTING_FAST which allows a single thread to hold
a mutex multiple times. You must ensure that the thread issues an
equivalent number of pthread_mutex_locak and pthread_mutex_unlock calls.
Just remember that if you use it, it's non-standard, and thus
non-portable.
--
Larry V. Streepy, Jr.
Chief Technical Officer, Healthcare Communications, Inc.
mailto:streepy@healthcare.com
(214) 851-7033 (Dallas Main #)
(970) 626-5028 (My office #) (970) 626-4425 (Fax)