mirror of
https://github.com/justinian/jsix.git
synced 2025-12-10 16:34:31 -08:00
[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,19 +2,14 @@
|
||||
#include "j6/types.h"
|
||||
|
||||
#include "objects/channel.h"
|
||||
#include "objects/thread.h"
|
||||
#include "objects/process.h"
|
||||
#include "scheduler.h"
|
||||
|
||||
namespace syscalls {
|
||||
|
||||
j6_status_t
|
||||
channel_create(j6_handle_t *handle)
|
||||
{
|
||||
scheduler &s = scheduler::get();
|
||||
TCB *tcb = s.current();
|
||||
thread *parent = thread::from_tcb(tcb);
|
||||
process &p = parent->parent();
|
||||
process &p = process::current();
|
||||
|
||||
channel *c = new channel;
|
||||
*handle = p.add_handle(c);
|
||||
@@ -25,10 +20,7 @@ channel_create(j6_handle_t *handle)
|
||||
j6_status_t
|
||||
channel_close(j6_handle_t handle)
|
||||
{
|
||||
scheduler &s = scheduler::get();
|
||||
TCB *tcb = s.current();
|
||||
thread *parent = thread::from_tcb(tcb);
|
||||
process &p = parent->parent();
|
||||
process &p = process::current();
|
||||
|
||||
kobject *o = p.lookup_handle(handle);
|
||||
if (!o || o->get_type() != kobject::type::channel)
|
||||
@@ -44,10 +36,7 @@ channel_close(j6_handle_t handle)
|
||||
j6_status_t
|
||||
channel_send(j6_handle_t handle, size_t *len, void *data)
|
||||
{
|
||||
scheduler &s = scheduler::get();
|
||||
TCB *tcb = s.current();
|
||||
thread *parent = thread::from_tcb(tcb);
|
||||
process &p = parent->parent();
|
||||
process &p = process::current();
|
||||
|
||||
kobject *o = p.lookup_handle(handle);
|
||||
if (!o || o->get_type() != kobject::type::channel)
|
||||
@@ -60,10 +49,7 @@ channel_send(j6_handle_t handle, size_t *len, void *data)
|
||||
j6_status_t
|
||||
channel_receive(j6_handle_t handle, size_t *len, void *data)
|
||||
{
|
||||
scheduler &s = scheduler::get();
|
||||
TCB *tcb = s.current();
|
||||
thread *parent = thread::from_tcb(tcb);
|
||||
process &p = parent->parent();
|
||||
process &p = process::current();
|
||||
|
||||
kobject *o = p.lookup_handle(handle);
|
||||
if (!o || o->get_type() != kobject::type::channel)
|
||||
|
||||
Reference in New Issue
Block a user