VAIOS

Task Model

VAIOS follows a task-based execution model, where each unit of execution is represented as an independent task managed by the kernel. Each task is described by a Task Control Block (TCB), which stores all information required for scheduling, context switching, and lifecycle management.

Memory layout of the VAIOS Task Control Block (TCB) showing field groupings by functional role.

The TCB , shown in Fig. 6.2, maintains the execution context of a task, including the current stack pointer, stack memory base, entry function, and argument. It also stores scheduling-related metadata such as priority, delay information, and runtime statistics. Additional fields are used for tracking synchronization state, linking tasks within scheduling lists, and ensuring system integrity through sanity checks. This structure enables efficient context switching and flexible task management while keeping all relevant task information localized.

Each task is allocated a separate stack at creation time using the system memory allocator. The stack is initialized to simulate an exception return frame, allowing the task to start execution through the same mechanism used during context switching. This design ensures a uniform execution model and simplifies the scheduler implementation. Stack isolation also prevents interference between tasks and allows independent execution.

The lifecycle of a task is defined through a set of states: READY, RUNNING, BLOCKED, DELAYED, and TERMINATED. Tasks in the READY state are maintained in priority-specific queues and are eligible for execution. The RUNNING state corresponds to the currently executing task. Tasks enter the BLOCKED state when waiting for synchronization primitives such as semaphores or mutexes, while the DELAYED state is used for time-based suspension using system ticks. Once execution is complete or explicitly terminated, tasks transition to the TERMINATED state and are later cleaned up by the system.

Task creation involves allocating memory for both the TCB and its stack, initializing the execution context, and inserting the task into the appropriate ready queue. The system maintains separate lists for ready, blocked, and delayed tasks, allowing efficient state transitions and scheduling decisions. Tasks can be dynamically delayed, blocked, or unblocked through kernel APIs, enabling flexible control over execution flow.

An idle task is always present in the system and is scheduled when no other tasks are ready to execute. In addition to occupying the processor during idle periods, it performs background operations such as reclaiming memory from terminated tasks, ensuring that resource cleanup does not interfere with active task execution.