RE: Darwin-dev Digest, Vol 6, Issue 119
RE: Darwin-dev Digest, Vol 6, Issue 119
- Subject: RE: Darwin-dev Digest, Vol 6, Issue 119
- From: "Karan, Cem (Civ, ARL/CISD)" <email@hidden>
- Date: Wed, 27 May 2009 16:19:07 -0400
- Thread-topic: Darwin-dev Digest, Vol 6, Issue 119
On Wed, 27 May 2009 13:57:50 -0400, Gwynne Raskind wrote:
<<SNIP>>
>
> From the pthread_rwlock_rdlock(3) manpage:
>
> A thread may hold multiple concurrent read locks. If so,
> pthread_rwlock_unlock() must be called once for each lock obtained.
>
> And further:
>
> [EDEADLK] The current thread already owns rwlock for
> writing.
>
> My interpretation of this is that you can hold as many read
> locks as you like, recursively, and that EDEADLK will only
> show up when you try to take a write lock when you already
> have a read lock.
>
> The manpage names itself as being BSD, not Darwin, so I would
> imagine (but not know!) that this is a characteristic of at
> least one of the flavors of BSD that Darwin derives from.
>
> Finally, having a look at the source code for pthread_rwlock_rdlock()
> at:
> http://www.opensource.apple.com/source/Libc/Libc-498.1.7/pthre
> ads/pthread_rwlock.c
>
> I see that EDEADLK will only be returned if the lock is held
> for writing by the current thread.
>
> -- Gwynne, Daughter of the Code
> "This whole world is an asylum for the incurable."
Interesting. My interpretation was that one thread could hold as many
DIFFERENT r/w locks at one time as it wanted (which really confused me,
locks would be quite useless if you COULDN'T do so, but that is what I
got out of "...for each lock obtained")
Reading the code makes it much clearer though; thank you! I did one
other stupid test; I locked for reading and then tried to lock for
writing. I seem to have deadlocked without an error on that one.
Unless that is considered normal behavior, once I confirm that it isn't
a problem with my test code, I'll file a bug about it.
Thanks,
Cem Karan
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden