kernel/inc/proc/process.h

93 lines
2.8 KiB
C
Raw Permalink Normal View History

// 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_PAGEFAULT, // SIGPAGEFAULT
PROCESS_SIGNAL_MATHFAULT, // SIGMATHFAULT
} process_signals_E;
typedef struct {
file_descriptor_t at_parent;
file_descriptor_t at_child;
}__attribute__((packed)) process_inherit_fd_T;
typedef struct {
uint8_t privilege_level;
char name[80];
file_descriptor_t executable;
uint16_t num_inherit_fds;
process_inherit_fd_T inherit_fds[];
}__attribute__((packed)) process_config_T;
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;
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;
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