kernel developer improve our code all the time.
When we turn a process to another, it will call function context_switch() in kernel/sched.c file. It can complete two function:
1, it can call switch_mm() function to rearrange virtual address to the new on in the file of include/asm/mmu_context.h.
2, it can also call switch_to() function to turn a processor's state to another including stack information, register information, etc.
So, kernel give us a need_resched logo to see if it is necessary to call schedule(). Kernel can call scheduler_tick() function to set the logo and try_to_wake_up() function also can do this.
Every process can include the need_resched logo to see if it is necessary to. Kernel can visit the logo is faster than global variable so it is good.
Before edition of 2.2 this logo is a global variable. During edition 2.2 to 2.4 is in task_struct. In edition 2.6 is in thread_info structure.
So We can know kernel developer improve our code all the time from need_resched logo.
Reference book:
《Linux Kernel Design and Implementation》 written by Robert Love.
阅读(384) | 评论(0) | 转发(0) |