Move Processes and Threads to be stored in SharedPtr
Reference counting lets us pass these around a bit more easily. SharedPtr was lightly tested using uint64_t in the main zion funcion. Also add a sleep functionality instead of panicking. Functionally the same right now since we don't preempt.
This commit is contained in:
parent
9f3ffbf5b4
commit
80d2bf1aaa
6 changed files with 96 additions and 23 deletions
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "lib/shared_ptr.h"
|
||||
|
||||
// Forward decl due to cyclic dependency.
|
||||
class Process;
|
||||
|
||||
|
|
@ -15,9 +17,10 @@ class Thread {
|
|||
BLOCKED,
|
||||
FINISHED,
|
||||
};
|
||||
static Thread* RootThread(Process* root_proc);
|
||||
static SharedPtr<Thread> RootThread(Process* root_proc);
|
||||
|
||||
explicit Thread(Process* proc, uint64_t tid, uint64_t elf_ptr);
|
||||
explicit Thread(const SharedPtr<Process>& proc, uint64_t tid,
|
||||
uint64_t elf_ptr);
|
||||
|
||||
uint64_t tid() { return id_; };
|
||||
uint64_t pid();
|
||||
|
|
@ -38,7 +41,7 @@ class Thread {
|
|||
private:
|
||||
// Special constructor for the root thread only.
|
||||
Thread(Process* proc) : process_(proc), id_(0) {}
|
||||
Process* process_;
|
||||
SharedPtr<Process> process_;
|
||||
uint64_t id_;
|
||||
State state_ = RUNNABLE;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue