Make a KernelObject base class for all Capabilities.
This commit is contained in:
parent
d358c1d672
commit
4e278a4664
9 changed files with 50 additions and 21 deletions
|
|
@ -20,13 +20,16 @@ RefPtr<Process> Process::RootProcess() {
|
|||
|
||||
return proc;
|
||||
}
|
||||
RefPtr<Process> Process::Create() { return MakeRefCounted<Process>(); }
|
||||
|
||||
Process::Process() : id_(gNextId++), state_(RUNNING) {
|
||||
caps_.PushBack(new Capability(this, Capability::PROCESS, Z_INIT_PROC_SELF,
|
||||
ZC_PROC_SPAWN_PROC | ZC_PROC_SPAWN_THREAD));
|
||||
RefPtr<Process> Process::Create() {
|
||||
auto proc = MakeRefCounted<Process>();
|
||||
proc->caps_.PushBack(
|
||||
new Capability(proc, Capability::PROCESS, Z_INIT_PROC_SELF,
|
||||
ZC_PROC_SPAWN_PROC | ZC_PROC_SPAWN_THREAD));
|
||||
return proc;
|
||||
}
|
||||
|
||||
Process::Process() : id_(gNextId++), state_(RUNNING) {}
|
||||
|
||||
RefPtr<Thread> Process::CreateThread() {
|
||||
RefPtr<Thread> thread = MakeRefCounted<Thread>(*this, next_thread_id_++);
|
||||
threads_.PushBack(thread);
|
||||
|
|
@ -65,12 +68,12 @@ SharedPtr<Capability> Process::GetCapability(uint64_t cid) {
|
|||
++iter;
|
||||
}
|
||||
dbgln("Bad cap access");
|
||||
dbgln("Num caps: %u", caps_.size());
|
||||
return {};
|
||||
}
|
||||
|
||||
uint64_t Process::AddCapability(RefPtr<Thread>& thread) {
|
||||
uint64_t Process::AddCapability(const RefPtr<Thread>& thread) {
|
||||
uint64_t cap_id = next_cap_id_++;
|
||||
caps_.PushBack(
|
||||
new Capability(thread.get(), Capability::THREAD, cap_id, ZC_WRITE));
|
||||
caps_.PushBack(new Capability(thread, Capability::THREAD, cap_id, ZC_WRITE));
|
||||
return cap_id;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@
|
|||
|
||||
#include "capability/capability.h"
|
||||
#include "lib/linked_list.h"
|
||||
#include "lib/ref_counted.h"
|
||||
#include "lib/ref_ptr.h"
|
||||
#include "lib/shared_ptr.h"
|
||||
#include "memory/virtual_memory.h"
|
||||
|
|
@ -12,7 +11,7 @@
|
|||
// Forward decl due to cyclic dependency.
|
||||
class Thread;
|
||||
|
||||
class Process : public RefCounted<Process> {
|
||||
class Process : public KernelObject {
|
||||
public:
|
||||
enum State {
|
||||
UNSPECIFIED,
|
||||
|
|
@ -30,7 +29,7 @@ class Process : public RefCounted<Process> {
|
|||
RefPtr<Thread> GetThread(uint64_t tid);
|
||||
|
||||
SharedPtr<Capability> GetCapability(uint64_t cid);
|
||||
uint64_t AddCapability(RefPtr<Thread>& t);
|
||||
uint64_t AddCapability(const RefPtr<Thread>& t);
|
||||
// Checks the state of all child threads and transitions to
|
||||
// finished if all have finished.
|
||||
void CheckState();
|
||||
|
|
|
|||
|
|
@ -2,13 +2,13 @@
|
|||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "lib/ref_counted.h"
|
||||
#include "lib/ref_ptr.h"
|
||||
#include "object/kernel_object.h"
|
||||
|
||||
// Forward decl due to cyclic dependency.
|
||||
class Process;
|
||||
|
||||
class Thread : public RefCounted<Thread> {
|
||||
class Thread : public KernelObject {
|
||||
public:
|
||||
enum State {
|
||||
UNSPECIFIED,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue