// This file is part of noxos and licensed under the MIT open source license #ifndef NOX_PROCESS_H #define NOX_PROCESS_H #include "utils/stdtypes.h" #include "utils/string.h" #include "utils/bitmap.h" #include "proc/file_descriptor.h" #include "proc/pipe.h" #include "mm/page_map.h" #include "drivers/builtin/elf/elf.h" #define MAX_THREADS_PER_PROCESS 64 #define THREAD_ID_INVALID (-1) typedef uint32_t pid_t; typedef enum { PROCESS_NONE, PROCESS_KERNEL } processes_standard_E; typedef enum { PROCESS_BLOCK_WAIT_PIPE_OUT, PROCESS_BLOCK_WAIT_PIPE_IN, PROCESS_BLOCK_ENUM_SIZE } process_blockers_E; typedef enum { PROCESS_SIGNAL_START, // SIGSTART PROCESS_SIGNAL_PAUSE, // SIGPAUSE PROCESS_SIGNAL_KILL, // SIGKILL PROCESS_SIGNAL_PFAULT, // SIGPFAULT } process_signals_E; typedef struct process_T process_T; struct process_T { char name [128]; pid_t id; void* chunk; uint32_t chunk_id; page_map_T* page_map; elf_executable_T* executable; file_descriptor_array_T* fd_array; // driver: If this process is a driver, this tells the ID // of that driver within the driver management system. uint32_t driver; pipe_T* stdout; pipe_T stdin; pipe_T* stderr; bitmap_T waiting; uint32_t num_threads; void* threads; bitmap_T thread_ids; process_T* parent; process_T* childs; // TODO: Must be 'children' process_T* prev; process_T* next; }; void process_kernel_spawn (elf_executable_T* executable); pid_t process_spawn (pid_t parent, string_t name, elf_executable_T* executable, void* buffer); void process_signal (process_T* process, process_signals_E signal); bool process_is_child_of (process_T* process, process_T* parent); int32_t process_get_thread_id (process_T* process); void process_clear_thread_id (process_T* process, uint32_t id); void process_pause_pid (pid_t pid); void process_pause (process_T* process); void process_start_pid (pid_t pid); void process_start (process_T* process); void process_kill_pid (pid_t pid); void process_kill (process_T* process); #endif //NOX_PROCESS_H