[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
kern/40516: subr_pcq.c has a couple of problems
>Synopsis: subr_pcq.c has a couple of problems
>Arrival-Date: Thu Jan 29 22:30:00 +0000 2009
>Originator: Andrew Doran
>Release: 5.99 current
The NetBSD Project
1. The memory barriers aren't correct. In particular, the use of
membar_consumer() is excessive.
2. There is a race condition where pcq_put() can fail to put items to
the queue even if it is not full. This can occur if the queue wraps
around quickly. This is likely to happen with odd timing conditions
resulting from preemption/interrupts/hyperthreading. While it's
understood that pcq_put() should fail if the queue is full, failing
because of a race is not desirable.
This needs to be fixed before ad-audiomp2 goes in, because it uses pcq
to hand down MIDI messages from multiple sources to the sequencer.
Here is a proof of concept that uses a single 32-bit word to synchronize.
I have tested this on a dual core Pentium-D and it seems to work. It has
a new limitation: these pcqs may not contain more than 65536 entries.
Since that would require 256kB of wired memory it doesn't seem like a
big problem to me.
Note this is a user program but it should be easy to translate to
Main Index |
Thread Index |