|
PatchworkOS
|
Signal style inter-process communication. More...
Data Structures | |
| struct | note_t |
| Note structure. More... | |
| struct | note_queue_t |
| Per-thread note queue. More... | |
Macros | |
| #define | NOTE_MAX_BUFFER 64 |
| Maximum size of a notes buffer. | |
Enumerations | |
| enum | note_queue_flag_t { NOTE_QUEUE_NONE = 0 , NOTE_QUEUE_RECIEVED_KILL = 1 << 0 } |
| Note queue flags. More... | |
Functions | |
| void | note_queue_init (note_queue_t *queue) |
| Initialize a note queue. | |
| uint64_t | note_queue_length (note_queue_t *queue) |
| Get the length of a note queue. | |
| uint64_t | note_queue_write (note_queue_t *queue, const void *buffer, uint64_t count) |
| Write a note to a note queue. | |
| void | note_interrupt_handler (interrupt_frame_t *frame, cpu_t *self) |
| Note interrupt handler. | |
Signal style inter-process communication.
Notes are exposed in the /proc/[pid]/note file. Notes are used for inter-process communication (IPC) in a way similar to signals in Unix-like operating systems. However, they allow for a buffer of data to be sent instead of just an integer. In theory anything could be sent as a note.
Notes are sent by writing to the /proc/[pid]/note file of the target process. The data written to the file is sent as a note to one of the threads in the target process.
TODO: Receiving notes, software interrupts, etc.
Certain notes will cause the kernel to take special actions and, for the sake of concistency, we define some notes that all user processes should handle in a standard way. The values for these notes are intended to mirror UNIX signals where applicable. Below is a list of all of these special notes:
| enum note_queue_flag_t |
Note queue flags.
| void note_interrupt_handler | ( | interrupt_frame_t * | frame, |
| cpu_t * | self | ||
| ) |
Note interrupt handler.
| frame | The current interrupt frame. |
| self | The currently running cpu. |
Definition at line 77 of file note.c.
References note_t::buffer, CONFIG_MAX_NOTES, EXIT_FAILURE, note_queue_t::flags, thread_t::id, note_t::length, note_queue_t::length, note_queue_t::lock, lock_acquire(), lock_release(), LOG_WARN, NOTE_QUEUE_RECIEVED_KILL, note_queue_t::notes, thread_t::notes, thread_t::process, process_kill(), note_queue_t::readIndex, SCHED_DIE, sched_invoke(), and sched_thread_unsafe().
Referenced by interrupt_handler().
| void note_queue_init | ( | note_queue_t * | queue | ) |
Initialize a note queue.
| queue | The queue to initialize. |
Definition at line 22 of file note.c.
References note_queue_t::flags, note_queue_t::length, note_queue_t::lock, lock_init(), NOTE_QUEUE_NONE, note_queue_t::readIndex, and note_queue_t::writeIndex.
Referenced by thread_init().
| uint64_t note_queue_length | ( | note_queue_t * | queue | ) |
Get the length of a note queue.
| queue | The queue to query. |
Definition at line 31 of file note.c.
References note_queue_t::flags, note_queue_t::length, note_queue_t::lock, LOCK_SCOPE, and NOTE_QUEUE_RECIEVED_KILL.
Referenced by syscall_handler(), and thread_is_note_pending().
| uint64_t note_queue_write | ( | note_queue_t * | queue, |
| const void * | buffer, | ||
| uint64_t | count | ||
| ) |
Write a note to a note queue.
| queue | The destination queue. |
| buffer | The buffer to write. |
| count | The number of bytes to write. |
0. On failure, ERR and errno is set. Definition at line 37 of file note.c.
References assert, note_t::buffer, buffer, CONFIG_MAX_NOTES, count, EINVAL, ERR, errno, note_queue_t::flags, process_t::id, note_t::length, note_queue_t::length, note_queue_t::lock, LOCK_SCOPE, memcpy(), NOTE_MAX_BUFFER, note_queue_compare_buffers(), NOTE_QUEUE_RECIEVED_KILL, note_queue_t::notes, NULL, note_queue_t::readIndex, sched_process(), note_t::sender, and note_queue_t::writeIndex.
Referenced by thread_send_note().