mirror of
https://github.com/justinian/jsix.git
synced 2025-12-10 08:24:32 -08:00
First pass at message syscalls
This commit is contained in:
@@ -1,28 +1,65 @@
|
||||
#include "process.h"
|
||||
#include "scheduler.h"
|
||||
|
||||
|
||||
void
|
||||
bool
|
||||
process::wait_on_signal(uint64_t sigmask)
|
||||
{
|
||||
waiting = process_wait::signal;
|
||||
waiting_info = sigmask;
|
||||
flags -= process_flags::ready;
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
bool
|
||||
process::wait_on_child(uint32_t pid)
|
||||
{
|
||||
waiting = process_wait::child;
|
||||
waiting_info = pid;
|
||||
flags -= process_flags::ready;
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
bool
|
||||
process::wait_on_time(uint64_t time)
|
||||
{
|
||||
waiting = process_wait::time;
|
||||
waiting_info = time;
|
||||
flags -= process_flags::ready;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
process::wait_on_send(uint32_t target_id)
|
||||
{
|
||||
scheduler &s = scheduler::get();
|
||||
process *target = s.get_process_by_id(target_id);
|
||||
if (!target) return false;
|
||||
|
||||
if (!target->wake_on_receive(this)) {
|
||||
waiting = process_wait::send;
|
||||
waiting_info = target_id;
|
||||
flags -= process_flags::ready;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
process::wait_on_receive(uint32_t source_id)
|
||||
{
|
||||
scheduler &s = scheduler::get();
|
||||
process *source = s.get_process_by_id(source_id);
|
||||
if (!source) return false;
|
||||
|
||||
if (!source->wake_on_send(this)) {
|
||||
waiting = process_wait::receive;
|
||||
waiting_info = source_id;
|
||||
flags -= process_flags::ready;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
@@ -49,7 +86,6 @@ process::wake_on_child(process *child)
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
process::wake_on_time(uint64_t now)
|
||||
{
|
||||
@@ -62,3 +98,28 @@ process::wake_on_time(uint64_t now)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
process::wake_on_send(process *target)
|
||||
{
|
||||
if (waiting != process_wait::send ||
|
||||
waiting_info != target->pid)
|
||||
return false;
|
||||
|
||||
waiting = process_wait::none;
|
||||
flags += process_flags::ready;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
process::wake_on_receive(process *source)
|
||||
{
|
||||
if (waiting != process_wait::receive ||
|
||||
waiting_info != source->pid)
|
||||
return false;
|
||||
|
||||
waiting = process_wait::none;
|
||||
flags += process_flags::ready;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user