|
PatchworkOS
19e446b
A non-POSIX operating system.
|
Process management. More...
Process management.
Processes store the shared resources for threads of execution, for example the address space and open files.
Modules | |
| Environment | |
| Environment variables. | |
| Process groups | |
| Process groups. | |
| Process reaper | |
| Process reaper for delayed process freeing. | |
Data Structures | |
| struct | process_threads_t |
| Represents the threads in a process. More... | |
| struct | process_status_t |
| Process exit status structure. More... | |
| struct | process_t |
| Process structure. More... | |
Macros | |
| #define | PROCESS_STATUS_MAX 256 |
| Maximum length of a process exit status. | |
| #define | PROCESS_RCU_THREAD_FOR_EACH(thread, process) LIST_FOR_EACH(thread, &(process)->threads.list, processEntry) |
| Macro to iterate over all threads in a process. | |
| #define | PROCESS_RCU_FOR_EACH(process) LIST_FOR_EACH(process, &_processes, entry) |
| Macro to iterate over all processes. | |
Enumerations | |
| enum | process_flags_t { PROCESS_NONE = 0 , PROCESS_DYING = 1 << 0 , PROCESS_SUSPENDED = 1 << 1 } |
| Process flags enum. More... | |
Functions | |
| process_t * | process_new (priority_t priority, group_member_t *group, namespace_t *ns) |
| Allocates and initializes a new process. | |
| static process_t * | process_current (void) |
| Retrieves the process of the currently running thread. | |
| static process_t * | process_current_unsafe (void) |
| Retrieves the process of the currently running thread without disabling interrupts. | |
| process_t * | process_get (pid_t id) |
| Gets a process by its ID. | |
| namespace_t * | process_get_ns (process_t *process) |
| Gets the namespace of a process. | |
| void | process_set_ns (process_t *process, namespace_t *ns) |
| Sets the namespace of a process. | |
| void | process_kill (process_t *process, const char *status) |
| Kills a process, pushing it to the reaper. | |
| void | process_remove (process_t *process) |
| Removes a process from the system. | |
| static thread_t * | process_rcu_first_thread (process_t *process) |
| Gets the first thread of a process. | |
| static uint64_t | process_rcu_thread_count (process_t *process) |
| Gets the amount of threads in a process. | |
| uint64_t | process_set_cmdline (process_t *process, char **argv, uint64_t argc) |
| Sets the command line arguments for a process. | |
| bool | process_has_thread (process_t *process, tid_t tid) |
| Checks if a process has a thread with the specified thread ID. | |
| process_t * | process_get_kernel (void) |
| Gets the kernel process. | |
Variables | |
| list_t | _processes |
| Global list of all processes. | |
| #define PROCESS_STATUS_MAX 256 |
| #define PROCESS_RCU_THREAD_FOR_EACH | ( | thread, | |
| process | |||
| ) | LIST_FOR_EACH(thread, &(process)->threads.list, processEntry) |
| #define PROCESS_RCU_FOR_EACH | ( | process | ) | LIST_FOR_EACH(process, &_processes, entry) |
| enum process_flags_t |
| process_t * process_new | ( | priority_t | priority, |
| group_member_t * | group, | ||
| namespace_t * | ns | ||
| ) |
Allocates and initializes a new process.
It is the responsibility of the caller to UNREF() the returned process.
| priority | The priority of the new process. |
| group | A member of the group to add the new process to, or NULL to create a new group for the process. |
| ns | The namespace to use for the new process. |
NULL and errno is set. Definition at line 125 of file process.c.
|
inlinestatic |
Retrieves the process of the currently running thread.
Definition at line 131 of file process.h.
|
inlinestatic |
Retrieves the process of the currently running thread without disabling interrupts.
Definition at line 145 of file process.h.
Gets a process by its ID.
It is the responsibility of the caller to UNREF() the returned process.
| id | The ID of the process to get. |
NULL if no such process exists. Definition at line 192 of file process.c.
| namespace_t * process_get_ns | ( | process_t * | process | ) |
Gets the namespace of a process.
It is the responsibility of the caller to UNREF() the returned namespace.
| process | The process to get the namespace of. |
NULL and errno is set:EINVAL: Invalid parameters. Definition at line 206 of file process.c.
| void process_set_ns | ( | process_t * | process, |
| namespace_t * | ns | ||
| ) |
| void process_kill | ( | process_t * | process, |
| const char * | status | ||
| ) |
Kills a process, pushing it to the reaper.
The process will still exist until the reaper removes it.
| process | The process to kill. |
| status | The exit status of the process. |
Definition at line 240 of file process.c.
| void process_remove | ( | process_t * | process | ) |
Gets the first thread of a process.
| process | The process to get the first thread of. |
NULL if the process has no threads. Definition at line 206 of file process.h.
Sets the command line arguments for a process.
This value is only used for the /proc/[pid]/cmdline file.
| process | The process to set the cmdline for. |
| argv | The array of argument strings. |
| argc | The number of arguments. |
0. On failure, ERR and errno is set to:EINVAL: Invalid parameters.ENOMEM: Out of memory. Definition at line 294 of file process.c.
| process_t * process_get_kernel | ( | void | ) |
Gets the kernel process.
The kernel process will be initalized lazily on the first call to this function, which should happen during early boot.
Will never return NULL and will not increment the reference count of the returned process.
Definition at line 374 of file process.c.
|
extern |
Global list of all processes.