Mercurial > lcfOS
view kernel/process.c3 @ 408:ad6be5454067
Added image build task
author | Windel Bouwman |
---|---|
date | Sat, 21 Feb 2015 12:17:47 +0100 |
parents | 9eb1fc6aad6c |
children | 6aa9743ed362 |
line wrap: on
line source
module process; import memory; import kernel; // process type definition: type struct { int id; int status; process_t* next; process_t* prev; } process_t; var process_t* first_process; var process_t* last_process; var int next_pid; var process_t* current; function void init() { next_pid = 0; first_process = 0; last_process = 0; } /* Create a new process. */ function process_t* create() { var process_t* p; p = memory.alloc(sizeof(process_t)); p->id = next_pid; p->status = 0; // Ready! p->next = 0; p->prev = 0; // Increment PID: next_pid = next_pid + 1; return p; } function void enqueue(process_t* p) { // Store it in the list: if (first_process == cast<process_t*>(0)) { first_process = p; last_process = p; } else { // Update pointers: last_process->next = p; p->prev = last_process; last_process = p; } } function void kill(process_t* p) { // clean memory } function process_t* byId(int id) { // Perform lookup return 0; } function void execute_next() { var process.process_t *old; old = 0; if (old != current) { //execute(current); } kernel.panic(); }