Linux???????????????
???????????? ???????[ 2014/9/12 10:48:56 ] ?????????????? Linux
????1??Linux????????????
??????Linux?У??????CPU?????????????????????????????????ж????У???????????? ????λ?TASK_RUNNING?????????????е???????????? Linux ??????????????????????CPU????????????????ж?????????????????????????С?
????????????????????????????CPU???????????? schedule()???????????????????????????????????????????????????????CPU????????????????CPU?????????μ?????? CPU??????????????????е?λ??????У??????????????schedule()??????д????????С?
????????????????????????????????????????????豸???????ɡ?I/O ???????????????????????????£??????????????ж???????????????????????У??????????????????????
????Linux ?е????????????????
???????????ж????????????????λTASK_INTERRUPTIBLE??
???????????????ж????????????????λ?TASK_UNINTERRUPTIBLE?????ж??????????????????????????????棬????????????????ж????? ???????????????????????????????????????????????????????ж??????????ж????????????????????????????????????????????? ????????????????????????????????????????????ж??????????????????????Щ???????????????????????????????????????? ??????????ж??????????????????????
???????????Linux???????У???????????????schedule()??????????????????????????????????????????е??????????????
????sleeping_task = current;
????set_current_state(TASK_INTERRUPTIBLE);
????schedule();
????func1();
????/* Rest of the code ... */
??????????????У?????洢????????????sleeping_task??current ??????????????????е???????set_current_state()???y?????????????TASK_RUNNING ????????TASK_INTERRUPTIBLE?? ???schedule()?????????TASK_RUNNING ????????????schedule()????????????????????CPU?????schedule()?????????TASK_INTERRUPTIBLE ??TASK_UNINTERRUPTIBLE ??????????????????????????軔????У??????е???????????????????????????????ж???????????????????????е??????????????????????????????ж????????
?????????????????????????????????????????????????
????wake_up_process(sleeping_task);
???????????wake_up_process()??????????????????????TASK_RUNNING???????????????????????ж??????????????????????????′α????????????????????????????????С?
????2????Ч????
?????????????е?????£???????????????Щ??????????????????????????????????е???????????? ?ж???????????????????????????????????????????????????ν????Ч????????????????У??????????????????????????????????? ??????????????????е??????????????????????????????????????????????Ч??????????????????????μ??
??????????????????A ??B??A ??????????????????????????????????????????????????????????????????Щ????????B????????????????????????????????????????????????????????A?????????????B??????????????????????????????A ?????????????£?
????A????:
1 spin_lock(&list_lock);
2 if(list_empty(&list_head)) {
3 spin_unlock(&list_lock);
4 set_current_state(TASK_INTERRUPTIBLE);
5 schedule();
6 spin_lock(&list_lock);
7 }
8
9 /* Rest of the code ... */
10 spin_unlock(&list_lock);
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11