aboutsummaryrefslogtreecommitdiff
path: root/src/kernel/include/process.h
diff options
context:
space:
mode:
authorAlex Auvolat <alex.auvolat@ens.fr>2015-02-09 17:39:41 +0100
committerAlex Auvolat <alex.auvolat@ens.fr>2015-02-09 17:40:03 +0100
commitf2c51bc81d2aa618b29ddbeaae5ac1c5308821f0 (patch)
treefae67a79d5e60128d074550326a05216694a5848 /src/kernel/include/process.h
parenta5dfdd2b3fa91a2cda4f807c88bd35928e3c7a61 (diff)
downloadkogata-f2c51bc81d2aa618b29ddbeaae5ac1c5308821f0.tar.gz
kogata-f2c51bc81d2aa618b29ddbeaae5ac1c5308821f0.zip
Reorganize all.
Diffstat (limited to 'src/kernel/include/process.h')
-rw-r--r--src/kernel/include/process.h43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/kernel/include/process.h b/src/kernel/include/process.h
new file mode 100644
index 0000000..00ed1d7
--- /dev/null
+++ b/src/kernel/include/process.h
@@ -0,0 +1,43 @@
+#pragma once
+
+// Things described in this file are essentially a public interface
+// All implementation details are hidden in process.c
+
+#include <thread.h>
+
+#include <hashtbl.h>
+#include <buffer.h>
+
+#define PW_NOT_WAITING 0
+#define PW_WAIT_ANY_MSG 1
+#define PW_WAIT_MSG_ON_CHAN 2
+
+#define PROCESS_MAILBOX_SIZE 42
+
+typedef int chan_id_t;
+
+typedef struct chan_pair {
+ chan_id_t fst, snd;
+} chan_pair_t;
+
+typedef struct message {
+ buffer_t *data;
+ chan_id_t chan_id;
+} message_t;
+
+struct process;
+typedef struct process process_t;
+
+process_t *new_process(entry_t entry, void* data, chan_pair_t *give_chans);
+
+chan_pair_t new_chan(); // not used very often, but still usefull
+chan_id_t unbox_chan(chan_id_t chan, chan_id_t subchan);
+void detach_chan(chan_id_t chan); // chan ID is freed
+
+int send_message(chan_id_t chan, buffer_t *msg); // nonnull on error (recipient queue is full)
+
+size_t await_message(); // returns the size of the first message to come
+size_t await_message_on_chan(chan_id_t chan); // returns the size of the first message to come
+message_t get_message(); // gets the first message in the queue (or nothing when queue is empty)
+
+/* vim: set ts=4 sw=4 tw=0 noet :*/