[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

@@ -18,6 +18,9 @@ public:
/// Size of userspace thread stacks
constexpr static size_t stack_size = 0x4000;
/// Value that represents default priority
constexpr static uint8_t default_pri = 0xff;
/// Constructor.
process();
@@ -43,7 +46,7 @@ public:
/// \args priority The new thread's scheduling priority
/// \args user If true, create a userspace stack for this thread
/// \returns The newly created thread object
thread * create_thread(uint8_t priorty, bool user = true);
thread * create_thread(uint8_t priorty = default_pri, bool user = true);
/// Start tracking an object with a handle.
/// \args obj The object this handle refers to