glibc -- ISO C11 threads Proposal
Kevin Cox
kevincox@kevincox.ca
Mon Mar 31 17:10:00 GMT 2014
On 31/03/14 10:18, Rich Felker wrote:
> On Mon, Mar 31, 2014 at 09:48:29AM -0400, Kevin Cox wrote:
>> On 31/03/14 01:50, Rich Felker wrote:
>>>
>>> I realized there's an alternate solution to the problem for
>>> non-process-shared mutexes: simply keep a count of recursive or
>>> error-checking mutexes the current thread owns in its TLS. If, on
>>> exit, this count is nonzero, don't actually exit but instead leave the
>>> tid permanently tied up until the process exits. (This requires
>>> emulating thread exit for pthread_join to work.)
>>>
>>
>> Instead of hanging the thread could the mutex be put in a "permalocked"
>> state? For example maybe the stored thread id could be replaced will a
>> "null" thread id. This would require reaching into pthread internals
>> (assuming we use pthreads to back C11) but this way you can let the
>> thread die as the user would expect but the mutex would stay locked forever.
>
> That's the solution which requires space to track all locks held in a
> linked list, the "non-alternate" solution.
Ah, yes. I missed that yours was only keeping a count.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 295 bytes
Desc: OpenPGP digital signature
URL: <http://sourceware.org/pipermail/libc-alpha/attachments/20140331/6a3f1ab1/attachment.sig>
More information about the Libc-alpha
mailing list