From: Will Sowerbutts Date: Sat, 27 Dec 2014 16:32:15 +0000 (+0000) Subject: Kernel: Merge 16-bit and 32-bit tick counters into one structure X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=1af6baeadd4cd064739795ddb05b174bc45d2643;p=FUZIX.git Kernel: Merge 16-bit and 32-bit tick counters into one structure --- diff --git a/Kernel/include/kdata.h b/Kernel/include/kdata.h index 7694aa9a..1d744677 100644 --- a/Kernel/include/kdata.h +++ b/Kernel/include/kdata.h @@ -32,8 +32,12 @@ extern uint8_t ticks_this_dsecond; /* Tick counter for counting off one de extern uint16_t runticks; /* Number of ticks current process has been swapped in */ extern time_t tod; /* Time of day */ -extern clock_t ticks; /* 32-bit count of ticks since boot */ -extern uint16_t miniticks; /* 16-bit count of ticks since boot */ + +typedef union { /* this structure is endian dependent */ + clock_t full; /* 32-bit count of ticks since boot */ + uint16_t mini; /* 16-bit count of ticks since boot */ +} ticks_t; +extern ticks_t ticks; extern uint8_t *swapbase; /* Used by device driver for swapping */ extern unsigned swapcnt; diff --git a/Kernel/kdata.c b/Kernel/kdata.c index 95a4063c..5b5ae504 100644 --- a/Kernel/kdata.c +++ b/Kernel/kdata.c @@ -13,8 +13,7 @@ uint8_t ticks_this_dsecond; inoptr root; uint16_t waitno; time_t tod; // time of day -clock_t ticks; // 32-bit system tick counter -uint16_t miniticks; // 16-bit system tick counter +ticks_t ticks; int16_t acct_fh = -1; /* Accounting file handle */ diff --git a/Kernel/process.c b/Kernel/process.c index e47d468b..0b876698 100644 --- a/Kernel/process.c +++ b/Kernel/process.c @@ -327,8 +327,8 @@ void timer_interrupt(void) else udata.u_utime++; } - ticks++; - miniticks++; + + ticks.full++; /* Do once-per-decisecond things - this doesn't work out well on boxes with 64 ticks/second.. need a better approach */ diff --git a/Kernel/syscall_proc.c b/Kernel/syscall_proc.c index 342ea7c2..4ec5d68c 100644 --- a/Kernel/syscall_proc.c +++ b/Kernel/syscall_proc.c @@ -144,7 +144,7 @@ int16_t _time(void) uput(&t, tvec, sizeof(t)); return (0); case 1: - uput(&t.low, &ticks, sizeof(ticks)); + uput(&t.low, &ticks.full, sizeof(ticks)); uzero(&t.high, sizeof(t.high)); return 0; default: diff --git a/Kernel/timer.c b/Kernel/timer.c index 9f50e034..f80708c1 100644 --- a/Kernel/timer.c +++ b/Kernel/timer.c @@ -12,14 +12,14 @@ timer_t set_timer_duration(uint16_t duration) } /* obvious code is return (miniticks+duration), however we have to do */ /* it this longwinded way or sdcc doesn't load miniticks atomically */ - a = miniticks; + a = ticks.mini; a += duration; return a; } bool timer_expired(timer_t timer_val) { - return ((timer_val - miniticks) & 0x8000); + return ((timer_val - ticks.mini) & 0x8000); } /*-----------------------------------------------------------*/