65 lines
5.0 KiB
Markdown
65 lines
5.0 KiB
Markdown
|
---
|
||
|
title: "process.h"
|
||
|
summary: "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](https://nerdcult.net/projects/noxos/docs/codebase/proc/process.h/#process_get_thread_idprocess---function-int32_t) 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_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](https://nerdcult.net/projects/noxos/docs/codebase/mm/page_map.h/#page_map_t---struct-page-aligned)* | The processes page map. |
|
||
|
| executable | [elf_executable_T](https://nerdcult.net/projects/noxos/docs/codebase/drivers/elf/elf.h/#elf_executable_t---struct)* | The processes executable |
|
||
|
| 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](https://nerdcult.net/projects/noxos/docs/codebase/proc/process.h/#process_t---struct)* | The process, that spawned this process |
|
||
|
| childs | [process_T](https://nerdcult.net/projects/noxos/docs/codebase/proc/process.h/#process_t---struct)* | A pointer to the processes' first child process |
|
||
|
| prev | [process_T](https://nerdcult.net/projects/noxos/docs/codebase/proc/process.h/#process_t---struct)* | The previous process |
|
||
|
| next | [process_T](https://nerdcult.net/projects/noxos/docs/codebase/proc/process.h/#process_t---struct)* | 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](https://nerdcult.net/projects/noxos/docs/codebase/proc/process.h/#thread_id_invalid---macro).
|
||
|
|
||
|
# `process_clear_thread_id(process, id)` - function (void)
|
||
|
Frees the thread **_id_** and makes it request-able again.
|
||
|
|
||
|
# `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_**.
|