Page 1 of 1

Process - Busy waiting

Posted: Fri Jun 16, 2006 1:13 am
by extremecoder
Is there a way to implement Busy waiting and Spin locks (mutual exclusion), without using while and for loops ?

Re: Process - Busy waiting

Posted: Fri Jun 16, 2006 3:30 pm
by rexlunae
extremecoder wrote:Is there a way to implement Busy waiting and Spin locks (mutual exclusion), without using while and for loops ?
Well, by definition a spinlock just loops until something changes, so I don't really see the difference between using a real C loop and anything else, but if you're really into making code that looks weird, you could use if()...goto. If your point is that you want the processor to be doing something useful while waiting for the lock to be available, you want a different type of lock.

Posted: Sun Jun 18, 2006 8:01 pm
by Da_Maestro
Isn't the idea of using a spin lock being that it is just a while loop anyway?

Trying to do any sort of loop any way other than using one of the looping constructs just seems silly....