2023-03-10 10:32:50 +00:00
|
|
|
// This file is part of noxos and licensed under the MIT open source license
|
2023-03-03 19:23:19 +00:00
|
|
|
|
|
|
|
#ifndef NOX_PROCESS_H
|
|
|
|
#define NOX_PROCESS_H
|
|
|
|
|
|
|
|
#include "utils/stdtypes.h"
|
|
|
|
#include "utils/string.h"
|
2023-03-08 00:01:12 +00:00
|
|
|
#include "utils/bitmap.h"
|
2023-04-18 23:02:45 +00:00
|
|
|
#include "proc/file_descriptor.h"
|
2023-04-27 10:27:12 +00:00
|
|
|
#include "proc/pipe.h"
|
2023-03-04 16:46:21 +00:00
|
|
|
#include "mm/page_map.h"
|
|
|
|
#include "drivers/elf/elf.h"
|
2023-03-03 19:23:19 +00:00
|
|
|
|
2023-03-08 00:01:12 +00:00
|
|
|
#define MAX_THREADS_PER_PROCESS 64
|
|
|
|
#define THREAD_ID_INVALID (-1)
|
|
|
|
|
2023-03-03 19:23:19 +00:00
|
|
|
typedef uint32_t pid_t;
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
PROCESS_NONE,
|
|
|
|
PROCESS_KERNEL
|
|
|
|
} processes_standard_E;
|
|
|
|
|
2023-04-27 10:27:12 +00:00
|
|
|
typedef enum {
|
|
|
|
PROCESS_BLOCK_WAIT_PIPE_OUT,
|
|
|
|
PROCESS_BLOCK_WAIT_PIPE_IN,
|
|
|
|
|
|
|
|
PROCESS_BLOCK_ENUM_SIZE
|
|
|
|
} process_blockers_E;
|
|
|
|
|
2023-03-03 19:23:19 +00:00
|
|
|
typedef struct process_T process_T;
|
2023-03-04 16:46:21 +00:00
|
|
|
struct process_T {
|
2023-04-18 23:02:45 +00:00
|
|
|
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;
|
|
|
|
|
2023-04-27 10:27:12 +00:00
|
|
|
pipe_T* stdout;
|
|
|
|
pipe_T stdin;
|
|
|
|
pipe_T* stderr;
|
|
|
|
|
|
|
|
bitmap_T waiting;
|
|
|
|
|
2023-04-18 23:02:45 +00:00
|
|
|
uint32_t num_threads;
|
|
|
|
void* threads;
|
|
|
|
bitmap_T thread_ids;
|
|
|
|
|
|
|
|
process_T* parent;
|
|
|
|
process_T* childs;
|
|
|
|
process_T* prev;
|
|
|
|
process_T* next;
|
2023-03-03 19:23:19 +00:00
|
|
|
};
|
|
|
|
|
2023-03-08 00:01:12 +00:00
|
|
|
void process_kernel_spawn (elf_executable_T* executable);
|
|
|
|
pid_t process_spawn (pid_t parent, string_t name, elf_executable_T* executable, void* buffer);
|
|
|
|
int32_t process_get_thread_id (process_T* process);
|
|
|
|
void process_clear_thread_id (process_T* process, uint32_t id);
|
2023-04-27 10:27:12 +00:00
|
|
|
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);
|
2023-03-08 00:01:12 +00:00
|
|
|
void process_kill_pid (pid_t pid);
|
|
|
|
void process_kill (process_T* process);
|
2023-03-03 19:23:19 +00:00
|
|
|
|
|
|
|
#endif //NOX_PROCESS_H
|