Skip to content
Snippets Groups Projects
Commit e4e40822 authored by Fache Charles's avatar Fache Charles
Browse files

3.3: wrote nice, passes all tests

parent 6c383c83
No related branches found
No related tags found
No related merge requests found
......@@ -825,5 +825,26 @@ void priodump(void){
// the provided pid is valid, 0 otherwise
int
nice(int pid, int priority) {
for(struct proc* p = proc; p < &proc[NPROC]; p++) {
acquire(&p->lock);
if (p->pid == pid) {
release(&p->lock);
acquire(&prio_lock);
acquire(&p->lock);
remove_from_prio_queue(p);
p->priority = priority;
insert_into_prio_queue(p);
release(&p->lock);
release(&prio_lock);
return 1;
}
release(&p->lock);
}
return 0;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment