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

@ -6,14 +6,15 @@
#include "string.h"
struct pcb *create_process(uint8_t uid)
struct pcb *create_process(uid_t uid)
{
static uint32_t pid = 1;
static pid_t pid = 1;
struct pcb *new_pcb = vmalloc(sizeof(struct pcb));
if (!new_pcb)
return NULL;
new_pcb->uid = uid;
new_pcb->pid = pid++;
new_pcb->tid = 1;
new_pcb->heap = alloc_pages(4096, &new_pcb->cr3);
if (!new_pcb->heap) {
@ -22,6 +23,8 @@ struct pcb *create_process(uint8_t uid)
}
memcpy(new_pcb->heap, current_pd, 4096);
new_pcb->daddy = NULL;
new_pcb->children = NULL;
new_pcb->next = new_pcb;
new_pcb->prev = new_pcb;
@ -40,7 +43,7 @@ struct pcb *create_process(uint8_t uid)
return new_pcb;
}
void remove_pcb(struct pcb *pcb)
void remove_process(struct pcb *pcb)
{
struct pcb *left = pcb->prev;
struct pcb *right = pcb->next;