Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Armillon Damien
xv6-riscv-tp
Commits
7ead23b3
Commit
7ead23b3
authored
May 07, 2020
by
Wilke Pierre
Browse files
Solution insert_into_prio_queue et remove_from_prio_queue
parent
092a9718
Changes
1
Hide whitespace changes
Inline
Side-by-side
kernel/proc.c
View file @
7ead23b3
...
...
@@ -26,6 +26,49 @@ static void wakeup1(struct proc *chan);
extern
char
trampoline
[];
// trampoline.S
/* Solution insert et remove
// Needs lock on p and prio_lock[p->priority]
void insert_into_prio_queue(struct proc* p){
struct list_proc* new = bd_malloc(sizeof(struct list_proc));
new->next = 0;
new->p = p;
if(!prio[p->priority]){
prio[p->priority] = new;
}
else {
struct list_proc* last = prio[p->priority];
while(last && last->next){
last = last->next;
}
last->next = new;
}
}
// Needs lock on p and prio_lock[p->priority]
void remove_from_prio_queue(struct proc* p){
struct list_proc* old = prio[p->priority];
struct list_proc* prev = 0;
struct list_proc* head = old;
while(old){
if(old->p == p) {
if(old == head){
head = old->next;
} else {
prev->next = old->next;
}
bd_free(old);
break;
}
prev = old;
old = old->next;
}
prio[p->priority] = head;
}
*/
void
procinit
(
void
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment