[prev in list] [next in list] [prev in thread] [next in thread]
List: haiku-commits
Subject: [haiku-commits] Re: haiku: hrev51184 - headers/posix
From: PulkoMandy <pulkomandy () gmail ! com>
Date: 2017-05-29 14:42:55
Message-ID: CAGkucwHi4+fSxw5n6HqPtN6y9xcA2iprAopE3bpbms_j7KzGPw () mail ! gmail ! com
[Download RAW message or body]
How do you detect the "first" call if there are multiple threads? They
could try to get the lock at almost the same time, and then both would
create a semaphore. Oops.
I guess there is a good reason we didn't have this initializer.
2017-05-29 16:39 UTC+02:00, waddlesplash <waddlesplash@gmail.com>:
> On Mon, May 29, 2017 at 8:20 AM, Hamish Morrison <hamishm53@gmail.com>
> wrote:
>> I'm afraid this won't work. pthread_rwlock_init creates semaphores and
>> constructs C++ objects:
>>
>> http://cgit.haiku-os.org/haiku/tree/src/system/libroot/posix/pthread/pthread_rwlock.cpp#n105
>>
>> This static initialiser leaves the semaphore in an unusable state.
>>
>
> Oops. Hmm, looking at other implementations, the thing to do is to
> check if "sem" is null on the first call to pthread_rwlock_*() and
> initialize then. Does that sound correct?
>
> -waddlesplash
>
>
--
Adrien Destugues / PulkoMandy
http://pulkomandy.tk
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic