diff options
| author | Kimplul <kimi.h.kuparinen@gmail.com> | 2024-07-02 21:58:34 +0300 |
|---|---|---|
| committer | Kimplul <kimi.h.kuparinen@gmail.com> | 2024-07-02 21:58:34 +0300 |
| commit | e06772a964e269d2d9abcb43a1edd868a62d4610 (patch) | |
| tree | 7e41a2898a3ebfcaa837732b31045561876b429d /src/uapi/proc.c | |
| parent | 8a3452098267e1af127d6c4f1836a9d82cd23f38 (diff) | |
| download | kmi-e06772a964e269d2d9abcb43a1edd868a62d4610.tar.gz kmi-e06772a964e269d2d9abcb43a1edd868a62d4610.zip | |
enable irqs when we sleep or swap threads
+ Also swap checks if thread is running
Diffstat (limited to 'src/uapi/proc.c')
| -rw-r--r-- | src/uapi/proc.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/uapi/proc.c b/src/uapi/proc.c index e87a2ec..bb4b463 100644 --- a/src/uapi/proc.c +++ b/src/uapi/proc.c @@ -181,6 +181,9 @@ SYSCALL_DEFINE1(swap)(struct tcb *t, sys_arg_t tid){ if (!s) return_args1(t, ERR_INVAL); + if (running(s)) + return_args1(t, ERR_EXT); + /* switch over to new thread */ use_tcb(s); @@ -195,6 +198,9 @@ SYSCALL_DEFINE1(swap)(struct tcb *t, sys_arg_t tid){ if (s->notify_state == NOTIFY_QUEUED) notify(s, 0); + /* if an irq handler is directly swapping to some other thread, + * interpret it as the thread being finished with its critical section */ + enable_irqs(); /* get register state for new thread */ return_args(s, get_args(s)); } |
