Timed waiting with hal_wait()
This commit is contained in:
@ -19,6 +19,7 @@ size_t hal_strspn(const char *s, const char *accept);
|
|||||||
char *hal_strcpy(char *dest, const char *src);
|
char *hal_strcpy(char *dest, const char *src);
|
||||||
char *hal_strchr(const char *s, int c);
|
char *hal_strchr(const char *s, int c);
|
||||||
void hal_init_withmalloc(void);
|
void hal_init_withmalloc(void);
|
||||||
|
void hal_wait(uint32_t ms);
|
||||||
|
|
||||||
#if defined(__x86_64__)
|
#if defined(__x86_64__)
|
||||||
# define HAL_PAGE_SIZE 0x1000
|
# define HAL_PAGE_SIZE 0x1000
|
||||||
|
@ -34,3 +34,7 @@ void hal_init_withmalloc(void) {
|
|||||||
hal_intr_disable();
|
hal_intr_disable();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void hal_wait(uint32_t ms) {
|
||||||
|
pit_wait(ms);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -11,6 +11,12 @@
|
|||||||
|
|
||||||
#define PROC_REAPER_FREQ 30
|
#define PROC_REAPER_FREQ 30
|
||||||
|
|
||||||
|
#define PROC_DIE() \
|
||||||
|
do { \
|
||||||
|
proc_killself(); \
|
||||||
|
for(;;); \
|
||||||
|
} while(0)
|
||||||
|
|
||||||
uint64_t pids = 0;
|
uint64_t pids = 0;
|
||||||
uint64_t sched_ticks = 0;
|
uint64_t sched_ticks = 0;
|
||||||
|
|
||||||
@ -114,13 +120,11 @@ int a = 0;
|
|||||||
|
|
||||||
void proc_print(void) {
|
void proc_print(void) {
|
||||||
for (;;) {
|
for (;;) {
|
||||||
for (volatile size_t i = 0; i < 0x1000000; i++) {
|
hal_wait(1 * 1000);
|
||||||
}
|
|
||||||
|
|
||||||
if (a == 10) {
|
/* if (a == 10) { */
|
||||||
proc_killself();
|
/* PROC_DIE(); */
|
||||||
for(;;);
|
/* } */
|
||||||
}
|
|
||||||
kprintf("A");
|
kprintf("A");
|
||||||
a++;
|
a++;
|
||||||
}
|
}
|
||||||
@ -130,13 +134,11 @@ int b = 0;
|
|||||||
|
|
||||||
void proc_print2(void) {
|
void proc_print2(void) {
|
||||||
for (;;) {
|
for (;;) {
|
||||||
for (volatile size_t i = 0; i < 0x1000000; i++) {
|
hal_wait(2 * 1000);
|
||||||
}
|
|
||||||
|
|
||||||
if (b == 20) {
|
/* if (b == 20) { */
|
||||||
proc_killself();
|
/* PROC_DIE(); */
|
||||||
for(;;);
|
/* } */
|
||||||
}
|
|
||||||
kprintf("B");
|
kprintf("B");
|
||||||
b++;
|
b++;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user