mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-11-01 23:18:21 +00:00
scheduler: sched_terminateprogram()
This commit is contained in:
@@ -155,5 +155,6 @@ void sched_targetcpu(struct cpu_t *cpu);
|
|||||||
void sched_sleepus(size_t us);
|
void sched_sleepus(size_t us);
|
||||||
void sched_apentry();
|
void sched_apentry();
|
||||||
void sched_inactiveproc(proc_t *proc);
|
void sched_inactiveproc(proc_t *proc);
|
||||||
|
void sched_terminateprogram(int status);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -407,6 +407,19 @@ void sched_stopotherthreads() {
|
|||||||
proc->nomorethreads = false;
|
proc->nomorethreads = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void sched_terminateprogram(int status) {
|
||||||
|
thread_t *thread = _cpu()->thread;
|
||||||
|
proc_t *proc = thread->proc;
|
||||||
|
if (spinlock_try(&proc->exiting) == false)
|
||||||
|
sched_threadexit();
|
||||||
|
|
||||||
|
sched_stopotherthreads();
|
||||||
|
|
||||||
|
proc->status = status;
|
||||||
|
|
||||||
|
sched_threadexit();
|
||||||
|
}
|
||||||
|
|
||||||
static void yield(context_t *context) {
|
static void yield(context_t *context) {
|
||||||
thread_t *thread = _cpu()->thread;
|
thread_t *thread = _cpu()->thread;
|
||||||
|
|
||||||
|
|||||||
@@ -253,12 +253,10 @@ bool signal_check(struct thread_t *thread, context_t *context, bool syscall, uin
|
|||||||
THREAD_ENTER(thread);
|
THREAD_ENTER(thread);
|
||||||
|
|
||||||
if (SIGNAL_GET(&proc->signals.pending, SIGKILL) || SIGNAL_GET(&thread->signals.pending, SIGKILL)) {
|
if (SIGNAL_GET(&proc->signals.pending, SIGKILL) || SIGNAL_GET(&thread->signals.pending, SIGKILL)) {
|
||||||
// TODO terminate entire program
|
|
||||||
THREAD_LEAVE(thread);
|
THREAD_LEAVE(thread);
|
||||||
PROCESS_LEAVE(proc);
|
PROCESS_LEAVE(proc);
|
||||||
proc->status = SIGKILL;
|
|
||||||
interrupt_set(true);
|
interrupt_set(true);
|
||||||
sched_threadexit();
|
sched_terminateprogram(SIGKILL);
|
||||||
}
|
}
|
||||||
|
|
||||||
// find the first pending signal which is unmasked
|
// find the first pending signal which is unmasked
|
||||||
@@ -312,12 +310,10 @@ bool signal_check(struct thread_t *thread, context_t *context, bool syscall, uin
|
|||||||
goto leave;
|
goto leave;
|
||||||
case ACTION_CORE:
|
case ACTION_CORE:
|
||||||
case ACTION_TERM:
|
case ACTION_TERM:
|
||||||
// TODO terminate entire program
|
|
||||||
proc->status = signal;
|
|
||||||
THREAD_LEAVE(thread);
|
THREAD_LEAVE(thread);
|
||||||
PROCESS_LEAVE(proc);
|
PROCESS_LEAVE(proc);
|
||||||
interrupt_set(true);
|
interrupt_set(true);
|
||||||
sched_threadexit();
|
sched_terminateprogram(signal);
|
||||||
case ACTION_STOP:
|
case ACTION_STOP:
|
||||||
// TODO what if a thread unmasks a stop signal?
|
// TODO what if a thread unmasks a stop signal?
|
||||||
// check if sigcont is not pending for the thread (SIGCONT is always sent to the thread)
|
// check if sigcont is not pending for the thread (SIGCONT is always sent to the thread)
|
||||||
|
|||||||
@@ -6,14 +6,6 @@
|
|||||||
#include <semaphore.h>
|
#include <semaphore.h>
|
||||||
|
|
||||||
__attribute__((noreturn)) void syscall_exit(context_t *context, int status) {
|
__attribute__((noreturn)) void syscall_exit(context_t *context, int status) {
|
||||||
thread_t *thread = _cpu()->thread;
|
sched_terminateprogram(status << 8);
|
||||||
proc_t *proc = thread->proc;
|
__builtin_unreachable();
|
||||||
if (spinlock_try(&proc->exiting) == false)
|
|
||||||
sched_threadexit();
|
|
||||||
|
|
||||||
sched_stopotherthreads();
|
|
||||||
|
|
||||||
proc->status = status << 8;
|
|
||||||
|
|
||||||
sched_threadexit();
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user