[英]How to implement a priority scheduler in xv6 ?
在xv6中實現優先級調度算法?
但我無法理解如何處理此調度。 我可以使用此代碼設置優先級。
int
set_priority(int pid,int priority)
{
struct proc *p;
//acquire(&ptable.lock);
//cprintf("Set Priority - %d \n",priority);
for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){
if((p->pid == pid) || (p->parent->pid == pid)){
p->priority = priority;
return 0;
}
}
//release(&ptable.lock);
return -1;
}
首先,您需要在struct proc
添加一個字段(優先級)。
struct proc{
//
....
int priority; // priority of the process
}
第二,你現在可以在proc.c
編寫自己的調度程序。
void scheduler(void){
for(;;){
//add your own priority scheduler here.
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.