Skip to content

<util/tls.h>

Per-thread control block (TCB): identity, priority and message box.

Every thread has one TCB slot in its space; the kernel fills the header and IPC copies messages through buf. GetTls() finds the current thread's slot.

#include <util/tls.h>

Constants

Name Value Description
PAGE_SIZE 4096 Page size in bytes.
TCB_HDR_SIZE 64 Bytes of TCB header before the message box.
MSG_BUF_SIZE 512 Size of a thread's message box: the most one Call() or Reply() can carry.
TCB_SLOT_SIZE (TCB_HDR_SIZE + MSG_BUF_SIZE) Bytes per TCB slot (576).
SLOTS_PER_PAGE (PAGE_SIZE / TCB_SLOT_SIZE) TCB slots per page (7).
TCB_MAX_SLOTS 255 Most threads per space; 0xFF is reserved to mean "no slot".
MAX_TCB_PAGES Pages reserved for TCB slots in every space (37).

Structures

ThreadLocalData

One thread's TCB slot. The header is written by the kernel; treat it as read-only.

Field Type Description
msg_buf void * Address of buf, set by the kernel.
tid Tid Thread ID.
spid Spid ID of the owning space.
prio uint8_t Base priority.
max_prio uint8_t Highest priority the thread may set.
padding uint8_t Pads the header to TCB_HDR_SIZE.
buf uint8_t Message box used by Call(), Reply() and receives.