进程调度API之yield
来源:互联网 发布:淘宝千人千面原理 编辑:程序博客网 时间:2024/06/16 21:36
void __sched yield(void) 用于让当前进程释放其占用的cpu资源,以便让其他进程有机会执行.但是kernel 并不推荐直接调用这个函数其使用的例子如下:static u16 hfa384x_allocate_fid(struct net_device *dev, int len){u16 fid;unsigned long delay;delay = jiffies + HFA384X_ALLOC_COMPL_TIMEOUT;while (!(HFA384X_INW(HFA384X_EVSTAT_OFF) & HFA384X_EV_ALLOC) && time_before(jiffies, delay))yield();}其源码分析如下:可见这个函数主要做了两件事情void __sched yield(void){#虽然让出cpu了,但是当前task的状态还是设置为TASK_RUNNINGset_current_state(TASK_RUNNING);#调用系统调用来让出cpu,其实在这个系统调用中是直接调用schedule 函数sys_sched_yield();}SYSCALL_DEFINE0(sched_yield){struct rq_flags rf;struct rq *rq;local_irq_disable();rq = this_rq();rq_lock(rq, &rf);schedstat_inc(rq->yld_count);current->sched_class->yield_task(rq);/* * Since we are going to call schedule() anyway, there's * no need to preempt or enable interrupts: */preempt_disable();rq_unlock(rq, &rf);sched_preempt_enable_no_resched();#这个系统调用的核心就是调用schedule来让出cpuschedule();return 0;}
阅读全文
0 0
- 进程调度API之yield
- 进程调度API之__wake_up
- 进程调度API之__wake_up_sync
- 进程调度API之preempt_count_dec_and_test
- 进程调度API之should_resched
- 进程调度API之preempt_schedule
- 进程调度API之add_wait_queue_exclusive
- 进程调度API之autoremove_wake_function
- 进程调度API之complete
- 进程调度API之complete_all
- 进程调度API之completion_done
- 进程调度API之wait_for_completion_x
- 进程调度API之finish_wait
- 进程调度API之init_waitqueue_entry
- 进程调度API之init_waitqueue_head
- 进程调度API之prepare_to_wait
- 进程调度API之set_cpus_allowed_ptr
- 进程调度API之set_user_nice
- 超级公牛冠军赛(Superbull)解析+代码
- 用python爬虫爬取去哪儿4500个热门景点,看看国庆不能去哪儿
- 前文提要
- linux下部署apache软件
- 修改Realm中授权方法查询登录人的权限
- 进程调度API之yield
- 11. Container With Most Water
- 10. find
- 3.7if
- 小Z的袜子 bzoj2038 莫队
- 外教活动总结
- 深入理解函数的调用--栈帧
- 揭秘深度学习成功的数学原因:从全局最优性到学习表征不变性
- 外围信息搜集