prepare_arch_schedule 的用途是什么?
我正在摆弄Linux内核2.4,sched.c中的函数schedule()使用宏prepare_arch_schedule,这看起来很奇怪。那是什么?
这是相关部分
#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
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我仍然不明白为什么你认为这是一个无限循环:)。
这是对空语句的“黑客攻击”,它存在的原因是编译器在遇到空语句时会抱怨。
据我了解,上下文切换锁定取决于体系结构,因此,对于尚未定义锁定的体系结构,定义了此空语句,以便您不必为每个体系结构修改 Schedule() 。因此#ifndef...
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...