fix (proc): documented threads in isolated process setup update

This commit is contained in:
antifallobst 2023-03-08 01:21:41 +01:00
parent c4d09a17ee
commit f6339e7127
1 changed files with 44 additions and 22 deletions

View File

@ -882,14 +882,19 @@ The first 4 digits can be ignored, they are ignored by the MMU,
but for clarity / readability reasons they are `FFFF` in the kernel space. but for clarity / readability reasons they are `FFFF` in the kernel space.
See _General Concepts / Memory Layout_ and _General Concepts / Process Memory Isolation_ for more details. See _General Concepts / Memory Layout_ and _General Concepts / Process Memory Isolation_ for more details.
| Name | Start | Description | | Name | Start | Description |
|----------------------------------|--------------------|-------------------------------------------------------------------------| |----------------------------------|--------------------|---------------------------------------------------|
| `MEM_REGION_PROCESS` | 0x0000000000000000 | This is the start of the process space | | `MEM_REGION_PROCESS` | 0x0000000000000000 | This is the start of the process space |
| `MEM_REGION_PROCESS_EXEC` | 0x0000010000000000 | Every processes' executable will be mapped here | | `MEM_REGION_PROCESS_EXEC` | 0x0000010000000000 | Every processes' executable will be mapped here |
| `MEM_REGION_PROCESS_THREAD_DATA` | 0x0000010100000000 | The start of the thread specific data ( -> _Process Memory Isolation_ ) | | `MEM_REGION_PROCESS_THREAD_BASE` | 0x0000010100000000 | The start of the _Thread Data_ regions |
| `MEM_REGION_KERNEL` | 0xFFFF800000000000 | This is the start of the kernel space | | `MEM_REGION_KERNEL` | 0xFFFF800000000000 | This is the start of the kernel space |
| `MEM_REGION_KERNEL_EXEC` | 0xFFFFFFFF80000000 | The kernel executable is mapped here | | `MEM_REGION_KERNEL_STACK_DUMMY` | 0xFFFFF00000000000 | This area is used when preparing a threads' stack |
| `MEM_REGION_KERNEL_HEAP` | 0xFFFFFFFFF0000000 | The kernels' heap begins here | | `MEM_REGION_KERNEL_HEAP` | 0xFFFFF80000000000 | The kernels' heap begins here |
| `MEM_REGION_KERNEL_THREAD_BASE` | 0xFFFFFF0000000000 | The kernel processes' _Thread Data_ regions |
| `MEM_REGION_KERNELEXEC` | 0xFFFFFFFF80000000 | The kernel executable is mapped here |
#### `MEM_REGION_THREAD_OFFSET` - macro
This time the threads id specifies its offset in its processes' _Thread Data_ region.
#### `KERNEL_START_ADDRESS` - macro #### `KERNEL_START_ADDRESS` - macro
Returns the address of `_kernel_start`. Returns the address of `_kernel_start`.
@ -1258,6 +1263,7 @@ Thread schematics (schedulers view):
| global_next | thread_T* | The next thread in the scheduling queue (**should only be accessed by the scheduler!**) | | global_next | thread_T* | The next thread in the scheduling queue (**should only be accessed by the scheduler!**) |
| local_prev | thread_T* | The previous thread of _process_ (**should only be accessed by the scheduler!**) | | local_prev | thread_T* | The previous thread of _process_ (**should only be accessed by the scheduler!**) |
| local_next | thread_T* | The next thread of _process_ (**should only be accessed by the scheduler!**) | | local_next | thread_T* | The next thread of _process_ (**should only be accessed by the scheduler!**) |
| local_id | uint32_t | The threads id in its process |
#### `thread_spawn(function)` - function (thread_T*) #### `thread_spawn(function)` - function (thread_T*)
@ -1287,6 +1293,14 @@ The threads stack and `thread_T` structure will be freed.
### process.h ### process.h
#### `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 #### `pid_t` - typedef
A typedef for `uint32_t`, used for process identification. A typedef for `uint32_t`, used for process identification.
Such an identification number is also called `pid`. Such an identification number is also called `pid`.
@ -1298,20 +1312,21 @@ These are standard pids
#### `process_T` - struct #### `process_T` - struct
| Name | Type | Description | | Name | Type | Description |
|-------------|-------------------|-----------------------------------------------------------| |-------------|-------------------|-----------------------------------------------------------------|
| name | char[128] | The processes' name | | name | char[128] | The processes' name |
| id | pid_t | The process-identification number | | id | pid_t | The process-identification number |
| chunk | void* | A pointer to the chunk, where the process is stored in | | chunk | void* | A pointer to the chunk, where the process is stored in |
| chunk_id | uint32_t | The processes id inside of its chunk | | chunk_id | uint32_t | The processes id inside of its chunk |
| page_map | page_map_T* | The processes page map. | | page_map | page_map_T* | The processes page map. |
| executable | elf_executable_T* | The processes executable | | executable | elf_executable_T* | The processes executable |
| num_threads | uint32_t | The amount of spawned threads, that belong to the process | | num_threads | uint32_t | The amount of spawned threads, that belong to the process |
| threads | void* | A pointer to the processes' first thread | | threads | void* | A pointer to the processes' first thread |
| parent | process_T* | The process, that spawned this process | | thread_ids | bitmap_T | This bitmap keeps track of the local thread ids the process has |
| childs | process_T* | A pointer to the processes' first child process | | parent | process_T* | The process, that spawned this process |
| prev | process_T* | The previous process | | childs | process_T* | A pointer to the processes' first child process |
| next | process_T* | The next process | | prev | process_T* | The previous process |
| next | process_T* | The next process |
#### `process_kernel_spawn(executable)` - function (void) #### `process_kernel_spawn(executable)` - function (void)
@ -1324,6 +1339,13 @@ 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_**. 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. 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) #### `process_kill_pid(pid)` - function (void)
Resolves the pids process and performs `process_kill` on it. Resolves the pids process and performs `process_kill` on it.