Process - Busy waiting

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
extremecoder
Member
Member
Posts: 59
Joined: Tue May 23, 2006 11:00 pm

Process - Busy waiting

Post by extremecoder »

Is there a way to implement Busy waiting and Spin locks (mutual exclusion), without using while and for loops ?
rexlunae
Member
Member
Posts: 134
Joined: Sun Oct 24, 2004 11:00 pm
Location: North Dakota, where the buffalo roam

Re: Process - Busy waiting

Post 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.
Da_Maestro
Member
Member
Posts: 144
Joined: Tue Oct 26, 2004 11:00 pm
Location: Australia

Post 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....
Post Reply