blob: 0e02d27754b1529e7b2a424e2365844246097c83 (
plain)
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
|
#pragma once
#include <kernel/arch/generic.h>
#include <kernel/handle.h>
#include <kernel/vfs/mount.h>
#include <shared/syscalls.h>
enum process_state {
PS_RUNNING,
PS_DEAD, // return message wasn't collected
PS_DEADER, // return message was collected
PS_WAITS4CHILDDEATH,
PS_WAITS4FS,
PS_WAITS4REQUEST,
};
struct process {
struct pagedir *pages;
struct registers regs;
enum process_state state;
struct process *sibling;
struct process *child;
struct process *parent;
uint32_t id; // only for debugging, don't expose to userland
// saved value, meaning depends on .state
union {
struct { // PS_DEAD, PS_WAITS4CHILDDEATH
char __user *buf;
size_t len;
} death_msg;
struct vfs_request pending_req; // PS_WAITS4FS
struct {
char __user *buf;
int max_len;
struct fs_wait_response __user *res;
} awaited_req; // PS_WAITS4REQUEST
};
struct vfs_request *handled_req;
struct vfs_mount *mount;
struct handle handles[HANDLE_MAX];
};
extern struct process *process_first;
extern struct process *process_current;
// creates the root process
struct process *process_seed(void);
struct process *process_fork(struct process *parent);
_Noreturn void process_switch(struct process *proc);
_Noreturn void process_switch_any(void); // switches to any running process
struct process *process_find(enum process_state);
handle_t process_find_handle(struct process *proc); // finds the first free handle
|