IssueNo:I3IK07
Description:liteos_m scheduling optimization and low power design. Sig:kernel Feature or Bugfix:Feature Binary Source:No Change-Id: I6ccbe267ec20f93f97032c5b006c3214eb099daa
This commit is contained in:
parent
628cdcbea0
commit
57f6e1f181
|
@ -56,7 +56,7 @@ STATIC const UINT16 g_daysInMonth[2][13] = {
|
|||
STATIC const UINT8 g_montbl[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
|
||||
|
||||
static UINT64 g_rtcTimeBase = 0;
|
||||
static UINT64 g_systickBase = 0;
|
||||
static UINT64 g_systickBase = (UINT64)-1;
|
||||
|
||||
/*
|
||||
* Time zone information, stored in minutes,
|
||||
|
@ -405,7 +405,7 @@ int clock_nanosleep(clockid_t clk, int flags, const struct timespec *req, struct
|
|||
|
||||
clock_t clock(void)
|
||||
{
|
||||
return HalGetExpandTick();
|
||||
return LOS_TickCountGet() * OS_MS_PER_TICK;
|
||||
}
|
||||
|
||||
time_t time(time_t *timer)
|
||||
|
@ -418,11 +418,11 @@ time_t time(time_t *timer)
|
|||
if (rtcRet != 0) {
|
||||
UINT64 currentTime;
|
||||
UINT64 tickDelta;
|
||||
UINT64 currentTick = HalGetExpandTick();
|
||||
if ((g_systickBase != 0) && (currentTick > g_systickBase)) {
|
||||
UINT64 currentTick = LOS_TickCountGet();
|
||||
if (currentTick > g_systickBase) {
|
||||
tickDelta = currentTick - g_systickBase;
|
||||
}
|
||||
currentTime = g_rtcTimeBase + tickDelta;
|
||||
currentTime = g_rtcTimeBase + tickDelta * OS_MS_PER_TICK;
|
||||
sec = currentTime / OS_SYS_MS_PER_SECOND;
|
||||
} else {
|
||||
sec = usec / OS_SYS_US_PER_SECOND;
|
||||
|
@ -607,11 +607,11 @@ int gettimeofday(struct timeval *tv, void *ptz)
|
|||
if (tv != NULL) {
|
||||
rtcRet = HalGetRtcTime(&usec);
|
||||
if (rtcRet != 0) {
|
||||
currentTick = HalGetExpandTick();
|
||||
if ((g_systickBase != 0) && (currentTick > g_systickBase)) {
|
||||
currentTick = LOS_TickCountGet();
|
||||
if (currentTick > g_systickBase) {
|
||||
tickDelta = currentTick - g_systickBase;
|
||||
}
|
||||
currentTime = g_rtcTimeBase + tickDelta;
|
||||
currentTime = g_rtcTimeBase + tickDelta * OS_MS_PER_TICK;
|
||||
tv->tv_sec = currentTime / OS_SYS_MS_PER_SECOND;
|
||||
tv->tv_usec = (currentTime % OS_SYS_MS_PER_SECOND) * OS_SYS_MS_PER_SECOND;
|
||||
} else {
|
||||
|
@ -633,7 +633,7 @@ int settimeofday(const struct timeval *tv, const struct timezone *tz)
|
|||
return -1;
|
||||
}
|
||||
g_rtcTimeBase = tv->tv_sec * OS_SYS_MS_PER_SECOND + tv->tv_usec / OS_SYS_MS_PER_SECOND;
|
||||
g_systickBase = HalGetExpandTick();
|
||||
g_systickBase = LOS_TickCountGet();
|
||||
if ((tz->tz_minuteswest > TIME_ZONE_MIN) &&
|
||||
(tz->tz_minuteswest < TIME_ZONE_MAX)) {
|
||||
g_rtcTimeZone = tz->tz_minuteswest;
|
||||
|
@ -652,4 +652,4 @@ int usleep(unsigned useconds)
|
|||
specTime.tv_sec = (time_t)(nanoseconds / OS_SYS_NS_PER_SECOND);
|
||||
specTime.tv_nsec = (long)(nanoseconds % OS_SYS_NS_PER_SECOND);
|
||||
return nanosleep(&specTime, NULL);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -98,8 +98,6 @@ extern "C" {
|
|||
* */
|
||||
extern UINT32 LOS_SysClockGet(VOID);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @ingroup los_sys
|
||||
* Number of milliseconds in one second.
|
||||
|
@ -120,6 +118,8 @@ extern UINT32 LOS_SysClockGet(VOID);
|
|||
|
||||
#define OS_NS_PER_CYCLE (OS_SYS_NS_PER_SECOND / OS_SYS_CLOCK)
|
||||
|
||||
#define OS_MS_PER_TICK (OS_SYS_MS_PER_SECOND / LOSCFG_BASE_CORE_TICK_PER_SECOND)
|
||||
|
||||
#define OS_US_PER_TICK (OS_SYS_US_PER_SECOND / LOSCFG_BASE_CORE_TICK_PER_SECOND)
|
||||
|
||||
#define OS_NS_PER_TICK (OS_SYS_NS_PER_SECOND / LOSCFG_BASE_CORE_TICK_PER_SECOND)
|
||||
|
|
Loading…
Reference in New Issue