mirror of
https://github.com/apache/nuttx.git
synced 2026-05-30 13:27:01 +08:00
sched/clock: Make g_system_ticks a static variable
Make g_system_ticks a static variable, as it is only accessed by
clock_get_sched_ticks().
This change improves code modularity and enhances safety, since
clock_get_sched_ticks() performs proper synchronization when
reading g_system_ticks.
Signed-off-by: Chengdong Wang wangchengdong@lixiang.com
This commit is contained in:
committed by
Alan C. Assis
parent
1b58dd92d8
commit
1b58a449c5
@@ -324,18 +324,6 @@ extern "C"
|
|||||||
#define EXTERN extern
|
#define EXTERN extern
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Access to raw system clock ***********************************************/
|
|
||||||
|
|
||||||
/* Direct access to the system timer/counter is supported only if (1) the
|
|
||||||
* system timer counter is available (i.e., we are not configured to use
|
|
||||||
* a hardware periodic timer), and (2) the execution environment has direct
|
|
||||||
* access to kernel global data
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef __HAVE_KERNEL_GLOBALS
|
|
||||||
EXTERN volatile clock_t g_system_ticks;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Function Prototypes
|
* Public Function Prototypes
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|||||||
@@ -61,14 +61,6 @@
|
|||||||
* Public Data
|
* Public Data
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#if !defined(__HAVE_KERNEL_GLOBALS)
|
|
||||||
/* The system clock exists (CONFIG_SCHED_TICKLESS), but it not prototyped
|
|
||||||
* globally in include/nuttx/clock.h.
|
|
||||||
*/
|
|
||||||
|
|
||||||
extern volatile clock_t g_system_ticks;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef CONFIG_CLOCK_TIMEKEEPING
|
#ifndef CONFIG_CLOCK_TIMEKEEPING
|
||||||
extern struct timespec g_basetime;
|
extern struct timespec g_basetime;
|
||||||
extern spinlock_t g_basetime_lock;
|
extern spinlock_t g_basetime_lock;
|
||||||
|
|||||||
@@ -51,8 +51,6 @@
|
|||||||
* Public Data
|
* Public Data
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
volatile clock_t g_system_ticks = INITIAL_SYSTEM_TIMER_TICKS;
|
|
||||||
|
|
||||||
#ifndef CONFIG_CLOCK_TIMEKEEPING
|
#ifndef CONFIG_CLOCK_TIMEKEEPING
|
||||||
struct timespec g_basetime;
|
struct timespec g_basetime;
|
||||||
spinlock_t g_basetime_lock = SP_UNLOCKED;
|
spinlock_t g_basetime_lock = SP_UNLOCKED;
|
||||||
|
|||||||
@@ -34,6 +34,12 @@
|
|||||||
|
|
||||||
#include "clock/clock.h"
|
#include "clock/clock.h"
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Private Data
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
static volatile clock_t g_system_ticks = INITIAL_SYSTEM_TIMER_TICKS;
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Functions
|
* Public Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|||||||
Reference in New Issue
Block a user