Timed waiting with hal_wait()

This commit is contained in:
2025-08-31 00:21:17 +02:00
parent 73f27f730b
commit 13ab117b1b
3 changed files with 19 additions and 12 deletions

View File

@ -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

View File

@ -34,3 +34,7 @@ void hal_init_withmalloc(void) {
hal_intr_disable();
}
void hal_wait(uint32_t ms) {
pit_wait(ms);
}

View File

@ -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++;
}