Kernel: Process is not reference counted any more

This was not necessary and it made things needlessly complicated
This commit is contained in:
Bananymous
2023-04-19 00:34:18 +03:00
parent 3ca623349a
commit d63716db96
11 changed files with 91 additions and 69 deletions

View File

@@ -13,7 +13,7 @@
namespace Kernel
{
class Process : BAN::RefCounted<Process>
class Process
{
BAN_NON_COPYABLE(Process);
BAN_NON_MOVABLE(Process);
@@ -22,8 +22,8 @@ namespace Kernel
using entry_t = Thread::entry_t;
public:
static BAN::ErrorOr<BAN::RefPtr<Process>> create_kernel(entry_t, void*);
static BAN::ErrorOr<BAN::RefPtr<Process>> create_userspace(void(*)());
static BAN::ErrorOr<Process*> create_kernel(entry_t, void*);
static BAN::ErrorOr<Process*> create_userspace(void(*)());
~Process();
[[noreturn]] void exit();
@@ -52,10 +52,11 @@ namespace Kernel
BAN::ErrorOr<BAN::String> working_directory() const;
BAN::ErrorOr<void> set_working_directory(BAN::StringView);
static BAN::RefPtr<Process> current() { return Thread::current().process(); }
static Process& current() { return Thread::current().process(); }
private:
Process(pid_t);
static Process* create_process();
BAN::ErrorOr<BAN::String> absolute_path_of(BAN::StringView) const;
@@ -81,8 +82,6 @@ namespace Kernel
BAN::Vector<Thread*> m_threads;
TTY* m_tty { nullptr };
friend class BAN::RefPtr<Process>;
};
}

View File

@@ -26,7 +26,7 @@ namespace Kernel
};
public:
static BAN::ErrorOr<Thread*> create(entry_t, void* = nullptr, BAN::RefPtr<Process> = nullptr);
static BAN::ErrorOr<Thread*> create(entry_t, void*, Process*);
~Thread();
void jump_userspace(uintptr_t rip);
@@ -46,22 +46,22 @@ namespace Kernel
size_t stack_size() const { return m_stack_size; }
static Thread& current() ;
BAN::RefPtr<Process> process();
Process& process();
private:
Thread(pid_t tid, BAN::RefPtr<Process>);
Thread(pid_t tid, Process*);
BAN::ErrorOr<void> initialize(entry_t, void*);
void on_exit();
private:
static constexpr size_t m_stack_size = 4096 * 1;
void* m_stack_base = nullptr;
uintptr_t m_rip = 0;
uintptr_t m_rsp = 0;
const pid_t m_tid = 0;
State m_state { State::NotStarted };
BAN::RefPtr<Process> m_process;
void* m_stack_base { nullptr };
uintptr_t m_rip { 0 };
uintptr_t m_rsp { 0 };
const pid_t m_tid { 0 };
State m_state { State::NotStarted };
Process* m_process { nullptr };
friend class Scheduler;
};