[kernel] Start process handles at 1

The 0 index was still sometimes not handled properly in the hash table.
Also 0 is sometimes indicative of an error. Let's just start handles
from 1 to avoid those issues.
This commit is contained in:
Justin C. Miller
2021-02-03 16:55:14 -08:00
parent 33ed95bd8e
commit 41eb45402e
2 changed files with 3 additions and 3 deletions

View File

@@ -17,13 +17,13 @@ kutil::vector<process*> process::s_processes;
process::process() : process::process() :
kobject {kobject::type::process}, kobject {kobject::type::process},
m_next_handle {0}, m_next_handle {1},
m_state {state::running} m_state {state::running}
{ {
s_processes.append(this); s_processes.append(this);
j6_handle_t self = add_handle(this); j6_handle_t self = add_handle(this);
kassert(self == self_handle(), "Process self-handle is not 0"); kassert(self == self_handle(), "Process self-handle is not 1");
} }
// The "kernel process"-only constructor // The "kernel process"-only constructor

View File

@@ -69,7 +69,7 @@ public:
bool thread_exited(thread *th); bool thread_exited(thread *th);
/// Get the handle for this process to refer to itself /// Get the handle for this process to refer to itself
inline j6_handle_t self_handle() const { return 0; } inline j6_handle_t self_handle() const { return 1; }
/// Get the process object that owns kernel threads and the /// Get the process object that owns kernel threads and the
/// kernel address space /// kernel address space