-
Notifications
You must be signed in to change notification settings - Fork 0
/
kernel_message.c
42 lines (35 loc) · 896 Bytes
/
kernel_message.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include "kernel.h"
#include "kernel_ipc.h"
#include "kernel_port.h"
/* Asynchronous message passing. */
void message_put(Task *destination, Message *message)
{
message->node.ln_pri = PRIORITY_NORMAL;
message->source = running_task;
interrupts_disable();
list_add_end(&destination->messages, (Node *) message);
interrupts_enable();
task_signal(destination, SIGNAL_MESSAGE);
}
void message_wait(void)
{
task_wait(SIGNAL_MESSAGE);
}
Message *message_get(void)
{
Message *m;
interrupts_disable();
m = (Message *) list_remove_head(&running_task->messages);
interrupts_enable();
return m;
}
/* Synchronous message passing. */
void message_putget(Task *destination, Message *message)
{
message_put(destination, message);
task_wait(SIGNAL_REPLY);
}
void message_reply(Message *message)
{
task_signal(message->source, SIGNAL_REPLY);
}