sys_clock: Fix unsafe tick count usage
The system tick count is a 64 bit quantity that gets updated from interrupt context, meaning that it's dangerously non-atomic and has to be locked. The core kernel clock code did this right. But the value was also exposed to the rest of the universe as a global variable, and virtually nothing else was doing this correctly. Even in the timer ISRs themselves, the interrupts may be themselves preempted (most of our architectures support nested interrupts) by code that wants to set timeouts and inspect system uptime. Define a z_tick_{get,set}() API, eliminate the old variable, and make sure everyone uses the right mechanism. Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
This commit is contained in:
parent
ae6daa6207
commit
0715015c75
|
@ -12,10 +12,8 @@
|
|||
#include <metal/time.h>
|
||||
#include <sys_clock.h>
|
||||
|
||||
extern volatile u64_t _sys_clock_tick_count;
|
||||
|
||||
unsigned long long metal_get_timestamp(void)
|
||||
{
|
||||
return (unsigned long long)_sys_clock_tick_count;
|
||||
return (unsigned long long)z_tick_get();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue