亚洲免费在线-亚洲免费在线播放-亚洲免费在线观看-亚洲免费在线观看视频-亚洲免费在线看-亚洲免费在线视频

Linux 內核--任務0的運行(切換到用戶模式)mov

系統 2077 0

本文分析基于Linux 0.11內核,轉載請標明出處, http://blog.csdn.net/yming0221/archive/2011/06/01/6459119.aspx

在main.c的程序中,當設備初始化完畢后,程序將從內核模式切換到用戶模式,也就是所說的任務0,執行fork()函數(該函數使用內嵌的匯

編,防止函數調用弄亂堆棧,造成寫時復制COPY_ON_WRITE)切換到用戶堆棧并執行任務0使用iret指令,首先將有關的值壓入堆棧,然后執

行iret指令。將剛剛壓入對堆棧的數據根據標志位彈入相應的寄存器。

執行iret前的堆棧如下:

Linux 內核--任務0的運行(切換到用戶模式)move_to_user_mode

一下這段話引用自 http://faydoc.tripod.com/cpu/iret.htm


In Protected Mode, the action of the IRET instruction depends on the settings of the NT (nested task) and VM flags in the EFLAGS register and the VM flag in the EFLAGS image stored on the current stack. Depending on the setting of these flags, the processor performs the following types of interrupt returns:

  • Return from virtual-8086 mode.
  • Return to virtual-8086 mode.
  • Intra-privilege level return.
  • Inter-privilege level return.
  • Return from nested task (task switch).

If the NT flag (EFLAGS register) is cleared, the IRET instruction performs a far return from the interrupt procedure, without a task switch. The code segment being returned to must be equally or less privileged than the interrupt handler routine (as indicated by the RPL field of the code segment selector popped from the stack). As with a real-address mode interrupt return, the IRET instruction pops the return instruction pointer, return code segment selector, and EFLAGS image from the stack to the EIP, CS, and EFLAGS registers, respectively, and then resumes execution of the interrupted program or procedure. If the return is to another privilege level, the IRET instruction also pops the stack pointer and SS from the stack, before resuming program execution. If the return is to virtual-8086 mode, the processor also pops the data segment registers from the stack.

-----------------------------------

由于在sched_init()中已經設置了標志寄存器中的vm標志為0,所以iret掉用后不會發生任務切換,而是繼續執行EIP指向的指令故繼續執行

1標號的代碼,開始執行任務0,任務0的堆棧段選擇符為0x17,在sched_init()中已設置了任務0 的任務描述符和局部描述符為INIT_TASK

Linux 內核--任務0的運行(切換到用戶模式)move_to_user_mode


更多文章、技術交流、商務合作、聯系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯系: 360901061

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦?。。?/p>

發表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 五月婷婷在线视频观看 | 久久成人免费大片 | 国产精品亚洲欧美日韩久久 | 亚洲va高清中文字幕 | 欧美高清69hd | 国产亚洲欧美久久精品 | 一级女人18毛片免费 | 久久久噜噜噜久久网 | 免费一级毛片在线视频观看 | 美日韩黄色大片 | 欧美日韩国产成人综合在线影院 | 中国一级一级全黄 | 久久久青青 | 国产精品久久久久久久久久久威 | 亚洲一区在线免费观看 | 91久久国产成人免费观看资源 | 毛片网站在线观看 | 99热久久这里只精品国产9 | 九九热在线视频观看这里只有精品 | 思99re久久这里只有精品首页 | 99热在线获取最新地址 | 国产成人在线观看免费网站 | 天天干天天摸 | 97在线公开视频 | 国产成人精品曰本亚洲77美色 | 国产精品午夜性视频 | 四虎国产精品永久一区 | 国产免费看 | 青娱乐国产在线视频 | 精品a视频 | 人人爽天天碰天天躁夜夜躁 | 国产欧美专区在线观看 | 鲁一鲁中文字幕久久 | 国产三级日产三级日本三级 | 色狠狠成人综合色 | 天天干天天拍天天操 | 日韩免费精品一级毛片 | 这里只有久久精品视频 | 成人免费视频一区二区三区 | 5x性区m免费毛片视频看看 | 一区二区中文字幕在线观看 |