Subj : lock on IA-32 To : comp.programming.threads From : Michael Pryhodko Date : Wed Mar 09 2005 04:56 pm Is it possible to implement lock on IA-32 without using LOCK prefix using following considerations: a) there could be arbitrary number of threads trying to grab the lock b) every thread has **unique** number P != 0 (this is main thing behind this whole idea) I was trying to build something like: init: A = 0 B = 0 LOCK: @: if (A == 0) .. A = P .. SFENCE .. if (A == P && B == 0) .. B = P .. SFENCE .. if (A == P && B == P) .. // we've got the lock .. // otherwise goto @: obviosly example above does not work. I spent some time modifying it, but every variant was discarded in time. Could anyone give me an insight? Also (since I do not now much about AMD architecture): is it possible on AMD architecture? Bye. Sincerely yours, Michael. .