[kernel] Use map for process handles
Replace linearly-indexed vector of handles with new kutil::map. Also provide thread::current() and process::current() accessors so that every syscall doesn't need to include the scheduler to deduce the current process.
This commit is contained in:
@@ -2,6 +2,8 @@
|
||||
/// \file process.h
|
||||
/// Definition of process kobject types
|
||||
|
||||
#include "kutil/map.h"
|
||||
#include "kutil/vector.h"
|
||||
#include "objects/kobject.h"
|
||||
#include "page_table.h"
|
||||
|
||||
@@ -22,6 +24,9 @@ public:
|
||||
/// Destructor.
|
||||
virtual ~process();
|
||||
|
||||
/// Get the currently executing process.
|
||||
static process & current();
|
||||
|
||||
/// Terminate this process.
|
||||
/// \arg code The return code to exit with.
|
||||
void exit(unsigned code);
|
||||
@@ -68,7 +73,8 @@ private:
|
||||
|
||||
page_table *m_pml4;
|
||||
kutil::vector<thread*> m_threads;
|
||||
kutil::vector<kobject*> m_handles;
|
||||
kutil::map<j6_handle_t, kobject*> m_handles;
|
||||
j6_handle_t m_next_handle;
|
||||
|
||||
enum class state : uint8_t { running, exited };
|
||||
state m_state;
|
||||
|
||||
Reference in New Issue
Block a user