sched/clock: Rename g_system_timer to g_system_ticks

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
Xiang Xiao 2022-09-27 12:03:48 +08:00 committed by Alan Carvalho de Assis
parent 24ea8ee3e9
commit 764540267e
6 changed files with 20 additions and 24 deletions

View File

@ -11,9 +11,9 @@ by ``CONFIG_USEC_PER_TICK`` (default 10000 microseconds or 100Hz.
If ``CONFIG_SCHED_TICKLESS`` is selected, the default is 100
microseconds). The timer generates an interrupt each
``CONFIG_USEC_PER_TICK`` microseconds and increments a counter
called ``g_system_timer``. ``g_system_timer`` then provides a
called ``g_system_ticks``. ``g_system_ticks`` then provides a
time-base for calculating *up-time* and elapsed time intervals in
units of ``CONFIG_USEC_PER_TICK``. The range of ``g_system_timer``
units of ``CONFIG_USEC_PER_TICK``. The range of ``g_system_ticks``
is, by default, 32-bits. However, if the MCU supports type
``long long`` and ``CONFIG_SYSTEM_TIME16`` is selected, a 64-bit
system timer will be supported instead.
@ -159,7 +159,7 @@ which requires the following base functions to read and set time:
- ``up_rtc_gettime()``. Get the current time from the high
resolution RTC clock/counter. This interface is only supported
by the high-resolution RTC/counter hardware implementation. It
is used to replace the system timer (``g_system_tick``).
is used to replace the system timer (``g_system_ticks``).
- ``up_rtc_settime()``. Set the RTC to the provided time. All RTC
implementations must be able to set their time based on a
standard timespec.
@ -167,7 +167,7 @@ which requires the following base functions to read and set time:
System Tick and Time
====================
The system tick is represented by ``g_system_timer``.
The system tick is represented by ``g_system_ticks``.
Running at rate of system base timer, used for time-slicing, and
so forth.
@ -178,7 +178,7 @@ after successful initialization variables are overridden by calls
to ``up_rtc_gettime()`` which is running continuously even in
power-down modes.
In the case of ``CONFIG_RTC_HIRES`` is set the ``g_system_timer``
In the case of ``CONFIG_RTC_HIRES`` is set the ``g_system_ticks``
keeps counting at rate of a system timer, which however, is
disabled in power-down mode. By comparing this time and RTC
(actual time) one may determine the actual system active time. To

View File

@ -700,7 +700,7 @@ int up_rtc_gettime(struct timespec *tp)
/* Get the elapsed time */
elapsed = NSEC_PER_TICK * (uint64_t)g_system_timer;
elapsed = NSEC_PER_TICK * (uint64_t)g_system_ticks;
/* Add the tiemr fraction in nanoseconds */

View File

@ -240,11 +240,11 @@ extern "C"
*/
#ifdef __HAVE_KERNEL_GLOBALS
EXTERN volatile clock_t g_system_timer;
EXTERN volatile clock_t g_system_ticks;
#ifndef CONFIG_SYSTEM_TIME64
# define clock_systime_ticks() g_system_timer
#endif
# ifndef CONFIG_SYSTEM_TIME64
# define clock_systime_ticks() g_system_ticks
# endif
#endif
/****************************************************************************

View File

@ -59,15 +59,11 @@
* globally in include/nuttx/clock.h.
*/
# ifdef CONFIG_SYSTEM_TIME64
extern volatile uint64_t g_system_timer;
# else
extern volatile uint32_t g_system_timer;
# endif
extern volatile clock_t g_system_ticks;
#endif
#ifndef CONFIG_CLOCK_TIMEKEEPING
extern struct timespec g_basetime;
extern struct timespec g_basetime;
#endif
/****************************************************************************

View File

@ -49,9 +49,9 @@
#ifndef CONFIG_SCHED_TICKLESS
#ifdef CONFIG_SYSTEM_TIME64
volatile uint64_t g_system_timer = INITIAL_SYSTEM_TIMER_TICKS;
volatile uint64_t g_system_ticks = INITIAL_SYSTEM_TIMER_TICKS;
#else
volatile uint32_t g_system_timer = INITIAL_SYSTEM_TIMER_TICKS;
volatile uint32_t g_system_ticks = INITIAL_SYSTEM_TIMER_TICKS;
#endif
#endif
@ -394,8 +394,8 @@ void clock_resynchronize(FAR struct timespec *rtc_diff)
/* Add the sleep time to correct system timer */
g_system_timer += SEC2TICK(rtc_diff->tv_sec);
g_system_timer += NSEC2TICK(rtc_diff->tv_nsec);
g_system_ticks += SEC2TICK(rtc_diff->tv_sec);
g_system_ticks += NSEC2TICK(rtc_diff->tv_nsec);
}
skip:
@ -418,6 +418,6 @@ void clock_timer(void)
{
/* Increment the per-tick system counter */
g_system_timer++;
g_system_ticks++;
}
#endif

View File

@ -122,8 +122,8 @@ clock_t clock_systime_ticks(void)
do
{
verify = g_system_timer;
sample = g_system_timer;
verify = g_system_ticks;
sample = g_system_ticks;
}
while ((sample & TIMER_MASK32) < (verify & TIMER_MASK32) ||
(sample & ~TIMER_MASK32) != (verify & ~TIMER_MASK32));
@ -134,7 +134,7 @@ clock_t clock_systime_ticks(void)
/* Return the current system time */
return g_system_timer;
return g_system_ticks;
# endif /* CONFIG_SYSTEM_TIME64 */
#endif /* CONFIG_SCHED_TICKLESS */