diff options
author | Christian Cunningham <cc@localhost> | 2021-12-04 18:00:23 -0700 |
---|---|---|
committer | Christian Cunningham <cc@localhost> | 2021-12-04 18:00:23 -0700 |
commit | 51af35ffc632f7979fecc609445af8378466d405 (patch) | |
tree | b13f7fb24718d7efc1e7066d9835f85416d13a55 /src/sys | |
parent | baac108e68f8861b01b118e97b149caa26a22e58 (diff) |
Created basic Mutex
Diffstat (limited to 'src/sys')
-rw-r--r-- | src/sys/timer.c | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/src/sys/timer.c b/src/sys/timer.c index 6996983..16e6fdb 100644 --- a/src/sys/timer.c +++ b/src/sys/timer.c @@ -1,17 +1,32 @@ #include "../sys/core.h" #include "../sys/timer.h" #include "../util/time.h" +#include "../util/mutex.h" #include "../drivers/uart.a.h" #include "../drivers/uart.h" +static unsigned long exe_cnt = 0; +static struct Mutex exe_cnt_m = {.addr = &exe_cnt, .pid = NULL_PID}; + +//static unsigned long execution_count = 0; + void c_timer() { // Reset the counter write_cntv_tval(cntfrq); // Output the value - uart_string((char*)"Timer Value: "); - unsigned long v = read_cntv_tval(); - uart_10(v); - uart_char(0x20); - uart_hexn(v); + //uart_string((char*)"Timer Value: "); + //unsigned long v = read_cntv_tval(); + //uart_10(v); + //uart_char(0x20); + //uart_hexn(v); + + // Lock the execution counter + if (lock_mutex(&exe_cnt_m, SCHED_PID) == 0) { + *(exe_cnt_m.addr) += 1; + uart_string((char*)"Executed #"); + uart_10(*(exe_cnt_m.addr)); + uart_string((char*)" Times\n"); + release_mutex(&exe_cnt_m, SCHED_PID); + } } |