On 06/23/2010 04:49 PM, Henry Vermaak wrote: > On 23/06/10 15:26, Michael Schnell wrote: >> >> Other ARMs (including thumb2) uses a loop with result compare. AFAIK >> this does not work reliably. I am not sure it it's really true that ARM > > No, SWP is atomic, so the implementation looks good (at a glance). >
even if that is true there is a problem: // lock ldr r12, .Lfpc_system_lock mov r3, #1 .Lloop: swp r3, r3, [r12] cmp r3, #0 bne .Lloop // do the job - thread 1 comes in and sets fpc_system_lock to 1 - now thread 2 is scheduled and comes in - fpc_system_lock is set so it enters a busy spinning unfortunately we are in a "realtime" system and the priority of thread 2 is set higher than that of thread 1 and thus thread 1 never gets a CPU cycle as thread 2 is busy and thus we have a dead-lock. -Michael _______________________________________________ fpc-devel maillist - [email protected] http://lists.freepascal.org/mailman/listinfo/fpc-devel
