commit 55b189e00e58679678b71b641d93b7c47d518c68
parent b84d3c24b90fd23b9aa8808ec9ec66995bac2301
Author: Roberto E. Vargas Caballero <roberto.vargas@midokura.com>
Date: Fri, 18 Nov 2022 15:13:36 +0100
os9: Remove global lock procm
This lock is not needed because it can be reduced to a lock
for the scheduler.
Diffstat:
1 file changed, 4 insertions(+), 8 deletions(-)
diff --git a/src/os9/proc.c b/src/os9/proc.c
@@ -6,7 +6,6 @@
#include <libk.h>
static Task tasktab[NR_TASKS];
-static mutex_t procm;
static struct {
Nspace *list;
@@ -96,7 +95,6 @@ gettask(int pid)
Task *tp, *p;
tp = NULL;
- lock(&procm);
for (p = tasktab; p < &tasktab[NR_TASKS]; ++p) {
locktask(p);
if (p->pid == pid && p->state != TFREE) {
@@ -105,7 +103,6 @@ gettask(int pid)
}
unlocktask(p);
}
- unlock(&procm);
return tp;
}
@@ -194,14 +191,12 @@ newslot(void)
{
Task *tp;
- lock(&procm);
for (tp = tasktab; tp < &tasktab[NR_TASKS]; tp++) {
locktask(tp);
if (tp->state == TFREE)
break;
unlocktask(tp);
}
- unlock(&procm);
if (tp == &tasktab[NR_TASKS]) {
errno = ENOMEM;
@@ -522,6 +517,7 @@ sched(void)
Task *new, *tp;
int prio;
long long wait, mask;
+ static mutex_t m;
if (proc->state == TRUNNING) {
if (proc->flags&TLOCK_PREEMP)
@@ -536,7 +532,7 @@ repeat:
wait = -1;
mask = 1ul << cpuid;
- lock(&procm);
+ lock(&m);
for (tp = tasktab; tp < &tasktab[NR_TASKS]; ++tp) {
lock(&tp->m);
@@ -553,7 +549,7 @@ repeat:
}
if (!new) {
- unlock(&procm);
+ unlock(&m);
idle();
goto repeat;
}
@@ -561,7 +557,7 @@ repeat:
proc = new;
lock(&proc->m);
proc->state = TRUNNING;
- unlock(&procm);
+ unlock(&m);
swtch(&proc->ctx);
}