[gameprogrammer] Re: Single producer consumer
- From: Kevin Jenkins <gameprogrammer@xxxxxxxxxx>
- To: gameprogrammer@xxxxxxxxxxxxx
- Date: Mon, 13 Feb 2006 08:46:00 -0800
In other words, I was wrong. You need an atomic read/write to make this
work.
I have used this in production code, but the counters were 1 byte values
(68000 assembly code) and I am pretty sure that 1 byte read/writes are
atomic on all systems I have every seen. And, 1 byte counters can make a
very nice queue that is big enough for most applications.
My apologies to the group for posting false information,
I think that writes and reads are atomic on single processor systems. I
updated my single producer consumer to work even for non-atomic reads
and writes.
http://www.rakkar.org/sourcecode/SingleProducerConsumer.h.txt
As I said in the last email, it writes a volatile bool before updating
the read or write pointer. The read or write will fail if either
respective value is incorrect, or either value correctly indicates that
it should fail. Since the pointer and bool writes are atomic, they
happen in-order, and thus the code should work.
---------------------
To unsubscribe go to http://gameprogrammer.com/mailinglist.html
- Follow-Ups:
- [gameprogrammer] Re: Single producer consumer
- From: David Olofson
- References:
- [gameprogrammer] How to have hills in a tiled game
- From: Alan Wolfe
- [gameprogrammer] Single producer consumer
- From: Kevin Jenkins
- [gameprogrammer] Re: Single producer consumer
- From: Bob Pendleton
- [gameprogrammer] Re: Single producer consumer
- From: Kevin Jenkins
- [gameprogrammer] Re: Single producer consumer
- From: Bob Pendleton
Other related posts:
- » [gameprogrammer] Single producer consumer
- » [gameprogrammer] Re: Single producer consumer
- » [gameprogrammer] Re: Single producer consumer
- » [gameprogrammer] Re: Single producer consumer
- » [gameprogrammer] Re: Single producer consumer
- » [gameprogrammer] Re: Single producer consumer
- » [gameprogrammer] Re: Single producer consumer
- » [gameprogrammer] Re: Single producer consumer
- » [gameprogrammer] Re: Single producer consumer
- » [gameprogrammer] Re: Single producer consumer
- » [gameprogrammer] Re: Single producer consumer
work.
I have used this in production code, but the counters were 1 byte values
(68000 assembly code) and I am pretty sure that 1 byte read/writes are
atomic on all systems I have every seen. And, 1 byte counters can make a
very nice queue that is big enough for most applications.
My apologies to the group for posting false information,
--------------------- To unsubscribe go to http://gameprogrammer.com/mailinglist.html
- [gameprogrammer] Re: Single producer consumer
- From: David Olofson
- [gameprogrammer] How to have hills in a tiled game
- From: Alan Wolfe
- [gameprogrammer] Single producer consumer
- From: Kevin Jenkins
- [gameprogrammer] Re: Single producer consumer
- From: Bob Pendleton
- [gameprogrammer] Re: Single producer consumer
- From: Kevin Jenkins
- [gameprogrammer] Re: Single producer consumer
- From: Bob Pendleton