5.0 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_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 |
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_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.