From 7753da66d7d72f441dadd76f357fd5ceb50e7c8f Mon Sep 17 00:00:00 2001 From: Christian Cunningham Date: Thu, 24 Mar 2022 18:52:56 -0700 Subject: Modularize Userspace --- usr/timed.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 usr/timed.c (limited to 'usr/timed.c') diff --git a/usr/timed.c b/usr/timed.c new file mode 100644 index 0000000..9247acf --- /dev/null +++ b/usr/timed.c @@ -0,0 +1,43 @@ +#define USR_TIMED_C +#include +#include +#include +#include +#include +#include + +void loop(void) +{ + static char str[13]; + static unsigned long previous = 0; + char* start; + unsigned long current = *(volatile unsigned long*)SYS_TIMER_CHI; + start = ulong_to_string(current, str); + draw_string(0, 10, " "); + draw_string(0, 10, start); + start = ulong_to_string(previous, str); + draw_string(0, 11, " "); + draw_string(0, 11, start); + start = ulong_to_string(nextpid, str); + draw_string(0, 12, " "); + draw_string(0, 12, start); + previous++; + wait_msec(3000); + add_thread(loop, 0, 3); +} + +void loopt(void) +{ + static char str[13]; + static char cnt = 18; + draw_string(0, 14, ulong_to_string(*(volatile unsigned long*)SYS_TIMER_CHI, str)); + cnt--; + if (cnt == 6) + unsubscribe_irq(SYS_TIMER_3_IRQ); + if (cnt == 4) + unsubscribe_irq(SYS_TIMER_2_IRQ); + else if (cnt == 2) + unsubscribe_irq(SYS_TIMER_1_IRQ); + else if (cnt == 0) + unsubscribe_irq(SYS_TIMER_0_IRQ); +} -- cgit v1.2.1