std1.0.0-beta-7 SafeC docs

std :: kernel::process

Struct std::PCB

#include <std/kernel/process.h> source

struct PCB {
    int pid;
    int state;
    int priority;
    unsigned long stack_ptr;
    unsigned long pc;
    unsigned long page_table;
    int parent_pid;
    int exit_code;
}

Fields

§int pidsource

process ID

§int statesource

PROC_READY, PROC_RUNNING, etc.

§int prioritysource

scheduling priority (higher = more important)

§unsigned long stack_ptrsource

saved stack pointer

§unsigned long pcsource

saved program counter

§unsigned long page_tablesource

physical address of page table root

§int parent_pidsource

parent process ID (-1 if none)

§int exit_codesource

exit code (valid when ZOMBIE)

Methods

§void set_state(int state)source · definition

Set process state.

§void set_priority(int priority)source · definition

Set process priority.

§void save_context(unsigned long sp, unsigned long pc)source · definition

Save context (stack pointer + program counter).

§void exit(int exit_code)source · definition

Mark process as zombie with the given exit code.

§static struct PCB new( int pid, unsigned long entry, unsigned long sp, unsigned long page_table, )source · definition

Initialize a PCB with the given pid, entry point, and stack.