Karg
v0.2.0
The kernel of CargOS
proc.h
Go to the documentation of this file.
1
#pragma once
2
3
#include <
config.h
>
4
#include <
fd.h
>
5
#include <
list.h
>
6
#include <
timer.h
>
7
8
typedef
i32
pid_t
;
9
10
#define PROC_FLAG_KERN 0x1
11
12
typedef
enum
{
13
PROC_STATE_INIT
,
14
PROC_STATE_READY
,
15
PROC_STATE_CURR
,
16
PROC_STATE_WAIT_SEM
,
17
PROC_STATE_WAIT_CHILD
,
18
PROC_STATE_SLEEP
,
19
PROC_STATE_ZOMBIE
,
20
}
proc_state_t
;
21
22
typedef
struct
proc
{
23
list_node_t
node
;
24
list_node_t
tree_node
;
25
26
pid_t
pid
;
27
u32
flags
;
28
29
struct
proc
*
parent
;
30
list_node_t
children
;
31
list_node_t
zombie_children
;
32
33
fd_t
fds
[
PROC_FD_CAPACITY
];
34
35
proc_state_t
state
;
36
struct
proc
*
proc_waiting
;
37
timer_t
timer
;
38
i32
exit_status
;
39
40
void
*
page_table
;
41
usize
*
kern_stack
;
42
usize
*
user_stack
;
43
usize
*
sp
;
44
}
proc_t
;
45
46
extern
proc_t
*
proc_table
[];
47
48
i32
proc_init
(
proc_t
*
proc
,
void
*entry,
u32
flags
,
proc_t
*
parent
,
i32
argc,
49
const
char
**argv,
void
*
page_table
);
50
void
proc_deinit
(
proc_t
*
proc
);
51
void
proc_ctx_sw
(
proc_t
*old_proc,
proc_t
*new_proc);
52
void
proc_adopt
(
proc_t
*new_parent,
proc_t
*
proc
);
53
bool
proc_is_bad_fd
(
const
proc_t
*
proc
,
i32
fd);
config.h
PROC_FD_CAPACITY
#define PROC_FD_CAPACITY
Definition:
config.h:9
fd.h
list.h
pid_t
i32 pid_t
Definition:
proc.h:8
proc_ctx_sw
void proc_ctx_sw(proc_t *old_proc, proc_t *new_proc)
Definition:
proc.c:149
proc_t
struct proc proc_t
proc_state_t
proc_state_t
Definition:
proc.h:12
PROC_STATE_INIT
@ PROC_STATE_INIT
Definition:
proc.h:13
PROC_STATE_SLEEP
@ PROC_STATE_SLEEP
Definition:
proc.h:18
PROC_STATE_WAIT_SEM
@ PROC_STATE_WAIT_SEM
Definition:
proc.h:16
PROC_STATE_WAIT_CHILD
@ PROC_STATE_WAIT_CHILD
Definition:
proc.h:17
PROC_STATE_ZOMBIE
@ PROC_STATE_ZOMBIE
Definition:
proc.h:19
PROC_STATE_READY
@ PROC_STATE_READY
Definition:
proc.h:14
PROC_STATE_CURR
@ PROC_STATE_CURR
Definition:
proc.h:15
proc_adopt
void proc_adopt(proc_t *new_parent, proc_t *proc)
Definition:
proc.c:156
proc_table
proc_t * proc_table[]
Definition:
proc.c:15
proc_init
i32 proc_init(proc_t *proc, void *entry, u32 flags, proc_t *parent, i32 argc, const char **argv, void *page_table)
Definition:
proc.c:93
proc_is_bad_fd
bool proc_is_bad_fd(const proc_t *proc, i32 fd)
Definition:
proc.c:166
proc_deinit
void proc_deinit(proc_t *proc)
Definition:
proc.c:141
fd_t
Definition:
fd.h:9
list_node
Definition:
list.h:6
proc
Definition:
proc.h:22
proc::pid
pid_t pid
Definition:
proc.h:26
proc::parent
struct proc * parent
Definition:
proc.h:29
proc::state
proc_state_t state
Definition:
proc.h:35
proc::children
list_node_t children
Definition:
proc.h:30
proc::zombie_children
list_node_t zombie_children
Definition:
proc.h:31
proc::user_stack
usize * user_stack
Definition:
proc.h:42
proc::flags
u32 flags
Definition:
proc.h:27
proc::node
list_node_t node
Definition:
proc.h:23
proc::proc_waiting
struct proc * proc_waiting
Definition:
proc.h:36
proc::tree_node
list_node_t tree_node
Definition:
proc.h:24
proc::timer
timer_t timer
Definition:
proc.h:37
proc::sp
usize * sp
Definition:
proc.h:43
proc::kern_stack
usize * kern_stack
Definition:
proc.h:41
proc::fds
fd_t fds[PROC_FD_CAPACITY]
Definition:
proc.h:33
proc::exit_status
i32 exit_status
Definition:
proc.h:38
proc::page_table
void * page_table
Definition:
proc.h:40
timer_t
Definition:
timer.h:6
timer.h
i32
__INT32_TYPE__ i32
Definition:
types.h:15
usize
__UINTPTR_TYPE__ usize
Definition:
types.h:28
u32
__UINT32_TYPE__ u32
Definition:
types.h:5
include
proc.h
Generated by
1.9.1