public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Nonblocking call may block in a mutex? Nonblocking call after poll may fail?
@ 2007-08-31 12:13 anon... anon.al
  2007-08-31 14:25 ` anon... anon.al
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: anon... anon.al @ 2007-08-31 12:13 UTC (permalink / raw)
  To: linux-kernel

Hi!

This is a driver-related question on non-blocking writes and poll.

Setup:
there is a single output-buffer (in kernel-space) of 24 bytes for
writes from all processes A, B, and C: each process is restricted to
use at most 8 bytes: 8*3 = 24
(until that data is handled (interrupt-handler...))

Question:
If this output-buffer has "4-bytes space remaining for process A",
then a non-blocking write of process A could still encounter a locked
mutex, if process B is busy writing to the output-buffer.

Should process A now block/sleep until that mutex is free and it can
access the output-buffer (and it's 4 bytes space)?

What about a non-blocking (write-) poll of process A: if the poll call
succeeds (the output buffer has space remaining for process A), and
process A now performs a non-blocking write: what happens if A
encounters a blocked mutex, since process B is busy writing to the
output-buffer.
a) Should A block until the mutex is available?
b) Should A return -EAGAIN, even though the poll call succeeded?
c) Should it be impossible for this to happen! i.e. -> should process
A already "have" the mutex in question, when the poll call succeeds
(thus preventing B from writing to the output buffer)

For c) What if process A "has" the mutex, but never does the
non-blocking write. Then no process can write, since the mutex is held
by process A...


I'll appreciate any answer, or pointer to relevant information.

Thanks Albert

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2007-08-31 21:34 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-08-31 12:13 Nonblocking call may block in a mutex? Nonblocking call after poll may fail? anon... anon.al
2007-08-31 14:25 ` anon... anon.al
2007-08-31 14:32 ` Denys Vlasenko
2007-08-31 21:33 ` David Schwartz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox