This repository has been archived on 2023-09-28. You can view files and clone it, but cannot push or open issues or pull requests.
homepage/content/projects/noxos/docs/codebase/proc/process.h.md

7.2 KiB

title summary
process.h processes are the containers, in which threads are organized

MAX_THREADS_PER_PROCESS - macro

The maximum amount of threads a process can have. This limitation is just for the bitmap, the overall processing structure would be capable of processes with unlimited threads, in theory.

THREAD_ID_INVALID - macro

If process_get_thread_id returns this, the process can't spawn one more thread.

pid_t - typedef

A typedef for uint32_t, used for process identification. Such an identification number is also called pid.

processes_standard_E - enum

These are standard pids

  • None - This pid is invalid, like NULL is an invalid pointer
  • Kernel - The kernels' main process

process_blockers_E - enum

  • PIPE_OUT - This blocker becomes activated, when the process tries to write to a pipe, but the pipe has not enough space for the data. It becomes deactivated, when the pipe has space to fit the rest of the data.
  • PIPE_IN - This blocker becomes activated, when the process tries to read from a pipe, but the pipe has not the requested amount of data. It becomes deactivated, when the pipe contains data again.

process_T - struct

Name Type Description
name char[128] The processes' name
id pid_t The process-identification number
chunk void* A pointer to the chunk, where the process is stored in
chunk_id uint32_t The processes id inside of its chunk
page_map page_map_T* The processes page map.
executable elf_executable_T* The processes executable
fd_array file_descriptor_array_T* Contains the open file descriptors of the process.
stdout pipe_T* Pointer to the pipe, where stdout writes to.
stdin pipe_T The pipe, where stdin reads from.
stderr pipe_T* Pointer to the pipe, where stderr writes to.
waiting bitmap_T A bitmap of process blockers. If this is greater 0 the process is blocked by something.
num_threads uint32_t The amount of spawned threads, that belong to the process
threads void* A pointer to the processes' first thread
thread_ids bitmap_T(reference needed) This bitmap keeps track of the local thread ids the process has
parent process_T* The process, that spawned this process
childs process_T* A pointer to the processes' first child process
prev process_T* The previous process
next process_T* The next process

process_kernel_spawn(executable) - function (void)

Spawns the kernels' main process.

Warning: this should only be called once, when initializing the scheduler!

process_spawn(parent, name, executable, buffer) - function (pid_t)

Spawns a process named name as child of parent and returns its pid. The process gets its own page map with the mappings specified in executable. In order to apply these mappings, this function needs the buffer where the executable was loaded from.

process_get_thread_id(process) - function (int32_t)

Searches for a free thread id in the process. If it finds one it returns it, else it returns THREAD_ID_INVALID.

process_clear_thread_id(process, id) - function (void)

Frees the thread id and makes it request-able again.

process_pause_pid(pid) - function (void)

Resolves the pids process and performs process_pause on it.

process_pause(process) - function (void)

Pauses process and all of its threads.

process_start_pid(pid) - function (void)

Resolves the pids process and performs process_start on it.

process_start(process) - function (void)

Starts process and all of its threads.

process_kill_pid(pid) - function (void)

Resolves the pids process and performs process_kill on it.

process_kill(process) - function (void)

Kills process and all of its threads and child processes. This will also destruct the executable and page_map associated with process.