From f2c51bc81d2aa618b29ddbeaae5ac1c5308821f0 Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Mon, 9 Feb 2015 17:39:41 +0100 Subject: Reorganize all. --- src/kernel/user/process.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 src/kernel/user/process.c (limited to 'src/kernel/user') diff --git a/src/kernel/user/process.c b/src/kernel/user/process.c new file mode 100644 index 0000000..7519dae --- /dev/null +++ b/src/kernel/user/process.c @@ -0,0 +1,30 @@ +#include +#include + +typedef struct process { + thread_t *thread; + int pid; + + mutex_t com_mutex; + + hashtbl_t *chans; + chan_id_t next_chan_id; + + message_t mbox[PROCESS_MAILBOX_SIZE]; + int mbox_size; // number of messages in queue + int mbox_first; // first message in queue (circular buffer) + + // a process can be in several waiting states : + // - wait for any message + // - wait for a message on a particular channel + // in this case, if a message is pushed on this particular channel, + // then it is put in front of the queue, so that it is the next message read + // (it is guaranteed that doing await_message_on_chan() immediately followed by get_message() + // gets the message whose size was returned by await_...) + int wait_state; + chan_id_t wait_chan_id; // when waiting for a message on a particular channel +} process_t; + +int push_message(process_t *proc, message_t msg); // nonnull on error (process queue is full) + +/* vim: set ts=4 sw=4 tw=0 noet :*/ -- cgit v1.2.3