aboutsummaryrefslogtreecommitdiff
path: root/src/kernel/tasks/process.h
blob: 9aae9bcd959f1f72355a6e687880e60d3a57529d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#ifndef MELVIX_PROCESS_H
#define MELVIX_PROCESS_H

#include <stdint.h>
#include <memory/paging.h>
#include <interrupts/interrupts.h>

struct mmap {
	u32 text;
	u32 bss;
	u32 data;
	u32 stack;
};

struct process {
	struct page_directory *cr3;
	struct regs registers;

	u32 pid;
	u32 gid;
	char *name;

	int state;
	int thread;

	u32 stdin;
	u32 stdout;
	u32 stderr;

	u32 brk;
	u32 handlers[6];

	struct process *parent;
	struct process *next;
};

void scheduler(struct regs *regs);

void process_kill(u32 pid);

u32 process_spawn(struct process *process);

void process_suspend(u32 pid);
void process_wake(u32 pid);
u32 process_child(struct process *process, u32 pid);
u32 process_fork(u32 pid);

u32 process_wait_gid(u32 gid, u32 *status);
u32 process_wait_pid(u32 pid, u32 *status);

struct process *process_from_pid(u32 pid);

void process_init(struct process *proc);

struct process *process_make_new();

u32 kexec(char *path);

u32 uexec(char *path);

extern struct process *current_proc;

extern u32 stack_hold;

#define PID_NOT_FOUND ((struct process *)0xFFFFFFFF)

#define PROC_RUNNING 0
#define PROC_ASLEEP 1

#define PROC_THREAD 0
#define PROC_PROC 1
#define PROC_ROOT 2

#define WAIT_ERROR (-1)
#define WAIT_OKAY 0

#endif