22#define KERNEL_STACK_SIZE (2 * PAGE_SIZE)
51#define PROCESS_NAME_MAX 32
#define ARCH_FPU_STATE_SIZE
Definition arch.h:284
#define FD_MAX
Definition fd_table.h:16
struct fd_table fd_table_t
the descriptors of a process.
uint32_t fs
Definition gdt.c:22
struct signal_handlers signal_handlers_t
what a process does with each signal.
struct file file_t
Definition file.h:38
unsigned int uint32_t
Definition fb.h:17
unsigned char uint8_t
Definition fb.h:18
__UINT64_TYPE__ uint64_t
Definition stdint.h:17
int int32_t
Definition stdint.h:14
__UINTPTR_TYPE__ uintptr_t
Definition stdint.h:19
void process_set_current(process_t *proc)
set the currently running process.
Definition process.c:270
void fs_context_put(fs_context_t *fs)
remove a user from an fs context; the last user frees it.
Definition process.c:327
bool process_group_exists(uint32_t pgid, uint32_t sid)
true if some live process is in the group and the session.
Definition process.c:540
void process_note_orphan_zombie(void)
record that an orphan (no parent) has become a zombie and must be reaped by the kernel.
Definition process.c:440
bool process_info(uint32_t pid, process_info_t *info)
copy what procfs shows about a process, safely against its exit.
Definition process.c:588
void process_sync_threads(process_t *proc)
give every other thread of a process's group its user and group ids, its process group and its sessio...
Definition process.c:773
void process_take_leader(process_t *proc)
make a thread the leader of its group in place of the old leader, which has ended (a zombie) and is t...
Definition process.c:796
process_t * process_clone_thread(const struct registers *regs, uintptr_t stack)
make a thread of the current process: a new task in its group that shares its memory,...
Definition process.c:167
uint64_t process_idle_ticks(void)
the timer ticks that the cores spent in their idle loops since boot, added over all cores.
Definition process.c:646
void process_orphan_children(process_t *parent)
detach the children of an exiting group (call when its last thread ends; parent is that thread): zomb...
Definition process.c:392
process_t * process_pick_thread(uint32_t tgid, uint32_t mask)
choose the thread of a group that takes a signal sent to the process: the leader if it does not block...
Definition process.c:746
process_t * process_fork(const struct registers *regs)
fork the current process.
Definition process.c:201
void process_release_resources(process_t *proc)
release what a process owns apart from its kernel stack and table slot: close its fds,...
Definition process.c:292
uint32_t process_list_group(uint32_t pgid, uint32_t *pids, uint32_t max)
list the pids of a process group.
Definition process.c:518
void process_signal_threads(uint32_t tgid, process_t *except, int sig)
send a signal to the threads of a group (signal_send to each).
Definition process.c:721
void process_copy_credentials(process_t *child, const process_t *parent)
give a new process the user and group ids and umask of another.
Definition process.c:685
void process_destroy(process_t *proc)
destroy a process and free its slot in the process table.
Definition process.c:339
void process_reap_orphans(void)
destroy orphan zombies.
Definition process.c:445
process_t * process_get(uint32_t pid)
look up a process by PID.
Definition process.c:697
void process_set_name(process_t *proc, const char *path)
set a process's name from a program path (its last component).
Definition process.c:627
void process_account_tick(bool user)
charge one timer tick to the current process (timer interrupt).
Definition process.c:657
void process_for_each(void(*fn)(process_t *proc, void *ctx), void *ctx)
call fn for every process in the table, with the table locked and interrupts masked: fn must not slee...
Definition process.c:558
void process_init(void)
initialize the process subsystem.
Definition process.c:98
fs_context_t * fs_context_get(fs_context_t *fs)
add a user to an fs context (a new thread that shares it).
Definition process.c:321
process_t * process_create(void)
create a new process and return its PCB.
Definition process.c:137
process_t * process_current(void)
get the currently running process.
Definition process.c:265
uint32_t process_list_pids(uint32_t *pids, uint32_t max)
list the pids in use.
Definition process.c:571
process_t * process_find_waitable_child(process_t *parent, int32_t pid, uint32_t options, bool *has_child)
find a child of a process that has something for waitpid: it exited (a zombie), or,...
Definition process.c:479
struct process process_t
process control block.
struct fs_context fs_context_t
where paths start, and the mode bits new files lose.
process_state_t
process states.
Definition process.h:28
@ PROC_STATE_BLOCKED
Definition process.h:33
@ PROC_STATE_UNUSED
Definition process.h:29
@ PROC_STATE_ZOMBIE
Definition process.h:34
@ PROC_STATE_READY
Definition process.h:32
@ PROC_STATE_RUNNING
Definition process.h:31
@ PROC_STATE_NEW
Definition process.h:30
@ PROC_STATE_STOPPED
Definition process.h:35
wait_report_t
a change of a child that waitpid has not reported yet.
Definition process.h:42
@ WAIT_REPORT_NONE
Definition process.h:43
@ WAIT_REPORT_CONTINUED
Definition process.h:45
@ WAIT_REPORT_STOPPED
Definition process.h:44
#define PATH_MAX
Definition process.h:48
#define PROCESS_NAME_MAX
Definition process.h:51
where paths start, and the mode bits new files lose.
Definition process.h:58
char root[PATH_MAX]
Definition process.h:62
char cwd[PATH_MAX]
Definition process.h:61
volatile uint32_t users
Definition process.h:59
uint32_t umask
Definition process.h:60
a copy of what procfs shows about a process.
Definition process.h:328
uint32_t utime
Definition process.h:337
uint32_t uid
Definition process.h:336
uintptr_t brk
Definition process.h:335
uint32_t pages
Definition process.h:339
uint32_t areas
Definition process.h:333
uint32_t pid
Definition process.h:329
process_state_t state
Definition process.h:331
char name[PROCESS_NAME_MAX]
Definition process.h:332
uint32_t stime
Definition process.h:338
uint32_t open_fds
Definition process.h:334
uint32_t parent_pid
Definition process.h:330
process control block.
Definition process.h:69
user_space_t * space
Definition process.h:93
int32_t exit_status
Definition process.h:95
uintptr_t entry
Definition process.h:98
uint32_t sgid
Definition process.h:90
struct process * leader
Definition process.h:73
uint8_t fpu_state[ARCH_FPU_STATE_SIZE] __attribute__((aligned(16)))
uint32_t parent_pid
Definition process.h:84
uint32_t stime
Definition process.h:133
uint32_t uid
Definition process.h:89
uintptr_t tls
Definition process.h:81
wait_report_t wait_report
Definition process.h:131
struct process * exec_thread
Definition process.h:78
uint32_t cstime
Definition process.h:135
uintptr_t kernel_esp
Definition process.h:97
file_t * held_files[FD_MAX]
Definition process.h:146
fs_context_t * fs
Definition process.h:142
fd_table_t * files
Definition process.h:144
uintptr_t kernel_stack
Definition process.h:96
uint32_t utime
Definition process.h:132
uintptr_t clear_tid
Definition process.h:82
uintptr_t fault_addr
Definition process.h:136
uint32_t held_count
Definition process.h:147
volatile uint32_t threads
Definition process.h:75
volatile bool on_cpu
Definition process.h:102
uint32_t pgid
Definition process.h:87
uint32_t gid
Definition process.h:90
bool group_exiting
Definition process.h:76
int32_t group_status
Definition process.h:80
uint32_t suid
Definition process.h:89
signal_state_t signals
Definition process.h:123
bool fault_write
Definition process.h:137
char name[PROCESS_NAME_MAX]
Definition process.h:141
uint32_t cpu
Definition process.h:103
uint32_t egid
Definition process.h:90
bool reaped
Definition process.h:101
struct process * ready_next
Definition process.h:107
wait_queue_t * waiting_on
Definition process.h:115
volatile uint32_t child_events
Definition process.h:100
uint32_t syscall_nr
Definition process.h:126
uint64_t alarm_deadline
Definition process.h:127
uint8_t stop_signal
Definition process.h:129
char ** argv
Definition process.h:104
uint32_t sid
Definition process.h:88
wait_queue_t child_exit
Definition process.h:99
uint32_t euid
Definition process.h:89
uint32_t pid
Definition process.h:70
bool futex_woken
Definition process.h:121
struct process * ready_prev
Definition process.h:108
signal_handlers_t * handlers
Definition process.h:124
struct user_space * futex_space
Definition process.h:119
bool group_stopped
Definition process.h:77
uint32_t cutime
Definition process.h:134
struct process * wait_next
Definition process.h:114
bool interruptible
Definition process.h:116
uintptr_t futex_addr
Definition process.h:120
int32_t nice
Definition process.h:91
uint32_t tgid
Definition process.h:71
process_state_t state
Definition process.h:92
saved register state pushed onto the stack by ISR stubs.
Definition isr.h:41
the signal state of a process (inside process_t).
Definition signal.h:78
the user half of an address space: the page tables, the areas (vma.h) and the program break.
Definition user_space.h:16
a queue of blocked processes, linked through process_t::wait_next.
Definition wait_queue.h:35
struct user_space user_space_t
the user half of an address space: the page tables, the areas (vma.h) and the program break.