[kernel] Have thread call scheduler on blocking

Instead of making every callsite that may make a thread do a blocking
operation also invoke the scheduler, move that logic into thread
implementation - if the thread is blocking and is the current thread,
call schedule().

Related changes in this commit:

- Also make exiting threads and processes call the scheduler when
  blocking.
- Threads start blocked, and get automatically added to the scheduler's
  blocked list.
This commit is contained in:
2020-09-27 21:35:15 -07:00
parent ff78c951f0
commit 87b0a93d32
9 changed files with 35 additions and 38 deletions

View File

@@ -3,7 +3,6 @@
#include "log.h"
#include "objects/process.h"
#include "scheduler.h"
namespace syscalls {
@@ -20,13 +19,10 @@ process_koid(j6_koid_t *koid)
j6_status_t
process_exit(int64_t status)
{
auto &s = scheduler::get();
process &p = process::current();
log::debug(logs::syscall, "Process %llx exiting with code %d", p.koid(), status);
p.exit(status);
s.schedule();
log::error(logs::syscall, "returned to exit syscall");
return j6_err_unexpected;