wip: fork()

This commit is contained in:
0x35c
2025-11-12 15:07:36 +01:00
parent 02d196fab5
commit 34aa0f0eb4
9 changed files with 115 additions and 28 deletions

View File

@ -1,25 +1,32 @@
#pragma once
#include "list.h"
#include "signal.h"
#include "thread.h"
#include <stdint.h>
extern struct pcb *current_pcb;
enum owner { OWNER_KERNEL, OWNER_USER };
typedef uint16_t pid_t;
typedef uint8_t uid_t;
struct pcb {
void *cr3;
uint32_t *heap;
uint16_t pid;
uint8_t uid;
pid_t pid;
uid_t uid;
tid_t tid;
struct signal_data signals;
struct pcb *next;
struct pcb *prev;
struct tcb *thread_list;
struct pcb *daddy;
struct list *children;
struct list *thread_list;
};
void switch_process(struct pcb *next_pcb);
struct pcb *create_process(uint8_t uid);
struct pcb *create_process(uid_t uid);
// int8_t create_kernel_process(void);
void remove_process(struct pcb *pcb);

View File

@ -1,10 +1,11 @@
#pragma once
#include "process.h"
#include <stdint.h>
#define STACK_SIZE PAGE_SIZE * 4
#define STACK_SIZE PAGE_SIZE * 4
#define CURRENT_TCB ((struct tcb *)current_tcb->content)
typedef uint16_t tid_t;
typedef enum {
NEW,
@ -16,10 +17,9 @@ typedef enum {
struct tcb {
uint32_t *esp;
uint32_t *esp0;
uint16_t tid;
tid_t tid;
state_t state;
struct pcb *process;
struct tcb *next;
};
struct tcb *create_thread(struct pcb *process, void (*entry)(void));