diff --git a/include/aos/paging_types.h b/include/aos/paging_types.h index 717cf20..171a982 100644 --- a/include/aos/paging_types.h +++ b/include/aos/paging_types.h @@ -82,7 +82,6 @@ struct paging_state { struct capref free_l2_vnode; struct capref free_l3_vnode; - // TODO rueegges: implement more precisely? struct pt_vaddr_reg_t vaddr_head; }; diff --git a/include/time.h b/include/time.h index 14d6044..90d946a 100644 --- a/include/time.h +++ b/include/time.h @@ -152,6 +152,7 @@ time_t mktime(struct tm *); size_t strftime(char * __restrict, size_t, const char * __restrict, const struct tm * __restrict); time_t time(time_t *); +void time_wait_ms(unsigned long); #if __POSIX_VISIBLE >= 200112 struct sigevent; int timer_create(clockid_t, struct sigevent *__restrict, timer_t *__restrict); diff --git a/lib/aos/paging.c b/lib/aos/paging.c index 357b272..e1dbf2e 100644 --- a/lib/aos/paging.c +++ b/lib/aos/paging.c @@ -317,7 +317,6 @@ errval_t paging_init_state(struct paging_state *st, lvaddr_t start_vaddr, assert(ca != NULL); // initialize slab allocators - // TODO rueegges: is this how we should initialize the slab allocators? slab_init(&st->pt_slabs, PT_META_MAX_SIZE, NULL); slab_init(&st->pt_children_slabs, BASE_PAGE_SIZE, NULL); diff --git a/lib/grading/test_spawn.c b/lib/grading/test_spawn.c index 64d62a4..62a8059 100644 --- a/lib/grading/test_spawn.c +++ b/lib/grading/test_spawn.c @@ -1,6 +1,7 @@ #include #include #include +#include #define PROCESS_COUNT 5 @@ -14,7 +15,8 @@ void do_test_spawn(void) { CHECK_ERR(spawn_load_by_name("hello", &(si[i]), &(pid[i]))); } - for(volatile int j = 0; j < 300000000; ++j); + // wait for 10 seconds before continuing + time_wait_ms(10000); for(uint i = 0; i < PROCESS_COUNT; ++i) { debug_printf("TEST_SPAWN: Killing %u\n", i); diff --git a/lib/libc/gen/time.c b/lib/libc/gen/time.c index 214dfce..43991bf 100644 --- a/lib/libc/gen/time.c +++ b/lib/libc/gen/time.c @@ -50,3 +50,24 @@ time(time_t *t) *t = retval; return (retval); } + +/** + * \brief Wait for ms milliseconds before returning. + * + * \param ms Duration to wait + * + * Very ugly and approximate but useful + * + */ +void +time_wait_ms(unsigned long ms) { + struct timespec tt; + + clock_gettime(CLOCK_REALTIME, &tt); + long start = tt.tv_sec * 1000 + tt.tv_nsec / 1000 / 1000; + long now; + do { + clock_gettime(CLOCK_REALTIME, &tt); + now = tt.tv_sec * 1000 + tt.tv_nsec / 1000 / 1000; + } while(start + ms > now); +} \ No newline at end of file diff --git a/usr/hello/hello.c b/usr/hello/hello.c index 9827006..9fc3a75 100644 --- a/usr/hello/hello.c +++ b/usr/hello/hello.c @@ -16,7 +16,7 @@ #include #include -#include +#include #include @@ -24,12 +24,7 @@ int main(int argc, char *argv[]) { - struct timespec tt; - - if (clock_gettime(CLOCK_REALTIME, &tt) < 0) return 1; - double time = tt.tv_sec + tt.tv_nsec / 1000000000.0; - - printf("Hello, world! I am %lfs\n", time); + printf("Hello, world!\n"); printf("argv:\n"); for(int i = 0; i < argc; ++i) { @@ -38,10 +33,12 @@ int main(int argc, char *argv[]) // if we receive the catch command, RUN! if (argc > 1 && !strncmp(argv[1], HELLO_CATCH_COMMAND, sizeof(HELLO_CATCH_COMMAND))) { + int iter = 0; while(1) { - printf("Catch %lf if you can!\n", time); + printf("Catch me if you can! %d\n", iter); // wait for 1 second - for(volatile int j = 0; j < 50000000; ++j); + time_wait_ms(1000); + ++iter; } }