谁能告诉我linux内核中schedule()函数的用法
谁能告诉我linux内核中schedule()函数的用法。
谁来调度这个调度程序线程?
提前致谢
Can anyone please let me know the usage of schedule() function in linux kernel.
Who will schedule this scheduler thread.?
Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
有两种机制可用:自愿机制或基于硬件的机制。
http://lwn.net/Articles/95334/
由于最近的补丁,自愿抢占已引入内核:
http://kerneltrap.org/node/3440
这意味着CPU将明确放弃当前作业并让调度程序接管以选择活动任务列表上的下一个任务。人们发现,这种自愿抢占方式比非自愿抢占(基于计时器时钟)提高了性能
更多信息:
http ://wiki.osdev.org/Context_Switching(软件与硬件上下文切换 - 类似于我们在这里讨论的内容)
http://wiki.osdev.org/Scheduling_Algorithms
Two mechanism are available: voluntary or hardware-based.
http://lwn.net/Articles/95334/
Arising from a recent patch, voluntary preemption has been introduced into the kernel:
http://kerneltrap.org/node/3440
This means the CPU will explicitly surrender the current job and let the scheduler take over to select the next tasks on the active tasks list. It has been found that this way of voluntary preemption improved performance over involuntary preemption (which is timer clock-based)
More info:
http://wiki.osdev.org/Context_Switching (software vs hardware context switching - similar to what we are talking here)
http://wiki.osdev.org/Scheduling_Algorithms
Linux 内核中没有调度程序线程。在某些特定情况下会调用schedule() 函数。例如:
1)当进程或内核线程在内核模式下显式调用它时。如果进程需要等待某个事件发生,通常会调用schedule()函数;就像来自输入输出设备的数据的可用性一样。
2) 当优先级高于当前进程的进程正在等待某个事件并且该事件发生时。
3)当分配给当前进程的时间片到期时。
There is no scheduler thread in the Linux kernel. There are specific situations in which the schedule() function is called. For example:
1) When a process or kernel thread explicitly calls it in kernel mode. A process generally calls schedule() function if it needs to wait for some event to occur; like availability of data from an input-output device.
2) When a process of priority higher than the current process was waiting for some event and the event occurs.
3) When the time slice allocated to the current process expires.