user_space #4

Merged
mathieu merged 40 commits from user_space into master 2021-11-04 16:17:36 +01:00
3 changed files with 22 additions and 0 deletions
Showing only changes of commit 0040fb1cda - Show all commits

View File

@ -15,6 +15,7 @@
#include "multiboot.h" #include "multiboot.h"
#include "paging.h" #include "paging.h"
#include "pit.h" #include "pit.h"
#include "process.h"
#include "serial.h" #include "serial.h"
#include "stack.h" #include "stack.h"
#include "stdarg.h" #include "stdarg.h"
@ -170,6 +171,7 @@ void kmain(unsigned long magic, unsigned long addr)
printf("[Setup] thread system\n"); printf("[Setup] thread system\n");
threadSetup(_stack_bottom, (_stack_top - _stack_bottom + 1)); threadSetup(_stack_bottom, (_stack_top - _stack_bottom + 1));
threadCreate("idle ", idleThread, NULL); threadCreate("idle ", idleThread, NULL);
processSetup();
irqSetRoutine(IRQ_TIMER, pit_handler); irqSetRoutine(IRQ_TIMER, pit_handler);

View File

@ -13,3 +13,4 @@ int processRef(struct process *proc);
int processUnref(struct process *proc); int processUnref(struct process *proc);
int processSetName(struct process *proc, char *name); int processSetName(struct process *proc, char *name);
int processAddThread(struct process *proc, struct thread *th); int processAddThread(struct process *proc, struct thread *th);
int processRemoveThread(struct thread *th);

View File

@ -9,6 +9,7 @@
#include "mem.h" #include "mem.h"
#include "mmuContext.h" #include "mmuContext.h"
#include "paging.h" #include "paging.h"
#include "process.h"
#include "serial.h" #include "serial.h"
#include "stack.h" #include "stack.h"
#include "synchro.h" #include "synchro.h"
@ -381,6 +382,23 @@ static void testMMUContext()
mmuContextUnref(new); mmuContextUnref(new);
} }
static void testProcess(){
struct process *proc= processCreate("TESTPROCESS");
struct thread *th1 = threadCreate("th1", sleepThread, NULL);
struct thread *th2 = threadCreate("th2", sleepThread, NULL);
processAddThread(proc, th1);
processAddThread(proc, th2);
processListPrint();
threadMsleep(600);
processRemoveThread(th1);
processRemoveThread(th2);
processUnref(proc);
printf("Next process list should be empty\n");
processListPrint();
}
void run_test(void) void run_test(void)
{ {
@ -420,6 +438,7 @@ void run_test(void)
testCoroutine(); testCoroutine();
testKthread(); testKthread();
testMMUContext(); testMMUContext();
testProcess();
memGetStat(&afterFreemem, &afterUsedmem); memGetStat(&afterFreemem, &afterUsedmem);
printf("free %d -> %d\n", freemem, afterFreemem); printf("free %d -> %d\n", freemem, afterFreemem);
} }