summaryrefslogtreecommitdiff
path: root/doc/messaging.txt
blob: 804bb5d5dce7831c126b518984194f5f4afdd65a (plain) (blame)
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
42
43
44
45
46
47
48
Message passing is the technique used by processes for communicating with each other.
It is based on a few basic functions :

= msg_register =
Registers the current process as the owner of a system channel.
System channels are aliases for PIDs (negative PIDs resolve to corresponding real PID).
They range from -1 to -255. They are allocated as follows :
 from -1 to -19 : drivers
   -1 = keyboard
   -2 = mouse
 from -20 to -29 : network services
   -20 = networking subsystem (may be in several parts)
 from -30 to -39 : system services
   -30 = virtual file system
   -31 = logger
   -32 = user server
 from -40 to -49 : UI services
   -40 = graphic server (includes VESA driver for now)
   -41 = sound server
Modules for HDD drivers, network cards, sound cards, ... do not register as devices but instead
notify of their presence to the corresponding service.

= msg_send =
Sends a message to a process. Arguments:
- Receiver PID or system channel id
- Message data (up to 64k bytes, minimum 4 bytes)
The first 4 bytes of the message data always designate the message code (function).
The kernel may intercept some special messages (as "kill process" or stuff like that).

= msg_info =
Gets first message in the queue for current process.
Function can block waiting for a message if asked by caller and if no other function already does it.
When it is there, return the following:
- If a message has come
- The sender PID
- The message code (first 4 bytes of data)
- The length of the data

= msg_get =
Reads the data of the first message in the queue for current process.
Is passed a pointer where the data will be written. It is supposed that enougth memory is already allocated.

From a kernel point of view, message passing is asynchronious,
but there also are userland functions for making them look synchronious by waiting for an answer.
Usually, message codes | 0x80000000 are answers to a message.

Most processes, most of the time, will be in a loop waiting for messages to come.
The drivers are the principal exception to that, they instead wait for an interrupt or another hardware signal.