From 06f8cfd2795fe045f184f0385bdb0f7b3f1236d7 Mon Sep 17 00:00:00 2001 From: Anton Lydike Date: Tue, 17 Aug 2021 09:12:37 +0200 Subject: [PATCH] removed mutex kernel code --- Makefile | 4 ++-- kinclude/mutex.c | 37 ------------------------------------- kinclude/mutex.h | 13 ------------- kinclude/sched.c | 15 --------------- 4 files changed, 2 insertions(+), 67 deletions(-) delete mode 100644 kinclude/mutex.c delete mode 100644 kinclude/mutex.h diff --git a/Makefile b/Makefile index 1cdefc5..b1dc873 100644 --- a/Makefile +++ b/Makefile @@ -30,10 +30,10 @@ ARCH = rv32im # here you CFLAGS += -march=$(ARCH) # dependencies that need to be built: -_DEPS = ecall.c csr.c mutex.c sched.c +_DEPS = ecall.c csr.c sched.c # dependencies as object files: -_OBJ = ecall.o mutex.o sched.o boot.o csr.o +_OBJ = ecall.o sched.o boot.o csr.o DEPS = $(patsubst %,$(KLIBDIR)/%,$(_DEPS)) diff --git a/kinclude/mutex.c b/kinclude/mutex.c deleted file mode 100644 index dc2dd26..0000000 --- a/kinclude/mutex.c +++ /dev/null @@ -1,37 +0,0 @@ -#include "mutex.h" -#include "../kernel.h" - -// mutex lock structure: -// this is a dict describing which process instantiated the lock -// it maps mutex_id -> pid (or zero for unused locks) -int locks[MUTEX_COUNT]; -int locks_bitfield[MUTEX_COUNT / XLEN]; // each bit representing if the lock is - // engaged - - -int mutex_is_locked(int mutex_id) -{ - int offset = mutex_id % XLEN; - - return locks[mutex_id / XLEN] & (1 << offset); -} - -int mutex_create() -{ - return 0; -} - -void mutex_lock(int mutex_id) -{ - -} - -void mutex_unlock(int mutex_id) -{ - -} - -void mutex_destroy(int mutex_id) -{ - -} diff --git a/kinclude/mutex.h b/kinclude/mutex.h deleted file mode 100644 index 96a92c6..0000000 --- a/kinclude/mutex.h +++ /dev/null @@ -1,13 +0,0 @@ -#ifndef H_MUTEX -#define H_MUTEX - -// mutex operations (modifies data, no checks) -int mutex_create(); -void mutex_lock(int mutex_id); -void mutex_unlock(int mutex_id); -void mutex_destroy(int mutex_id); -// mutex helpers -int mutex_is_locked(int mutex_id); - - -#endif \ No newline at end of file diff --git a/kinclude/sched.c b/kinclude/sched.c index a236fe3..a6f95a9 100644 --- a/kinclude/sched.c +++ b/kinclude/sched.c @@ -1,6 +1,5 @@ #include "../kernel.h" #include "sched.h" -#include "mutex.h" #include "csr.h" @@ -48,20 +47,6 @@ int scheduler_select_free() timeout_available = true; } } - - if (pcb->status == PROC_WAIT_LOCK) { - if (pcb->asleep_until != 0) { - if (pcb->asleep_until < mtime) { - // set process return args! - return (current_process_index + i) % PROCESS_COUNT; - } - timeout_available = true; - } - - if (!mutex_is_locked(pcb->requested_lock)) { - return (current_process_index + i) % PROCESS_COUNT; - } - } } if (timeout_available == false) {