[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: lock_kernel
Hi Siva,
> when the macro lock_kernel is defined as
> do{ } while(0)
> and when it comes 'out' immediately('cos the condition is false by
> having specified 0) from the flow of control what is the rational
> behind using it?
I don't know the macro but
while (0) {
/* never executed. */
}
and
do {
/* executed once. */
} while (0);
should make things clearer. That is, you're wrong when you say `it
comes 'out' immediately'. It doesn't, but executes exactly once as a
do...while loop tests the condition at the end of the iteration.
/* a while-loop. */
loop:
if (cond) {
/* body of loop. */
goto loop;
}
/* a do-while-loop. */
loop:
/* body of loop. */
if (cond) {
goto loop;
}
Read K&R2 for more details.
Ralph.
-
Kernelnewbies: Help each other learn about the Linux kernel.
Archive: http://mail.nl.linux.org/
IRC Channel: irc.openprojects.net / #kernelnewbies
Web Page: http://www.kernelnewbies.org/