📄 buggy-sched.c
字号:
#include "hos.h"struct task_struct * next_p(){ // select next processor return (current->next_run);}#define switch_to(prev, next, last) do { \ asm volatile("movl %%esp, %0\n\t" /*save esp*/ \ "movl %4, %%esp\n\t" /*restore esp*/ \ "movl $1f, %1\n\t" /*save eip*/ \ "pushl %5\n\t" /*restore eip*/ \ "movl %6, %%eax \n\t" \ "movl %%eax, %3\n" \ "1:\t" \ "movl %%ebx, %2\n\t" \ "cli\n\t" \ :"=m"(prev->esp), "=m"(prev->eip), \ "=b"(last), "=m"(init_tss.esp0) \ :"m"(next->esp), "m"(next->eip), \ "m"(next->esp0)); \}while (0)void schedule(void){ unsigned long addr; float x=0.0; int i; if (!current->need_reschedule) return; //get next process and start it struct task_struct *prev, *next; prev=current; current->need_reschedule=0; // reset next=next_p(); current=next; if (next!=prev){ printk("about to switch. current is %x\n",current); for(i=0;i<100000000;i++) x=x+1.0; switch_to(prev,next,prev); asm("ret\n\t"::); /* asm("popl %%eax\n\t" "movl %%eax, %0\n\t" :"=m"(addr):); printk("p1_body is %x, return addr: %x\n", p1_body, addr); for(;;); */ }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -