Mercurial > hg > Members > shivanidubey > xv6
changeset 7:29025bcad36d
Scheduling By Priority
author | shivanidubey |
---|---|
date | Wed, 19 Jun 2019 17:53:14 +0900 |
parents | cbfb7472821d |
children | 1150b46afde9 |
files | src/proc.c src/syscall.c src/sysproc.c |
diffstat | 3 files changed, 12 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/src/proc.c Wed Jun 19 17:28:28 2019 +0900 +++ b/src/proc.c Wed Jun 19 17:53:14 2019 +0900 @@ -314,8 +314,10 @@ int get_highest_priority_proc(void) { - int highest_priority=ptable.proc->priority; - for(struct proc *p = ptable.proc; p < &ptable.proc[NPROC]; p++){ + int highest_priority; + highest_priority=ptable.proc->priority; + struct proc *p; + for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ if(p->state != RUNNABLE) { continue; } @@ -338,7 +340,6 @@ void scheduler(void) { - struct proc *p; for(;;){ // Enable interrupts on this processor. @@ -352,7 +353,8 @@ // Switch to chosen process. It is the process's job // to release ptable.lock and then reacquire it // before jumping back to us. - struct proc *p =ptable.proc[highest_priority]; + struct proc *p; + p=&ptable.proc[highest_priority]; switchuvm(p); p->state = RUNNING;
--- a/src/syscall.c Wed Jun 19 17:28:28 2019 +0900 +++ b/src/syscall.c Wed Jun 19 17:53:14 2019 +0900 @@ -114,8 +114,8 @@ extern int sys_wait(void); extern int sys_write(void); extern int sys_uptime(void); -extern void sys_setpriority(void); - +extern int sys_setpriority(void); +extern int getpriority(void); static int (*syscalls[])(void) = { [SYS_fork] sys_fork, [SYS_exit] sys_exit,
--- a/src/sysproc.c Wed Jun 19 17:28:28 2019 +0900 +++ b/src/sysproc.c Wed Jun 19 17:53:14 2019 +0900 @@ -94,15 +94,17 @@ return xticks; } -extern setpriority(int); +extern void setpriority(int); -void sys_setpriority(void) +int sys_setpriority(void) { int priority; if(argint(0, &priority) < 0) { return -1; } setpriority(priority); + return 0; } +