mirror of
https://github.com/justinian/jsix.git
synced 2025-12-10 00:14:32 -08:00
[kernel] Remove process & thread self-handles
For the coming switch to cap/handle ref-counting being the main lifetime determiner of objects, get rid of self handles for threads and processes to avoid circular references. Instead, passing 0 to syscalls expecting a thread or process handle signifies "this process/thread".
This commit is contained in:
@@ -24,8 +24,6 @@ process::process() :
|
||||
kobject {kobject::type::process},
|
||||
m_state {state::running}
|
||||
{
|
||||
m_self_handle = g_cap_table.create(this, process::self_caps);
|
||||
add_handle(m_self_handle);
|
||||
}
|
||||
|
||||
// The "kernel process"-only constructor
|
||||
@@ -71,28 +69,6 @@ process::exit(int32_t code)
|
||||
current.exit();
|
||||
}
|
||||
|
||||
void
|
||||
process::update()
|
||||
{
|
||||
util::scoped_lock lock {m_threads_lock};
|
||||
|
||||
kassert(false, "process::update used!");
|
||||
kassert(m_threads.count() > 0, "process::update with zero threads!");
|
||||
|
||||
size_t i = 0;
|
||||
while (i < m_threads.count()) {
|
||||
thread *th = m_threads[i];
|
||||
if (th->has_state(thread::state::exited)) {
|
||||
m_threads.remove_swap_at(i);
|
||||
continue;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
if (m_threads.count() == 0)
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
thread *
|
||||
process::create_thread(uintptr_t rsp3, uint8_t priority)
|
||||
{
|
||||
|
||||
@@ -20,9 +20,6 @@ public:
|
||||
/// Capabilities on a newly constructed process handle
|
||||
static constexpr j6_cap_t creation_caps = j6_cap_process_all;
|
||||
|
||||
/// Capabilities on a process to itself
|
||||
static constexpr j6_cap_t self_caps = j6_cap_process_all;
|
||||
|
||||
/// Top of memory area where thread stacks are allocated
|
||||
static constexpr uintptr_t stacks_top = 0x0000800000000000;
|
||||
|
||||
@@ -47,9 +44,6 @@ public:
|
||||
/// \arg code The return code to exit with.
|
||||
void exit(int32_t code);
|
||||
|
||||
/// Update internal bookkeeping about threads.
|
||||
void update();
|
||||
|
||||
/// Get the process' virtual memory space
|
||||
vm_space & space() { return m_space; }
|
||||
|
||||
@@ -105,7 +99,6 @@ private:
|
||||
// This constructor is called by create_kernel_process
|
||||
process(page_table *kpml4);
|
||||
|
||||
j6_handle_t m_self_handle;
|
||||
int32_t m_return_code;
|
||||
|
||||
vm_space m_space;
|
||||
|
||||
@@ -32,8 +32,6 @@ thread::thread(process &parent, uint8_t pri, uintptr_t rsp0) :
|
||||
m_tcb.rsp0 = rsp0;
|
||||
|
||||
m_creator = current_cpu().thread;
|
||||
m_self_handle = g_cap_table.create(this, thread::parent_caps);
|
||||
parent.add_handle(m_self_handle);
|
||||
}
|
||||
|
||||
thread::~thread()
|
||||
|
||||
@@ -57,9 +57,6 @@ public:
|
||||
/// Capabilities on a newly constructed thread handle
|
||||
static constexpr j6_cap_t creation_caps = j6_cap_thread_all;
|
||||
|
||||
/// Capabilities the parent process gets on new thread handles
|
||||
static constexpr j6_cap_t parent_caps = j6_cap_thread_all;
|
||||
|
||||
static constexpr kobject::type type = kobject::type::thread;
|
||||
|
||||
enum class state : uint8_t {
|
||||
@@ -168,9 +165,6 @@ public:
|
||||
uintptr_t rip0 = 0,
|
||||
uint64_t flags = 0);
|
||||
|
||||
/// Get the handle representing this thread to its process
|
||||
j6_handle_t self_handle() const { return m_self_handle; }
|
||||
|
||||
/// Create the kernel idle thread
|
||||
/// \arg kernel The process object that owns kernel tasks
|
||||
/// \arg rsp The existing stack for the idle thread
|
||||
@@ -208,7 +202,6 @@ private:
|
||||
message_data m_message_data;
|
||||
|
||||
wait_queue m_join_queue;
|
||||
j6_handle_t m_self_handle;
|
||||
};
|
||||
|
||||
} // namespace obj
|
||||
|
||||
Reference in New Issue
Block a user