ThoughtWorks Interview Question
ConsultantsThere is no return from the function, neither any change in the value for a and b
Therefore this function is useless.
If bth bit is set it goes in infinite loop else it stops. The function does nothing. It returns nothing. Even value of *a does not get changed.
Maybe is used to check for bth bit and works as a wait loop(based on bth bit) before a mutex...where *a gets changed in some other process.
Looks like a code for a timer to me.
- swap1712 July 25, 2011Function waits until the bth bit of a is zero.
a might be an address of program status word or an i/o device address which keeps changing value. If such is true, a should've been defined as volatile.