Compare commits

...

4 Commits

Author SHA1 Message Date
openharmony_ci
887a845874 !724 fix: 修复系统时间比RTC时间过快的问题
Merge pull request !724 from zhushengle/tick_3.0.0
2022-06-25 10:12:26 +00:00
zhushengle
8ee33a771b fix: 修复系统时间比RTC时间过快的问题
1.标记在时间接口中更新base后在中断中不再更新base
2.优化tick计算

Close #I5DCRB

Signed-off-by: zhushengle <zhushengle@huawei.com>
Change-Id: I525e6e996fd40890b52c1c749ef0bad20c8136d8
2022-06-25 09:45:45 +08:00
openharmony_ci
c182540a92 !716 fix:ping命令访问野指针及内存泄漏问题修复
Merge pull request !716 from Zhaotianyu/0617ping_fix
2022-06-18 10:06:29 +00:00
arvinzzz
d837ed3e9d fix: ping命令内访问野指针及内存泄漏
Signed-off-by: arvinzzz <zhaotianyu9@huawei.com>
2022-06-17 16:54:51 +08:00
6 changed files with 26 additions and 25 deletions

View File

@@ -588,7 +588,6 @@ u32_t OsShellPing(int argc, const char **argv)
stPingTask.uwArg = (UINTPTR)parg;
ret = LOS_TaskCreate((UINT32 *)(&ping_taskid), &stPingTask);
if (ret != LOS_OK) {
free(parg);
PRINTK("ping_task create failed 0x%08x.\n", ret);
count = LWIP_SHELL_CMD_PING_RETRY_TIMES;
} else {
@@ -604,6 +603,8 @@ u32_t OsShellPing(int argc, const char **argv)
PRINTK("Ping cmd failed due some errors\n");
}
free(parg);
return LOS_OK;
ping_error:
lwip_ping_usage();

View File

