user_space #4
@ -15,6 +15,7 @@
|
||||
#include "multiboot.h"
|
||||
#include "paging.h"
|
||||
#include "pit.h"
|
||||
#include "process.h"
|
||||
#include "serial.h"
|
||||
#include "stack.h"
|
||||
#include "stdarg.h"
|
||||
@ -170,6 +171,7 @@ void kmain(unsigned long magic, unsigned long addr)
|
||||
printf("[Setup] thread system\n");
|
||||
threadSetup(_stack_bottom, (_stack_top - _stack_bottom + 1));
|
||||
threadCreate("idle ", idleThread, NULL);
|
||||
processSetup();
|
||||
|
||||
irqSetRoutine(IRQ_TIMER, pit_handler);
|
||||
|
||||
|
@ -13,3 +13,4 @@ int processRef(struct process *proc);
|
||||
int processUnref(struct process *proc);
|
||||
int processSetName(struct process *proc, char *name);
|
||||
int processAddThread(struct process *proc, struct thread *th);
|
||||
int processRemoveThread(struct thread *th);
|
||||
|
19
tests/test.c
19
tests/test.c
@ -9,6 +9,7 @@
|
||||
#include "mem.h"
|
||||
#include "mmuContext.h"
|
||||
#include "paging.h"
|
||||
#include "process.h"
|
||||
#include "serial.h"
|
||||
#include "stack.h"
|
||||
#include "synchro.h"
|
||||
@ -381,6 +382,23 @@ static void testMMUContext()
|
||||
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)
|
||||
{
|
||||
|
||||
@ -420,6 +438,7 @@ void run_test(void)
|
||||
testCoroutine();
|
||||
testKthread();
|
||||
testMMUContext();
|
||||
testProcess();
|
||||
memGetStat(&afterFreemem, &afterUsedmem);
|
||||
printf("free %d -> %d\n", freemem, afterFreemem);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user