Re: [AD] option to allow SSE instructions |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
- To: Coordination of admins/developers of the game programming library Allegro <alleg-developers@xxxxxxxxxx>
- Subject: Re: [AD] option to allow SSE instructions
- From: AJ <aj@xxxxxxxxxx>
- Date: Tue, 17 Mar 2009 01:11:04 +1100
Peter Wang wrote:
On 2009-03-16, AJ <aj@xxxxxxxxxx> wrote:
Does this mean we can use InterlockedXX()s also ?
They'd make things like the threading easier to manage, and reduce that
hideous critical section locking (all for a read/write to bool ... talk
about overhead!!!)
Which critical section are you thinking of?
_al_thread_should_stop
in
/4.9/include/allegro5/platform/aintwthr.h
I presume this function gets called in a while loop, the user waiting
for its state to change.
too tight a loop, and it'll chew cpu.
that is why things like the cpu pause instruction was invented.
You can use InterlockedXX if it makes sense (at least some atomic ops
were already possible on late 486s). Generally I think it's not
worthwhile; it's much harder to get right than using mutexes/critical
sections.
when the only thing your protecting is a single var, the overhead of
critical sections is ..er.. overkill.
when there are multiple vars, critical sections are easier to 'get right'.
however, this code is simply protecting a bool state flag.