@@ -130,6 +130,10 @@ extern UINT64 LOS_SysCycleGet(VOID);
#define OS_SYS_NS_TO_CYCLE(time, freq) (((time) / OS_SYS_NS_PER_SECOND) * (freq) + \
(time % OS_SYS_NS_PER_SECOND) * (freq) / OS_SYS_NS_PER_SECOND)
#define OS_SYS_TICK_TO_CYCLE(ticks) (((UINT64)(ticks) * g_sysClock) / LOSCFG_BASE_CORE_TICK_PER_SECOND)
#define OS_SYS_CYCLE_TO_TICK(cycle) ((((UINT64)(cycle)) * LOSCFG_BASE_CORE_TICK_PER_SECOND) / g_sysClock)
/**
* @ingroup los_tick
* System time basic function error code: Null pointer.

View File

@@ -92,13 +92,17 @@ VOID OsSchedResetSchedResponseTime(UINT64 responseTime)
#if (LOSCFG_BASE_CORE_TICK_WTIMER == 0)
STATIC UINT64 g_schedTimerBase;
STATIC BOOL g_tickTimerBaseUpdate = FALSE;
VOID OsSchedUpdateSchedTimeBase(VOID)
{
UINT32 period = 0;
(VOID)HalGetTickCycle(&period);
g_schedTimerBase += period;
if (g_tickTimerBaseUpdate == FALSE) {
(VOID)HalGetTickCycle(&period);
g_schedTimerBase += period;
}
g_tickTimerBaseUpdate = FALSE;
}
VOID OsSchedTimerBaseReset(UINT64 currTime)
@@ -124,6 +128,7 @@ UINT64 OsGetCurrSysTimeCycle(VOID)
/* Turn the timer count */
g_schedTimerBase += period;
schedTime = g_schedTimerBase + time;
g_tickTimerBaseUpdate = TRUE;
}
LOS_ASSERT(schedTime >= oldSchedTime);
@@ -145,22 +150,11 @@ STATIC INLINE VOID OsTimeSliceUpdate(LosTaskCB *taskCB, UINT64 currTime)
taskCB->startTime = currTime;
}
STATIC INLINE VOID OsSchedTickReload(UINT64 nextResponseTime, UINT32 responseID, BOOL isTimeSlice, BOOL timeUpdate)
STATIC INLINE VOID OsSchedTickReload(UINT64 currTime, UINT64 nextResponseTime, UINT32 responseID,
BOOL isTimeSlice, BOOL timeUpdate)
{
UINT64 currTime, nextExpireTime;
UINT32 usedTime;
currTime = OsGetCurrSchedTimeCycle();
if (g_tickStartTime != 0) {
usedTime = currTime - g_tickStartTime;
g_tickStartTime = 0;
} else {
usedTime = 0;
}
if ((nextResponseTime > usedTime) && ((nextResponseTime - usedTime) > OS_TICK_RESPONSE_PRECISION)) {
nextResponseTime -= usedTime;
} else {
UINT64 nextExpireTime;
if (nextResponseTime < OS_TICK_RESPONSE_PRECISION) {
nextResponseTime = OS_TICK_RESPONSE_PRECISION;
}
@@ -190,8 +184,10 @@ STATIC INLINE VOID OsSchedSetNextExpireTime(UINT64 startTime, UINT32 responseID,
UINT64 nextExpireTime;
UINT64 nextResponseTime = 0;
BOOL isTimeSlice = FALSE;
(VOID)startTime;
nextExpireTime = OsGetNextExpireTime(startTime);
UINT64 currTime = OsGetCurrSchedTimeCycle();
nextExpireTime = OsGetNextExpireTime(currTime);
/* The response time of the task time slice is aligned to the next response time in the delay queue */
if ((nextExpireTime > taskEndTime) && ((nextExpireTime - taskEndTime) > OS_SCHED_MINI_PERIOD)) {
nextExpireTime = taskEndTime;
@@ -200,7 +196,7 @@ STATIC INLINE VOID OsSchedSetNextExpireTime(UINT64 startTime, UINT32 responseID,
if ((g_schedResponseTime > nextExpireTime) &&
((g_schedResponseTime - nextExpireTime) >= OS_TICK_RESPONSE_PRECISION)) {
nextResponseTime = nextExpireTime - startTime;
nextResponseTime = nextExpireTime - currTime;
if (nextResponseTime > OS_TICK_RESPONSE_TIME_MAX) {
if (SchedRealSleepTimeSet != NULL) {
SchedRealSleepTimeSet(nextResponseTime);
@@ -217,7 +213,7 @@ STATIC INLINE VOID OsSchedSetNextExpireTime(UINT64 startTime, UINT32 responseID,
return;
}
OsSchedTickReload(nextResponseTime, responseID, isTimeSlice, timeUpdate);
OsSchedTickReload(currTime, nextResponseTime, responseID, isTimeSlice, timeUpdate);
}
VOID OsSchedUpdateExpireTime(UINT64 startTime, BOOL timeUpdate)

View File

@@ -115,7 +115,7 @@ VOID OsAdd2SortLink(SortLinkList *node, UINT64 startTime, UINT32 waitTicks, Sort
}
intSave = LOS_IntLock();
SET_SORTLIST_VALUE(node, startTime + (UINT64)waitTicks * OS_CYCLE_PER_TICK);
SET_SORTLIST_VALUE(node, startTime + OS_SYS_TICK_TO_CYCLE(waitTicks));
OsAddNode2SortLink(sortLinkHeader, node);
LOS_IntRestore(intSave);
}

View File

@@ -123,8 +123,8 @@ LITE_OS_SEC_TEXT_INIT UINT32 OsSwtmrTaskCreate(VOID)
STATIC UINT64 OsSwtmrCalcStartTime(UINT64 currTime, SWTMR_CTRL_S *swtmr, const SWTMR_CTRL_S *alignSwtmr)
{
UINT64 usedTime, startTime;
UINT64 alignEnd = (UINT64)alignSwtmr->uwInterval * OS_CYCLE_PER_TICK;
UINT64 swtmrTime = (UINT64)swtmr->uwInterval * OS_CYCLE_PER_TICK;
UINT64 alignEnd = OS_SYS_TICK_TO_CYCLE(alignSwtmr->uwInterval);
UINT64 swtmrTime = OS_SYS_TICK_TO_CYCLE(swtmr->uwInterval);
UINT64 remainTime = OsSortLinkGetRemainTime(currTime, &alignSwtmr->stSortList);
if (remainTime == 0) {
startTime = GET_SORTLIST_VALUE(&alignSwtmr->stSortList);

View File

@@ -72,7 +72,7 @@ Return : current tick
*****************************************************************************/
LITE_OS_SEC_TEXT_MINOR UINT64 LOS_TickCountGet(VOID)
{
return OsGetCurrSchedTimeCycle() / OS_CYCLE_PER_TICK;
return OS_SYS_CYCLE_TO_TICK(OsGetCurrSchedTimeCycle());
}
/*****************************************************************************