fix: tick 动态化计算优化,减小中断执行时间对系统总体时间的影响,保证软件定时器的响应精度。
方案描述:
1.周期软件定时器超时添加一个startTime字段,用于记录当前软件定时器的开始计时的时间,
在定时器响应时,开始时间修改为上一次响应的结束时间(消除了中断执行时间对软件定时器
的影响)。
2. 在执行tick中断的过程当中,持有tick动态计算锁,保证在该过程中不会触发tick周期
的计算,在tick中断结束时统一计算设置。 --- 提升tick中断的执行效率
3. 在设置tick周期时,减掉tick中断执行的时间,减小周期动态化带来的时间误差
4.新增LOSCFG_BASE_CORE_TICK_PER_SECOND_MINI配置宏,用于配置tick中断的最小响应精度
Close #I3YGP1
Signed-off-by: zhushengle <zhushengle@huawei.com>
Change-Id: Ia53e4accce497bce870557c2c3387ce51fa3fed3
This commit is contained in:
@@ -65,6 +65,22 @@ extern "C" {
|
||||
#define LOSCFG_BASE_CORE_TICK_PER_SECOND (100UL)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @ingroup los_config
|
||||
* Minimum response error accuracy of tick interrupts, number of ticks in one second.
|
||||
*/
|
||||
#ifndef LOSCFG_BASE_CORE_TICK_PER_SECOND_MINI
|
||||
#define LOSCFG_BASE_CORE_TICK_PER_SECOND_MINI (1000UL) /* 1ms */
|
||||
#endif
|
||||
|
||||
#if (LOSCFG_BASE_CORE_TICK_PER_SECOND > LOSCFG_BASE_CORE_TICK_PER_SECOND_MINI)
|
||||
#error "LOSCFG_BASE_CORE_TICK_PER_SECOND_MINI must be greater than LOSCFG_BASE_CORE_TICK_PER_SECOND"
|
||||
#endif
|
||||
|
||||
#if (LOSCFG_BASE_CORE_TICK_PER_SECOND_MINI > 1000UL)
|
||||
#error "LOSCFG_BASE_CORE_TICK_PER_SECOND_MINI must be less than or equal to 1000"
|
||||
#endif
|
||||
|
||||
#if defined(LOSCFG_BASE_CORE_TICK_PER_SECOND) && \
|
||||
((LOSCFG_BASE_CORE_TICK_PER_SECOND < 1UL) || (LOSCFG_BASE_CORE_TICK_PER_SECOND > 1000000000UL))
|
||||
#error "LOSCFG_BASE_CORE_TICK_PER_SECOND SHOULD big than 0, and less than 1000000000UL"
|
||||
|
||||
@@ -42,14 +42,18 @@ extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#define OS_SCHED_MINI_PERIOD (OS_SYS_CLOCK / LOSCFG_BASE_CORE_TICK_PER_SECOND_MINI)
|
||||
#define OS_TICK_RESPONSE_PRECISION (UINT32)((OS_SCHED_MINI_PERIOD * 75) / 100)
|
||||
#define OS_SCHED_MAX_RESPONSE_TIME (UINT64)(((UINT64)-1) - 1U)
|
||||
|
||||
extern UINT32 g_taskScheduled;
|
||||
typedef BOOL (*SchedScan)(VOID);
|
||||
|
||||
extern UINT64 g_sysSchedStartTime;
|
||||
|
||||
VOID OsSchedUpdateSchedTimeBase(VOID);
|
||||
|
||||
UINT64 OsGetCurrSchedTimeCycle(VOID);
|
||||
UINT64 OsGetCurrSysTimeCycle(VOID);
|
||||
|
||||
VOID OsSchedSetIdleTaskSchedParam(LosTaskCB *idleTask);
|
||||
|
||||
@@ -87,6 +91,15 @@ UINT32 OsSchedRealSleepTimeSet(VOID (*func)(UINT64));
|
||||
|
||||
VOID OsSchedTimerBaseReset(UINT64 currTime);
|
||||
|
||||
STATIC INLINE UINT64 OsGetCurrSchedTimeCycle(VOID)
|
||||
{
|
||||
if (g_sysSchedStartTime == 0) {
|
||||
return g_sysSchedStartTime;
|
||||
}
|
||||
|
||||
return (OsGetCurrSysTimeCycle() - g_sysSchedStartTime);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup los_sched
|
||||
* @brief Get the time, in nanoseconds, remaining before the next tick interrupt response.
|
||||
|
||||
@@ -57,6 +57,15 @@ typedef struct {
|
||||
|
||||
#define OS_SORT_LINK_INVALID_TIME ((UINT64)-1)
|
||||
#define SET_SORTLIST_VALUE(sortList, value) (((SortLinkList *)(sortList))->responseTime = (value))
|
||||
#define GET_SORTLIST_VALUE(sortList) (((SortLinkList *)(sortList))->responseTime)
|
||||
|
||||
STATIC INLINE UINT64 OsSortLinkGetRemainTime(UINT64 currTime, const SortLinkList *targetSortList)
|
||||
{
|
||||
if (currTime >= targetSortList->responseTime) {
|
||||
return 0;
|
||||
}
|
||||
return (targetSortList->responseTime - currTime);
|
||||
}
|
||||
|
||||
SortLinkAttribute *OsGetSortLinkAttribute(SortLinkType type);
|
||||
UINT64 OsGetNextExpireTime(UINT64 startTime);
|
||||
|
||||
@@ -276,12 +276,12 @@ typedef struct tagSwTmrCtrl {
|
||||
UINT8 ucSensitive; /* align enable */
|
||||
#endif
|
||||
UINT32 usTimerID; /* Software timer ID */
|
||||
UINT32 uwCount; /* Times that a software timer works */
|
||||
UINT32 uwInterval; /* Timeout interval of a periodic software timer */
|
||||
UINT32 uwArg; /* Parameter passed in when the callback function
|
||||
that handles software timer timeout is called */
|
||||
SWTMR_PROC_FUNC pfnHandler; /* Callback function that handles software timer timeout */
|
||||
SortLinkList stSortList;
|
||||
UINT64 startTime;
|
||||
} SWTMR_CTRL_S;
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user