|
My Kernel v0.1.0
|

Modules | |
| Processes - x86 | |
| Processes - arch specifics | |
Data Structures | |
| struct | process |
| A single process. More... | |
| struct | thread |
| A single thread. More... | |
Macros | |
| #define | PROCESS_NAME_MAX_LEN 32U |
| The max length of a process's name. | |
| #define | PROCESS_FD_COUNT 32 |
| Maximum number of files that one process can have open at any one time. | |
Typedefs | |
| typedef void(* | thread_entry_t) (void *data) |
| A function used as an entry point when creating a new thread. More... | |
Enumerations | |
| enum | thread_state { SCHED_RUNNING , SCHED_WAITING , SCHED_KILLED } |
| The different states a thread can be in. More... | |
| enum | thread_flags { THREAD_KERNEL = BIT(0) } |
Functions | |
| static ALWAYS_INLINE bool | thread_is_initial (thread_t *thread) |
| The initial thread is the thread created along with the process. More... | |
| static void | thread_set_stack_pointer (struct thread *thread, void *stack) |
| Set the thread's current stack pointer. | |
| static void * | thread_get_stack_pointer (struct thread *thread) |
| Get the thread's current stack pointer. | |
| static void | thread_set_kernel_stack (struct thread *thread, void *stack) |
| Set the thread's kernel stack bottom address. | |
| static void * | thread_get_kernel_stack_top (const struct thread *thread) |
| Get the thread's kernel stack top address. | |
| static void * | thread_get_kernel_stack (const struct thread *thread) |
| Get the thread's kernel stack bottom address. | |
| static void | thread_set_user_stack (struct thread *thread, void *stack) |
| Set the thread's user stack bottom address. | |
| static void * | thread_get_user_stack_top (const struct thread *thread) |
| Get the thread's user stack top address. | |
| static void * | thread_get_user_stack (const struct thread *thread) |
| Get the thread's user stack bottom address. | |
| void | process_init_kernel_process (void) |
| Initialize the kernel process's address space. More... | |
| int | process_register_file (struct process *, struct file *) |
| Register an open file inside the process's open file descriptor table. More... | |
| error_t | process_unregister_file (struct process *, int fd) |
| Remove an open file from the process's open file descriptor table. | |
| struct file * | process_file_get (struct process *, int fd) |
| static void | process_file_put (struct process *process, struct file *file) |
| Release a file description retreived using process_file_get(). | |
| struct thread * | process_execute_in_userland (const char *exec_path) |
| Run an executable. More... | |
| bool | thread_switch (thread_t *) |
| Switch the currently running thread. More... | |
| thread_t * | thread_spawn (struct process *, thread_entry_t, void *, void *, u32) |
| Create and initialize a new thread. More... | |
| NO_RETURN void | thread_jump_to_userland (thread_entry_t, void *) |
| Start executing code in userland. More... | |
| void | thread_set_mmu (struct thread *thread, paddr_t mmu) |
| Set the MMU address saved inside the thread's structure. More... | |
| void | thread_kill (thread_t *) |
| Effectively kill a thread. More... | |
| struct thread * | thread_fork (struct thread *, thread_entry_t, void *) |
| Create a new fork of the given thread. More... | |
Variables | |
| struct process | kernel_process |
| Process used when starting up the kernel. More... | |
| struct process * | init_process |
| The init process is the very first executed userland process. More... | |
| thread_t * | current |
| The currently running thread. | |
| typedef void(* thread_entry_t) (void *data) |
| data | Generic data passed on to the function when starting the thread |
| enum thread_flags |
| enum thread_state |
| struct thread * process_execute_in_userland | ( | const char * | exec_path | ) |
As the kernel should never run external executables, this function instead creates a new userland process that will in turn be used to execute the executable.
| exec_path | Absolute path to the executable file |
| void process_init_kernel_process | ( | void | ) |
The kernel process's instance being defined satically, it is required to be explicitely initialize during the startup phase so that it can be used just like any other process later on.
| struct thread * thread_fork | ( | struct thread * | thread, |
| thread_entry_t | entrypoint, | ||
| void * | arg | ||
| ) |
A new process is created to execute the forked thread. The address space of the original thread's process is duplicated inside the newly created process.
If the duplicated process had multiple threads, only the one that called this function is replicated.
|
static |
The TID of the initial thread is the same as its process's PID.
| NO_RETURN void thread_jump_to_userland | ( | thread_entry_t | entrypoint, |
| void * | data | ||
| ) |
This function resets the user execution context (eip, stack content). It then changes the privilege level to be that of userland, and jumps onto the given address.
@info This serves as a temporary equivalent to the execve syscall for testing purposes.
| entrypoint | The entrypoint address to jump onto |
| data | The data passed as an argument to the 'entrypoint' function (ignored) |
| void thread_kill | ( | thread_t * | thread | ) |
| void thread_set_mmu | ( | struct thread * | thread, |
| paddr_t | mmu | ||
| ) |
| thread_t * thread_spawn | ( | struct process * | process, |
| thread_entry_t | entrypoint, | ||
| void * | data, | ||
| void * | esp, | ||
| u32 | flags | ||
| ) |
When starting a userland thread, the data field is not passed to the entrypoint function.
| process | The process the newly created thread belongs to |
| entrypoint | The function called when starting the thread |
| data | Data passed to the entry function (can be NULL) |
| esp | The value to place inside the stack pointer register before first kicking off the thread. This is mainly useful when forking an existing thread. Ignored if NULL. |
| flags | Feature flags: a combination of thread_flags enum values |
| bool thread_switch | ( | thread_t * | thread | ) |
| process | The new thread to switch into |
false if the new thread was previously killed
|
extern |
It is the parent of all other userland processes, and all zombie processes are attached to it when their parent dies.
The init process uses the reserved PID 1.
|
extern |
It is necesary to define it statically, since memory management functions are not yet set up when first starting up.
We should not reference this process anymore once we have an up and running scheduler.