views:

45

answers:

1

I'm messing around with Linux kernel 2.4 and function schedule() in sched.c uses the macro prepare_arch_schedule, which looks really strange. What is that?

Here's the relevant section

#ifndef prepare_arch_schedule
# define prepare_arch_schedule(prev)    do { } while(0)
# define finish_arch_schedule(prev) do { } while(0)
# define prepare_arch_switch(rq)    do { } while(0)
# define finish_arch_switch(rq)     spin_unlock_irq(&(rq)->lock)
#endif
+1  A: 

I still don't understand why you think it's an infinite loop :) .

It's a "hack" for an empty statement and the reason it's there is because the compiler can complain when it hits an empty statement.

From what I understand, context switch locking is architecture dependent and so, for architectures for which the locking hasn't been defined, this empty statement was defined so that you don't have to modify schedule() for each architecture. Hence the #ifndef...

Bandan
Added the relevant code.
EpsilonVector
not really that hard to find... http://git.kernel.org/?p=linux/kernel/git/wtarreau/linux-2.4.git;a=summary
Hasturkun
@hasturkun Just one more favor: go to the link you provided and find the definition of prepare_arch_schedule(). (You won't find it, it's been removed since long! There was a reason why I asked what I asked :))
Bandan
"I still don't understand why you think it's an infinite loop" I remembered it to be while(1)...
EpsilonVector