Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1425135
| From | Peter Zijlstra <peterz@infradead.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: initialize a mutex into locked state? |
| Date | 2016-06-17 16:20 +0200 |
| Message-ID | <rL2MT-7BC-31@gated-at.bofh.it> (permalink) |
| References | <rKnJE-62T-11@gated-at.bofh.it> <rKXk5-46B-5@gated-at.bofh.it> <rL2MN-7BC-1@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On Fri, Jun 17, 2016 at 10:14:10AM -0400, Oleg Drokin wrote: > > On Jun 17, 2016, at 4:25 AM, Peter Zijlstra wrote: > > > On Wed, Jun 15, 2016 at 02:23:35PM -0400, Oleg Drokin wrote: > >> Hello! > >> > >> To my surprise I found out that it's not possible to initialise a mutex into > >> a locked state. > >> I discussed it with Arjan and apparently there's no fundamental reason > >> not to allow this. > > > > There is. A mutex _must_ have an owner. If you can initialize it in > > locked state, you could do so statically, ie. outside of the context of > > a task. > > What's wrong with disallowing only static initializers, but allowing dynamic ones? > Then there is a clear owner. At which point, what wrong with the simple: mutex_init(&m); mutex_lock(&m); Sequence? Its obvious, has clear semantics and doesn't extend the API.
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
initialize a mutex into locked state? Oleg Drokin <green@linuxhacker.ru> - 2016-06-15 20:30 +0200
Re: initialize a mutex into locked state? Peter Zijlstra <peterz@infradead.org> - 2016-06-17 10:30 +0200
Re: initialize a mutex into locked state? Oleg Drokin <green@linuxhacker.ru> - 2016-06-17 16:20 +0200
Re: initialize a mutex into locked state? Peter Zijlstra <peterz@infradead.org> - 2016-06-17 16:20 +0200
Re: initialize a mutex into locked state? Oleg Drokin <green@linuxhacker.ru> - 2016-06-17 16:30 +0200
Re: initialize a mutex into locked state? Peter Zijlstra <peterz@infradead.org> - 2016-06-17 16:40 +0200
Re: initialize a mutex into locked state? Oleg Drokin <green@linuxhacker.ru> - 2016-06-17 16:50 +0200
Re: initialize a mutex into locked state? Jeff Layton <jlayton@poochiereds.net> - 2016-06-17 16:50 +0200
Re: initialize a mutex into locked state? Oleg Drokin <green@linuxhacker.ru> - 2016-06-17 17:00 +0200
Re: initialize a mutex into locked state? Arjan van de Ven <arjan@linux.intel.com> - 2016-06-17 17:00 +0200
Re: initialize a mutex into locked state? Peter Zijlstra <peterz@infradead.org> - 2016-06-17 17:10 +0200
Re: initialize a mutex into locked state? Oleg Drokin <green@linuxhacker.ru> - 2016-06-17 16:50 +0200
csiph-web