diff --git a/kernel/hal/hal.h b/kernel/hal/hal.h index 2fe9749..62f243f 100644 --- a/kernel/hal/hal.h +++ b/kernel/hal/hal.h @@ -19,6 +19,7 @@ size_t hal_strspn(const char *s, const char *accept); char *hal_strcpy(char *dest, const char *src); char *hal_strchr(const char *s, int c); void hal_init_withmalloc(void); +void hal_wait(uint32_t ms); #if defined(__x86_64__) # define HAL_PAGE_SIZE 0x1000 diff --git a/kernel/hal/x86_64/hal.c b/kernel/hal/x86_64/hal.c index fdbf571..76503a0 100644 --- a/kernel/hal/x86_64/hal.c +++ b/kernel/hal/x86_64/hal.c @@ -34,3 +34,7 @@ void hal_init_withmalloc(void) { hal_intr_disable(); } +void hal_wait(uint32_t ms) { + pit_wait(ms); +} + diff --git a/kernel/proc/proc.c b/kernel/proc/proc.c index 3a16f1d..b6b3f99 100644 --- a/kernel/proc/proc.c +++ b/kernel/proc/proc.c @@ -11,6 +11,12 @@ #define PROC_REAPER_FREQ 30 +#define PROC_DIE() \ + do { \ + proc_killself(); \ + for(;;); \ + } while(0) + uint64_t pids = 0; uint64_t sched_ticks = 0; @@ -114,13 +120,11 @@ int a = 0; void proc_print(void) { for (;;) { - for (volatile size_t i = 0; i < 0x1000000; i++) { - } + hal_wait(1 * 1000); - if (a == 10) { - proc_killself(); - for(;;); - } + /* if (a == 10) { */ + /* PROC_DIE(); */ + /* } */ kprintf("A"); a++; } @@ -130,13 +134,11 @@ int b = 0; void proc_print2(void) { for (;;) { - for (volatile size_t i = 0; i < 0x1000000; i++) { - } + hal_wait(2 * 1000); - if (b == 20) { - proc_killself(); - for(;;); - } + /* if (b == 20) { */ + /* PROC_DIE(); */ + /* } */ kprintf("B"); b++; }