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 {
20 } proc_state_t;
21 
22 typedef struct proc {
25 
28 
29  struct proc *parent;
32 
34 
36  struct proc *proc_waiting;
39 
40  void *page_table;
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);
#define PROC_FD_CAPACITY
Definition: config.h:9
i32 pid_t
Definition: proc.h:8
void proc_ctx_sw(proc_t *old_proc, proc_t *new_proc)
Definition: proc.c:149
struct proc proc_t
proc_state_t
Definition: proc.h:12
@ PROC_STATE_INIT
Definition: proc.h:13
@ PROC_STATE_SLEEP
Definition: proc.h:18
@ PROC_STATE_WAIT_SEM
Definition: proc.h:16
@ PROC_STATE_WAIT_CHILD
Definition: proc.h:17
@ PROC_STATE_ZOMBIE
Definition: proc.h:19
@ PROC_STATE_READY
Definition: proc.h:14
@ PROC_STATE_CURR
Definition: proc.h:15
void proc_adopt(proc_t *new_parent, proc_t *proc)
Definition: proc.c:156
proc_t * proc_table[]
Definition: proc.c:15
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
bool proc_is_bad_fd(const proc_t *proc, i32 fd)
Definition: proc.c:166
void proc_deinit(proc_t *proc)
Definition: proc.c:141
Definition: fd.h:9
Definition: list.h:6
Definition: proc.h:22
pid_t pid
Definition: proc.h:26
struct proc * parent
Definition: proc.h:29
proc_state_t state
Definition: proc.h:35
list_node_t children
Definition: proc.h:30
list_node_t zombie_children
Definition: proc.h:31
usize * user_stack
Definition: proc.h:42
u32 flags
Definition: proc.h:27
list_node_t node
Definition: proc.h:23
struct proc * proc_waiting
Definition: proc.h:36
list_node_t tree_node
Definition: proc.h:24
timer_t timer
Definition: proc.h:37
usize * sp
Definition: proc.h:43
usize * kern_stack
Definition: proc.h:41
fd_t fds[PROC_FD_CAPACITY]
Definition: proc.h:33
i32 exit_status
Definition: proc.h:38
void * page_table
Definition: proc.h:40
Definition: timer.h:6
__INT32_TYPE__ i32
Definition: types.h:15
__UINTPTR_TYPE__ usize
Definition: types.h:28
__UINT32_TYPE__ u32
Definition: types.h:5