axf-os161 / kern / include / pid.h
pid.h
Raw
#pragma once

#include <types.h>

struct child_node
{
    pid_t pid;
    struct child_node *next;
};

struct pid_node
{
    pid_t pid;
    pid_t parent_pid;
    struct pid_node *next;
    volatile bool finished;
    struct child_node *child_list;
    struct cv *pid_cv;
    int exit_status;
};

#define PID_KERN 1
#define INVALID_PID 0

struct lock *pid_list_lock;


void pid_bootstrap(void);

int pid_remove(pid_t pid);
int pid_insert_kern(pid_t *pid);
int pid_insert(pid_t *pid);
struct pid_node* pid_get_node(pid_t pid);
int pid_assign_parent(pid_t child_pid, pid_t parent_pid);
int pid_assign_child(pid_t child_pid, pid_t parent_pid);
int pid_remove_child(pid_t child_pid, pid_t parent_pid);
bool pid_is_child(pid_t child_pid, pid_t parent_pid);