diff options
author | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2023-08-12 13:30:47 +0200 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2023-08-12 23:29:30 +0200 |
commit | deb2b637605bf0beedb55ed5483f55af09ab41e9 (patch) | |
tree | ebe34978e45ed1c4928eb13a8132c926af304ea8 | |
parent | 5879781c77ac5ed903b3712aef546848681b449d (diff) | |
download | gnumach-deb2b637605bf0beedb55ed5483f55af09ab41e9.tar.gz gnumach-deb2b637605bf0beedb55ed5483f55af09ab41e9.tar.bz2 gnumach-deb2b637605bf0beedb55ed5483f55af09ab41e9.zip |
sched: Add runq_lock helpers which check they are called at spl7
-rw-r--r-- | kern/ast.c | 4 | ||||
-rw-r--r-- | kern/eventcount.c | 4 | ||||
-rw-r--r-- | kern/sched.h | 15 | ||||
-rw-r--r-- | kern/sched_prim.c | 14 |
4 files changed, 26 insertions, 11 deletions
@@ -203,7 +203,7 @@ ast_check(void) /* * Need to recheck and possibly update hint. */ - simple_lock(&rq->lock); + runq_lock(rq); q = rq->runq + rq->low; if (rq->count > 0) { for (i = rq->low; i < NRQS; i++) { @@ -213,7 +213,7 @@ ast_check(void) } rq->low = i; } - simple_unlock(&rq->lock); + runq_unlock(rq); } if (rq->low <= thread->sched_pri) { diff --git a/kern/eventcount.c b/kern/eventcount.c index 3a96b4fb..4dda5186 100644 --- a/kern/eventcount.c +++ b/kern/eventcount.c @@ -339,7 +339,7 @@ simpler_thread_setrun( ast_on(cpu_number(), AST_BLOCK); whichq = (th)->sched_pri; - simple_lock(&(rq)->lock); /* lock the run queue */ + runq_lock(rq); /* lock the run queue */ enqueue_head(&(rq)->runq[whichq], &((th)->links)); if (whichq < (rq)->low || (rq)->count == 0) @@ -350,7 +350,7 @@ simpler_thread_setrun( #else (th)->runq = (rq); #endif - simple_unlock(&(rq)->lock); + runq_unlock(rq); /* * Turn off first_quantum to allow context switch. diff --git a/kern/sched.h b/kern/sched.h index 07d27ff5..35747f19 100644 --- a/kern/sched.h +++ b/kern/sched.h @@ -74,6 +74,21 @@ struct run_queue { typedef struct run_queue *run_queue_t; #define RUN_QUEUE_NULL ((run_queue_t) 0) +/* Shall be taken at splsched only */ +#ifdef MACH_LDEBUG +#define runq_lock(rq) do { \ + assert(splsched() == SPL7); \ + simple_lock_nocheck(&(rq)->lock); \ +} while (0) +#define runq_unlock(rq) do { \ + assert(splsched() == SPL7); \ + simple_unlock_nocheck(&(rq)->lock); \ +} while (0) +#else +#define runq_lock(rq) simple_lock_nocheck(&(rq)->lock) +#define runq_unlock(rq) simple_unlock_nocheck(&(rq)->lock) +#endif + #if MACH_FIXPRI /* * NOTE: For fixed priority threads, first_quantum indicates diff --git a/kern/sched_prim.c b/kern/sched_prim.c index dd0f492b..793a09f2 100644 --- a/kern/sched_prim.c +++ b/kern/sched_prim.c @@ -1174,7 +1174,7 @@ void update_priority( whichq = NRQS - 1; \ } \ \ - simple_lock(&(rq)->lock); /* lock the run queue */ \ + runq_lock(rq); /* lock the run queue */ \ checkrq((rq), "thread_setrun: before adding thread"); \ enqueue_tail(&(rq)->runq[whichq], &((th)->links)); \ \ @@ -1185,7 +1185,7 @@ void update_priority( (th)->runq = (rq); \ thread_check((th), (rq)); \ checkrq((rq), "thread_setrun: after adding thread"); \ - simple_unlock(&(rq)->lock); \ + runq_unlock(rq); \ MACRO_END #else /* DEBUG */ #define run_queue_enqueue(rq, th) \ @@ -1198,7 +1198,7 @@ void update_priority( whichq = NRQS - 1; \ } \ \ - simple_lock(&(rq)->lock); /* lock the run queue */ \ + runq_lock(rq); /* lock the run queue */ \ enqueue_tail(&(rq)->runq[whichq], &((th)->links)); \ \ if (whichq < (rq)->low || (rq)->count == 0) \ @@ -1206,7 +1206,7 @@ void update_priority( \ (rq)->count++; \ (th)->runq = (rq); \ - simple_unlock(&(rq)->lock); \ + runq_unlock(rq); \ MACRO_END #endif /* DEBUG */ /* @@ -1422,7 +1422,7 @@ struct run_queue *rem_runq( * the thread is on a runq, but could leave. */ if (rq != RUN_QUEUE_NULL) { - simple_lock(&rq->lock); + runq_lock(rq); #if DEBUG checkrq(rq, "rem_runq: at entry"); #endif /* DEBUG */ @@ -1441,7 +1441,7 @@ struct run_queue *rem_runq( checkrq(rq, "rem_runq: after removing thread"); #endif /* DEBUG */ th->runq = RUN_QUEUE_NULL; - simple_unlock(&rq->lock); + runq_unlock(rq); } else { /* @@ -1450,7 +1450,7 @@ struct run_queue *rem_runq( * can't move again because this routine's * caller locked the thread. */ - simple_unlock(&rq->lock); + runq_unlock(rq); rq = RUN_QUEUE_NULL; } } |