Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.os.linux.misc > #11097
| From | "Charles T. Smith" <cts.private.yahoo@gmail.com> |
|---|---|
| Newsgroups | comp.os.linux.misc |
| Subject | Re: pthread mutex used like a semaphore. Why does it work? |
| Date | 2014-05-19 08:27 +0000 |
| Organization | A noiseless patient Spider |
| Message-ID | <llcf8v$2ob$2@dont-email.me> (permalink) |
| References | <llavfa$tsr$1@dont-email.me> <wwviop25grr.fsf@l1AntVDjLrnP7Td3DQJ8ynzIq3lJMueXf87AxnpFoA.invalid> |
On Mon, 19 May 2014 09:12:08 +0100, Richard Kettlewell wrote: > "Charles T. Smith" <cts.private.yahoo@gmail.com> writes: >> I'm looking at a piece of code where one thread locks a mutex at >> regular intervals and a different thread frees that lock. I thought it >> was an error for a different thread to free a mutex, but it seems to be >> working and there's no error code. >> >> I see the following at http://pubs.opengroup.org/onlinepubs/9699919799/ >> functions/pthread_mutex_lock.html: >> >> The pthread_mutex_unlock() function shall fail if: >> >> [EPERM] >> The mutex type is PTHREAD_MUTEX_ERRORCHECK or >> PTHREAD_MUTEX_RECURSIVE, >> or the mutex is a robust mutex, and the current thread does not own the >> mutex. >> >> >> How does a PTHREAD_MUTEX_DEFAULT mutex react if a non-owning thread >> unlocks it? > > There’s a table at the top of the page which gives the behavior for the > various cases. Yes, you're right. Mutex Type Robustness Relock Unlock When Not Owner NORMAL non-robust deadlock undefined behavior Before I file that as a bug report, I just wanted to be sure that nobody would say that "everybody knows that a mutex unlocked by another thread is obviously a perfectly good semaphore"!
Back to comp.os.linux.misc | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
pthread mutex used like a semaphore. Why does it work? "Charles T. Smith" <cts.private.yahoo@gmail.com> - 2014-05-18 18:51 +0000
Re: pthread mutex used like a semaphore. Why does it work? "Charles T. Smith" <cts.private.yahoo@gmail.com> - 2014-05-18 19:26 +0000
Re: pthread mutex used like a semaphore. Why does it work? Xavier Roche <xroche@free.fr.NOSPAM.invalid> - 2014-05-19 08:32 +0200
Re: pthread mutex used like a semaphore. Why does it work? "Charles T. Smith" <cts.private.yahoo@gmail.com> - 2014-05-19 08:16 +0000
Re: pthread mutex used like a semaphore. Why does it work? Richard Kettlewell <rjk@greenend.org.uk> - 2014-05-19 09:12 +0100
Re: pthread mutex used like a semaphore. Why does it work? "Charles T. Smith" <cts.private.yahoo@gmail.com> - 2014-05-19 08:27 +0000
Re: pthread mutex used like a semaphore. Why does it work? Mark <i@dontgetlotsofspamanymore.invalid> - 2014-05-19 10:50 +0100
Re: pthread mutex used like a semaphore. Why does it work? Chick Tower <c.tower@deadspam.com> - 2014-05-19 19:16 +0000
Re: pthread mutex used like a semaphore. Why does it work? "Charles T. Smith" <cts.private.yahoo@gmail.com> - 2014-05-20 10:24 +0000
Re: pthread mutex used like a semaphore. Why does it work? David Brown <david.brown@hesbynett.no> - 2014-05-20 21:27 +0200
Re: pthread mutex used like a semaphore. Why does it work? Chick Tower <c.tower@deadspam.com> - 2014-05-21 02:22 +0000
Re: pthread mutex used like a semaphore. Why does it work? Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2014-05-20 22:33 -0400
Re: pthread mutex used like a semaphore. Why does it work? James Moe <jimoeDESPAM@sohnen-moe.com> - 2014-05-20 11:13 -0700
Re: pthread mutex used like a semaphore. Why does it work? "Charles T. Smith" <cts.private.yahoo@gmail.com> - 2014-05-20 19:39 +0000
Re: pthread mutex used like a semaphore. Why does it work? Mark <i@dontgetlotsofspamanymore.invalid> - 2014-05-22 08:59 +0100
csiph-web