view kernel/process.c3 @ 292:534b94b40aa8

Fixup reorganize
author Windel Bouwman
date Wed, 27 Nov 2013 08:06:42 +0100
parents c9781c73e7e2
children 917eab04b8b7
line wrap: on
line source

module process;
import memory;
import kernel;

// process type definition:
typedef struct {
    int id;
    int status;
} process_t;

// Or, use this list structure:
List<process_t> procs;

// init is the root of all processes:
var process_t* init = 0;
var int next_pid = 0;

public func void Init()
{
    next_pid = 0;
    init = Create();
}

/*
    Create a new process.
*/
public func process_t* Create()
{
    process_t* p = memory.Alloc(sizeof(process_t));
    p->id = next_pid;
    next_pid++;
    return p;
}


public func void Kill(process_t* p)
{
    // clean memory
}

public process_t* byId(int id)
{
    // Perform lookup
    return 0;
}