更新日期: 2022/06/01 来源: https://gitee.com/weharmony/kernel_liteos_a_note
los_swtmr.c 文件参考

软定时器主文件 更多...

浏览源代码.

结构体

struct  SwtmrRunqueue
 

函数

STATIC INLINE VOID SwtmrDelete (SWTMR_CTRL_S *swtmr)
 
STATIC INLINE UINT64 SwtmrToStart (SWTMR_CTRL_S *swtmr, UINT16 cpuid)
 
LITE_OS_SEC_BSS SPIN_LOCK_INIT (g_swtmrSpin)
 初始化软时钟自旋锁,只有SMP情况才需要,只要是自旋锁都是用于CPU多核的同步 更多...
 
BOOL OsSwtmrDebugDataUsed (UINT32 swtmrID)
 
UINT32 OsSwtmrDebugDataGet (UINT32 swtmrID, SwtmrDebugData *data, UINT32 len, UINT8 *mode)
 
STATIC VOID SwtmrDebugDataInit (VOID)
 
STATIC INLINE VOID SwtmrDebugDataUpdate (SWTMR_CTRL_S *swtmr, UINT32 ticks, UINT32 times)
 
STATIC INLINE VOID SwtmrDebugDataStart (SWTMR_CTRL_S *swtmr, UINT16 cpuid)
 
STATIC INLINE VOID SwtmrDebugWaitTimeCalculate (UINT32 swtmrID, SwtmrHandlerItemPtr swtmrHandler)
 
STATIC INLINE VOID SwtmrDebugDataClear (UINT32 swtmrID)
 
STATIC INLINE VOID SwtmrHandler (SwtmrHandlerItemPtr swtmrHandle)
 
STATIC INLINE VOID SwtmrWake (SwtmrRunqueue *srq, UINT64 startTime, SortLinkList *sortList)
 
STATIC INLINE VOID ScanSwtmrTimeList (SwtmrRunqueue *srq)
 
STATIC VOID SwtmrTask (VOID)
 软时钟的入口函数,拥有任务的最高优先级 0 级! 更多...
 
STATIC UINT32 SwtmrTaskCreate (UINT16 cpuid, UINT32 *swtmrTaskID)
 创建软时钟任务,每个cpu core都可以拥有自己的软时钟任务 更多...
 
UINT32 OsSwtmrTaskIDGetByCpuid (UINT16 cpuid)
 
BOOL OsIsSwtmrTask (const LosTaskCB *taskCB)
 
LITE_OS_SEC_TEXT_INIT VOID OsSwtmrRecycle (UINT32 processID)
 回收指定进程的软时钟 更多...
 
STATIC UINT32 SwtmrBaseInit (VOID)
 软时钟初始化 ,注意函数在多CPU情况下会执行多次 更多...
 
LITE_OS_SEC_TEXT_INIT UINT32 OsSwtmrInit (VOID)
 
STATIC INLINE VOID FindIdleSwtmrRunqueue (UINT16 *idleCpuid)
 
STATIC INLINE VOID AddSwtmr2TimeList (SortLinkList *node, UINT64 responseTime, UINT16 cpuid)
 
STATIC INLINE VOID DeSwtmrFromTimeList (SortLinkList *node)
 
STATIC VOID SwtmrAdjustCheck (UINT16 cpuid, UINT64 responseTime)
 
STATIC INLINE VOID SwtmrStart (SWTMR_CTRL_S *swtmr)
 
STATIC INLINE VOID SwtmrRestart (UINT64 startTime, SortLinkList *sortList, UINT16 cpuid)
 
VOID OsSwtmrResponseTimeReset (UINT64 startTime)
 
STATIC INLINE BOOL SwtmrRunqueueFind (SortLinkAttribute *swtmrSortLink, SCHED_TL_FIND_FUNC checkFunc, UINTPTR arg)
 
STATIC BOOL SwtmrTimeListFind (SCHED_TL_FIND_FUNC checkFunc, UINTPTR arg)
 
BOOL OsSwtmrWorkQueueFind (SCHED_TL_FIND_FUNC checkFunc, UINTPTR arg)
 
LITE_OS_SEC_TEXT UINT32 OsSwtmrGetNextTimeout (VOID)
 Scan a software timer. 更多...
 
STATIC VOID SwtmrStop (SWTMR_CTRL_S *swtmr)
 
LITE_OS_SEC_TEXT STATIC UINT32 OsSwtmrTimeGet (const SWTMR_CTRL_S *swtmr)
 
LITE_OS_SEC_TEXT_INIT UINT32 LOS_SwtmrCreate (UINT32 interval, UINT8 mode, SWTMR_PROC_FUNC handler, UINT16 *swtmrID, UINTPTR arg)
 创建定时器,设置定时器的定时时长、定时器模式、回调函数,并返回定时器ID 更多...
 
LITE_OS_SEC_TEXT UINT32 LOS_SwtmrStart (UINT16 swtmrID)
 接口函数 启动定时器 参数定时任务ID 更多...
 
LITE_OS_SEC_TEXT UINT32 LOS_SwtmrStop (UINT16 swtmrID)
 接口函数 停止定时器 参数定时任务ID 更多...
 
LITE_OS_SEC_TEXT UINT32 LOS_SwtmrTimeGet (UINT16 swtmrID, UINT32 *tick)
 接口函数 获得软件定时器剩余Tick数 通过 *tick 带走 更多...
 
LITE_OS_SEC_TEXT UINT32 LOS_SwtmrDelete (UINT16 swtmrID)
 接口函数 删除定时器 更多...
 

变量

LITE_OS_SEC_BSS SWTMR_CTRL_Sg_swtmrCBArray = NULL
 
LITE_OS_SEC_BSS UINT8g_swtmrHandlerPool = NULL
 
LITE_OS_SEC_BSS LOS_DL_LIST g_swtmrFreeList
 
STATIC SwtmrRunqueue g_swtmrRunqueue [LOSCFG_KERNEL_CORE_NUM]
 
STATIC SwtmrDebugDatag_swtmrDebugData = NULL
 

详细描述

软定时器主文件


注意
基本概念 
    软件定时器,是基于系统Tick时钟中断且由软件来模拟的定时器。当经过设定的Tick数后,会触发用户自定义的回调函数。
    硬件定时器受硬件的限制,数量上不足以满足用户的实际需求。因此为了满足用户需求,提供更多的定时器,
    软件定时器功能,支持如下特性:
        创建软件定时器。
        启动软件定时器。
        停止软件定时器。
        删除软件定时器。
        获取软件定时器剩余Tick数。
        可配置支持的软件定时器个数。
        
    运作机制 
        软件定时器是系统资源,在模块初始化的时候已经分配了一块连续内存。
        软件定时器使用了系统的一个队列和一个任务资源,软件定时器的触发遵循队列规则,
        先进先出。定时时间短的定时器总是比定时时间长的靠近队列头,满足优先触发的准则。
        软件定时器以Tick为基本计时单位,当创建并启动一个软件定时器时,Huawei LiteOS会根据 
        当前系统Tick时间及设置的定时时长确定该定时器的到期Tick时间,并将该定时器控制结构挂入计时全局链表。
        当Tick中断到来时,在Tick中断处理函数中扫描软件定时器的计时全局链表,检查是否有定时器超时,
        若有则将超时的定时器记录下来。Tick中断处理函数结束后,软件定时器任务(优先级为最高)
        被唤醒,在该任务中调用已经记录下来的定时器的回调函数。
 
    定时器状态 
        OS_SWTMR_STATUS_UNUSED(定时器未使用)
        系统在定时器模块初始化时,会将系统中所有定时器资源初始化成该状态。
 
        OS_SWTMR_STATUS_TICKING(定时器处于计数状态)
        在定时器创建后调用LOS_SwtmrStart接口启动,定时器将变成该状态,是定时器运行时的状态。
 
        OS_SWTMR_STATUS_CREATED(定时器创建后未启动,或已停止)
        定时器创建后,不处于计数状态时,定时器将变成该状态。
 
    软件定时器提供了三类模式:
        单次触发定时器,这类定时器在启动后只会触发一次定时器事件,然后定时器自动删除。
        周期触发定时器,这类定时器会周期性的触发定时器事件,直到用户手动停止定时器,否则将永远持续执行下去。
        单次触发定时器,但这类定时器超时触发后不会自动删除,需要调用定时器删除接口删除定时器。
 
    使用场景 
        创建一个单次触发的定时器,超时后执行用户自定义的回调函数。
        创建一个周期性触发的定时器,超时后执行用户自定义的回调函数。
 
     软件定时器的典型开发流程 
         通过make menuconfig配置软件定时器 
         创建定时器LOS_SwtmrCreate,设置定时器的定时时长、定时器模式、超时后的回调函数。
         启动定时器LOS_SwtmrStart。
         获得软件定时器剩余Tick数LOS_SwtmrTimeGet。
         停止定时器LOS_SwtmrStop。
         删除定时器LOS_SwtmrDelete。
 
     注意事项 
         软件定时器的回调函数中不应执行过多操作,不建议使用可能引起任务挂起或者阻塞的接口或操作, 
         如果使用会导致软件定时器响应不及时,造成的影响无法确定。
         软件定时器使用了系统的一个队列和一个任务资源。软件定时器任务的优先级设定为0,且不允许修改 。
         系统可配置的软件定时器个数是指:整个系统可使用的软件定时器总个数,并非用户可使用的软件定时器个数。
         例如:系统多占用一个软件定时器,那么用户能使用的软件定时器资源就会减少一个。
         创建单次不自删除属性的定时器,用户需要自行调用定时器删除接口删除定时器,回收定时器资源,避免资源泄露。
         软件定时器的定时精度与系统Tick时钟的周期有关。

在文件 los_swtmr.c 中定义.

函数说明

◆ AddSwtmr2TimeList()

STATIC INLINE VOID AddSwtmr2TimeList ( SortLinkList node,
UINT64  responseTime,
UINT16  cpuid 
)

在文件 los_swtmr.c491 行定义.

492{
493 SwtmrRunqueue *srq = &g_swtmrRunqueue[cpuid];
494 OsAdd2SortLink(&srq->swtmrSortLink, node, responseTime, cpuid);
495}
STATIC SwtmrRunqueue g_swtmrRunqueue[LOSCFG_KERNEL_CORE_NUM]
Definition: los_swtmr.c:127
SortLinkAttribute swtmrSortLink
Definition: los_swtmr.c:122
函数调用图:
这是这个函数的调用关系图:

◆ DeSwtmrFromTimeList()

STATIC INLINE VOID DeSwtmrFromTimeList ( SortLinkList node)

在文件 los_swtmr.c497 行定义.

498{
499#ifdef LOSCFG_KERNEL_SMP
500 UINT16 cpuid = OsGetSortLinkNodeCpuid(node);
501#else
502 UINT16 cpuid = 0;
503#endif
504 SwtmrRunqueue *srq = &g_swtmrRunqueue[cpuid];
506 return;
507}
unsigned short UINT16
Definition: los_typedef.h:56
函数调用图:
这是这个函数的调用关系图:

◆ FindIdleSwtmrRunqueue()

STATIC INLINE VOID FindIdleSwtmrRunqueue ( UINT16 idleCpuid)

在文件 los_swtmr.c474 行定义.

475{
476 SwtmrRunqueue *idleRq = &g_swtmrRunqueue[0];
477 UINT32 nodeNum = OsGetSortLinkNodeNum(&idleRq->swtmrSortLink);
478 UINT16 cpuid = 1;
479 do {
480 SwtmrRunqueue *srq = &g_swtmrRunqueue[cpuid];
482 if (nodeNum > temp) {
483 *idleCpuid = cpuid;
484 nodeNum = temp;
485 }
486 cpuid++;
487 } while (cpuid < LOSCFG_KERNEL_CORE_NUM);
488}
unsigned int UINT32
Definition: los_typedef.h:57
函数调用图:
这是这个函数的调用关系图:

◆ OsIsSwtmrTask()

BOOL OsIsSwtmrTask ( const LosTaskCB taskCB)

在文件 los_swtmr.c383 行定义.

384{
385 if (taskCB->taskEntry == (TSK_ENTRY_FUNC)SwtmrTask) {
386 return TRUE;
387 }
388 return FALSE;
389}
VOID *(* TSK_ENTRY_FUNC)(UINTPTR param1, UINTPTR param2, UINTPTR param3, UINTPTR param4)
Define the type of a task entrance function.
Definition: los_task.h:480
STATIC VOID SwtmrTask(VOID)
软时钟的入口函数,拥有任务的最高优先级 0 级!
Definition: los_swtmr.c:325
TSK_ENTRY_FUNC taskEntry
函数调用图:
这是这个函数的调用关系图:

◆ OsSwtmrDebugDataGet()

UINT32 OsSwtmrDebugDataGet ( UINT32  swtmrID,
SwtmrDebugData data,
UINT32  len,
UINT8 mode 
)

在文件 los_swtmr.c142 行定义.

143{
144 UINT32 intSave;
145 errno_t ret;
146
147 if ((swtmrID > LOSCFG_BASE_CORE_SWTMR_LIMIT) || (data == NULL) ||
148 (mode == NULL) || (len < sizeof(SwtmrDebugData))) {
149 return LOS_NOK;
150 }
151
152 SWTMR_CTRL_S *swtmr = &g_swtmrCBArray[swtmrID];
153 SWTMR_LOCK(intSave);
154 ret = memcpy_s(data, len, &g_swtmrDebugData[swtmrID], sizeof(SwtmrDebugData));
155 *mode = swtmr->ucMode;
156 SWTMR_UNLOCK(intSave);
157 if (ret != EOK) {
158 return LOS_NOK;
159 }
160 return LOS_OK;
161}
LITE_OS_SEC_BSS SWTMR_CTRL_S * g_swtmrCBArray
Definition: los_swtmr.c:112
STATIC SwtmrDebugData * g_swtmrDebugData
Definition: los_swtmr.c:131
UINT8 ucMode
Definition: los_swtmr.h:270
这是这个函数的调用关系图:

◆ OsSwtmrDebugDataUsed()

BOOL OsSwtmrDebugDataUsed ( UINT32  swtmrID)

在文件 los_swtmr.c133 行定义.

134{
135 if (swtmrID > LOSCFG_BASE_CORE_SWTMR_LIMIT) {
136 return FALSE;
137 }
138
139 return g_swtmrDebugData[swtmrID].swtmrUsed;
140}
这是这个函数的调用关系图:

◆ OsSwtmrGetNextTimeout()

LITE_OS_SEC_TEXT UINT32 OsSwtmrGetNextTimeout ( VOID  )

Scan a software timer.

Description:
  • This API is used to scan a software timer when a Tick interrupt occurs and determine whether the software timer expires.
注意
  • None.
参数
None.
返回值
None.
Dependency:
参见
LOS_SwtmrStop

在文件 los_swtmr.c675 行定义.

676{
677 UINT64 currTime = OsGetCurrSchedTimeCycle();
679 UINT64 time = (OsSortLinkGetNextExpireTime(currTime, &srq->swtmrSortLink) / OS_CYCLE_PER_TICK);
680 if (time > OS_INVALID_VALUE) {
681 time = OS_INVALID_VALUE;
682 }
683 return (UINT32)time;
684}
STATIC INLINE UINT32 ArchCurrCpuid(VOID)
Definition: los_hw_cpu.h:168
STATIC INLINE UINT64 OsGetCurrSchedTimeCycle(VOID)
Definition: los_sched_pri.h:75
long unsigned int UINT64
Definition: los_typedef.h:66
time_t time(time_t *t)
Definition: time.c:1224
函数调用图:

◆ OsSwtmrInit()

LITE_OS_SEC_TEXT_INIT UINT32 OsSwtmrInit ( VOID  )

在文件 los_swtmr.c441 行定义.

442{
443 UINT32 ret;
444 UINT32 cpuid = ArchCurrCpuid();
445 UINT32 swtmrTaskID;
446
447 if (cpuid == 0) {
448 ret = SwtmrBaseInit();
449 if (ret != LOS_OK) {
450 goto ERROR;
451 }
452 }
453
454 ret = SwtmrTaskCreate(cpuid, &swtmrTaskID);
455 if (ret != LOS_OK) {
456 ret = LOS_ERRNO_SWTMR_TASK_CREATE_FAILED;
457 goto ERROR;
458 }
459
460 SwtmrRunqueue *srq = &g_swtmrRunqueue[cpuid];
461 srq->swtmrTask = OsGetTaskCB(swtmrTaskID);
462 return LOS_OK;
463
464ERROR:
465 PRINT_ERR("OsSwtmrInit error! ret = %u\n", ret);
467 g_swtmrCBArray = NULL;
469 g_swtmrHandlerPool = NULL;
470 return ret;
471}
UINT8 * m_aucSysMem1
系统动态内存池地址的起始地址 @note_thinking 能否不要用 0,1来命名核心变量 ???
Definition: los_memory.c:108
UINT32 LOS_MemFree(VOID *pool, VOID *ptr)
释放从指定动态内存中申请的内存
Definition: los_memory.c:1369
UINT8 * m_aucSysMem0
异常交互动态内存池地址的起始地址,当不支持异常交互特性时,m_aucSysMem0等于m_aucSysMem1。
Definition: los_memory.c:107
STATIC UINT32 SwtmrBaseInit(VOID)
软时钟初始化 ,注意函数在多CPU情况下会执行多次
Definition: los_swtmr.c:400
STATIC UINT32 SwtmrTaskCreate(UINT16 cpuid, UINT32 *swtmrTaskID)
创建软时钟任务,每个cpu core都可以拥有自己的软时钟任务
Definition: los_swtmr.c:356
LITE_OS_SEC_BSS UINT8 * g_swtmrHandlerPool
Definition: los_swtmr.c:113
STATIC INLINE LosTaskCB * OsGetTaskCB(UINT32 taskID)
通过任务ID获取任务实体,task由任务池分配,本质是个数组,彼此都挨在一块
Definition: los_task_pri.h:250
LosTaskCB * swtmrTask
Definition: los_swtmr.c:123
函数调用图:
这是这个函数的调用关系图:

◆ OsSwtmrRecycle()

LITE_OS_SEC_TEXT_INIT VOID OsSwtmrRecycle ( UINT32  processID)

回收指定进程的软时钟

在文件 los_swtmr.c391 行定义.

392{
393 for (UINT16 index = 0; index < LOSCFG_BASE_CORE_SWTMR_LIMIT; index++) {//一个进程往往会有多个定时器
394 if (g_swtmrCBArray[index].uwOwnerPid == processID) {//找到一个
395 LOS_SwtmrDelete(index);//删除定时器
396 }
397 }
398}
LITE_OS_SEC_TEXT UINT32 LOS_SwtmrDelete(UINT16 swtmrID)
接口函数 删除定时器
Definition: los_swtmr.c:889
函数调用图:
这是这个函数的调用关系图:

◆ OsSwtmrResponseTimeReset()

VOID OsSwtmrResponseTimeReset ( UINT64  startTime)

在文件 los_swtmr.c610 行定义.

611{
612 UINT16 cpuid = ArchCurrCpuid();
613 SortLinkAttribute *swtmrSortLink = &g_swtmrRunqueue[cpuid].swtmrSortLink;
614 LOS_DL_LIST *listHead = &swtmrSortLink->sortLink;
615 LOS_DL_LIST *listNext = listHead->pstNext;
616
617 LOS_SpinLock(&swtmrSortLink->spinLock);
618 while (listNext != listHead) {
619 SortLinkList *sortList = LOS_DL_LIST_ENTRY(listNext, SortLinkList, sortLinkNode);
620 OsDeleteNodeSortLink(swtmrSortLink, sortList);
621 LOS_SpinUnlock(&swtmrSortLink->spinLock);
622
623 SwtmrRestart(startTime, sortList, cpuid);
624
625 LOS_SpinLock(&swtmrSortLink->spinLock);
626 listNext = listNext->pstNext;
627 }
628 LOS_SpinUnlock(&swtmrSortLink->spinLock);
629}
VOID LOS_SpinLock(SPIN_LOCK_S *lock)
Definition: los_spinlock.c:50
VOID LOS_SpinUnlock(SPIN_LOCK_S *lock)
Definition: los_spinlock.c:84
STATIC INLINE VOID SwtmrRestart(UINT64 startTime, SortLinkList *sortList, UINT16 cpuid)
Definition: los_swtmr.c:599
struct LOS_DL_LIST * pstNext
Definition: los_list.h:84
函数调用图:
这是这个函数的调用关系图:

◆ OsSwtmrTaskIDGetByCpuid()

UINT32 OsSwtmrTaskIDGetByCpuid ( UINT16  cpuid)

在文件 los_swtmr.c378 行定义.

379{
380 return g_swtmrRunqueue[cpuid].swtmrTask->taskID;
381}
UINT32 taskID

◆ OsSwtmrTimeGet()

LITE_OS_SEC_TEXT STATIC UINT32 OsSwtmrTimeGet ( const SWTMR_CTRL_S swtmr)

在文件 los_swtmr.c702 行定义.

703{
704 UINT64 currTime = OsGetCurrSchedTimeCycle();
705 UINT64 time = (OsSortLinkGetTargetExpireTime(currTime, &swtmr->stSortList) / OS_CYCLE_PER_TICK);
706 if (time > OS_INVALID_VALUE) {
707 time = OS_INVALID_VALUE;
708 }
709 return (UINT32)time;
710}
SortLinkList stSortList
通过它挂到对应CPU核定时器链表上
Definition: los_swtmr.h:268
函数调用图:
这是这个函数的调用关系图:

◆ OsSwtmrWorkQueueFind()

BOOL OsSwtmrWorkQueueFind ( SCHED_TL_FIND_FUNC  checkFunc,
UINTPTR  arg 
)

在文件 los_swtmr.c661 行定义.

662{
663 UINT32 intSave;
664
665 SWTMR_LOCK(intSave);
666 BOOL find = SwtmrTimeListFind(checkFunc, arg);
667 SWTMR_UNLOCK(intSave);
668 return find;
669}
STATIC BOOL SwtmrTimeListFind(SCHED_TL_FIND_FUNC checkFunc, UINTPTR arg)
Definition: los_swtmr.c:650
size_t BOOL
Definition: los_typedef.h:88
函数调用图:

◆ ScanSwtmrTimeList()

STATIC INLINE VOID ScanSwtmrTimeList ( SwtmrRunqueue srq)

在文件 los_swtmr.c282 行定义.

283{
284 UINT32 intSave;
285 SortLinkAttribute *swtmrSortLink = &srq->swtmrSortLink;
286 LOS_DL_LIST *listObject = &swtmrSortLink->sortLink;
287
288 /*
289 * it needs to be carefully coped with, since the swtmr is in specific sortlink
290 * while other cores still has the chance to process it, like stop the timer.
291 */
292 LOS_SpinLockSave(&swtmrSortLink->spinLock, &intSave);
293
294 if (LOS_ListEmpty(listObject)) {
295 LOS_SpinUnlockRestore(&swtmrSortLink->spinLock, intSave);
296 return;
297 }
298 SortLinkList *sortList = LOS_DL_LIST_ENTRY(listObject->pstNext, SortLinkList, sortLinkNode);
299
300 UINT64 currTime = OsGetCurrSchedTimeCycle();
301 while (sortList->responseTime <= currTime) {
302 sortList = LOS_DL_LIST_ENTRY(listObject->pstNext, SortLinkList, sortLinkNode);
303 UINT64 startTime = GET_SORTLIST_VALUE(sortList);
304 OsDeleteNodeSortLink(swtmrSortLink, sortList);
305 LOS_SpinUnlockRestore(&swtmrSortLink->spinLock, intSave);
306
307 SwtmrWake(srq, startTime, sortList);
308
309 LOS_SpinLockSave(&swtmrSortLink->spinLock, &intSave);
310 if (LOS_ListEmpty(listObject)) {
311 break;
312 }
313
314 sortList = LOS_DL_LIST_ENTRY(listObject->pstNext, SortLinkList, sortLinkNode);
315 }
316
317 LOS_SpinUnlockRestore(&swtmrSortLink->spinLock, intSave);
318 return;
319}
LITE_OS_SEC_ALW_INLINE STATIC INLINE BOOL LOS_ListEmpty(LOS_DL_LIST *list)
Identify whether a specified doubly linked list is empty. | 判断链表是否为空
Definition: los_list.h:321
VOID LOS_SpinUnlockRestore(SPIN_LOCK_S *lock, UINT32 intSave)
Definition: los_spinlock.c:108
VOID LOS_SpinLockSave(SPIN_LOCK_S *lock, UINT32 *intSave)
Definition: los_spinlock.c:98
STATIC INLINE VOID SwtmrWake(SwtmrRunqueue *srq, UINT64 startTime, SortLinkList *sortList)
Definition: los_swtmr.c:248
函数调用图:
这是这个函数的调用关系图:

◆ SPIN_LOCK_INIT()

LITE_OS_SEC_BSS SPIN_LOCK_INIT ( g_swtmrSpin  )

初始化软时钟自旋锁,只有SMP情况才需要,只要是自旋锁都是用于CPU多核的同步

◆ SwtmrAdjustCheck()

STATIC VOID SwtmrAdjustCheck ( UINT16  cpuid,
UINT64  responseTime 
)

在文件 los_swtmr.c509 行定义.

510{
511 UINT32 ret;
512 UINT32 intSave;
513 SwtmrRunqueue *srq = &g_swtmrRunqueue[cpuid];
514 SCHEDULER_LOCK(intSave);
515 if ((srq->swtmrTask == NULL) || !OsTaskIsBlocked(srq->swtmrTask)) {
516 SCHEDULER_UNLOCK(intSave);
517 return;
518 }
519
520 if (responseTime >= GET_SORTLIST_VALUE(&srq->swtmrTask->sortList)) {
521 SCHEDULER_UNLOCK(intSave);
522 return;
523 }
524
525 ret = OsSchedTimeoutQueueAdjust(srq->swtmrTask, responseTime);
526 SCHEDULER_UNLOCK(intSave);
527 if (ret != LOS_OK) {
528 return;
529 }
530
531 if (cpuid == ArchCurrCpuid()) {
533 } else {
534 LOS_MpSchedule(CPUID_TO_AFFI_MASK(cpuid));
535 }
536}
VOID LOS_MpSchedule(UINT32 target)
Definition: los_mp.c:76
VOID OsSchedExpireTimeUpdate(VOID)
Definition: los_sched.c:88
STATIC INLINE UINT32 OsSchedTimeoutQueueAdjust(LosTaskCB *taskCB, UINT64 responseTime)
STATIC INLINE BOOL OsTaskIsBlocked(const LosTaskCB *taskCB)
SortLinkList sortList
函数调用图:
这是这个函数的调用关系图:

◆ SwtmrBaseInit()

STATIC UINT32 SwtmrBaseInit ( VOID  )

软时钟初始化 ,注意函数在多CPU情况下会执行多次

在文件 los_swtmr.c400 行定义.

401{
402 UINT32 ret;
403 UINT32 size = sizeof(SWTMR_CTRL_S) * LOSCFG_BASE_CORE_SWTMR_LIMIT;
404 SWTMR_CTRL_S *swtmr = (SWTMR_CTRL_S *)LOS_MemAlloc(m_aucSysMem0, size); /* system resident resource */
405 if (swtmr == NULL) {
406 return LOS_ERRNO_SWTMR_NO_MEMORY;
407 }
408
409 (VOID)memset_s(swtmr, size, 0, size);//清0
410 g_swtmrCBArray = swtmr;//软时钟
411 LOS_ListInit(&g_swtmrFreeList);//初始化空闲链表
412 for (UINT16 index = 0; index < LOSCFG_BASE_CORE_SWTMR_LIMIT; index++, swtmr++) {
413 swtmr->usTimerID = index;//按顺序赋值
414 LOS_ListTailInsert(&g_swtmrFreeList, &swtmr->stSortList.sortLinkNode);//通过sortLinkNode将节点挂到空闲链表
415 }
416 //想要用静态内存池管理,就必须要使用LOS_MEMBOX_SIZE来计算申请的内存大小,因为需要点前缀内存承载头部信息.
417 size = LOS_MEMBOX_SIZE(sizeof(SwtmrHandlerItem), OS_SWTMR_HANDLE_QUEUE_SIZE);//规划一片内存区域作为软时钟处理函数的静态内存池。
418 g_swtmrHandlerPool = (UINT8 *)LOS_MemAlloc(m_aucSysMem1, size); /* system resident resource */
419 if (g_swtmrHandlerPool == NULL) {
420 return LOS_ERRNO_SWTMR_NO_MEMORY;
421 }
422
424 if (ret != LOS_OK) {
425 return LOS_ERRNO_SWTMR_HANDLER_POOL_NO_MEM;
426 }
427
428 for (UINT16 index = 0; index < LOSCFG_KERNEL_CORE_NUM; index++) {
429 SwtmrRunqueue *srq = &g_swtmrRunqueue[index];
430 /* The linked list of all cores must be initialized at core 0 startup for load balancing */
433 srq->swtmrTask = NULL;
434 }
435
437
438 return LOS_OK;
439}
LITE_OS_SEC_ALW_INLINE STATIC INLINE VOID LOS_ListInit(LOS_DL_LIST *list)
Definition: los_list.h:104
LITE_OS_SEC_ALW_INLINE STATIC INLINE VOID LOS_ListTailInsert(LOS_DL_LIST *list, LOS_DL_LIST *node)
Insert a node to the tail of a doubly linked list.
Definition: los_list.h:244
LITE_OS_SEC_TEXT_INIT UINT32 LOS_MemboxInit(VOID *pool, UINT32 poolSize, UINT32 blkSize)
初始化一个静态内存池,根据入参设定其起始地址、总大小及每个内存块大小
Definition: los_membox.c:106
VOID * LOS_MemAlloc(VOID *pool, UINT32 size)
从指定内存池中申请size长度的内存,注意这可不是从内核堆空间中申请内存
Definition: los_memory.c:1123
struct tagSwTmrCtrl SWTMR_CTRL_S
LITE_OS_SEC_BSS LOS_DL_LIST g_swtmrFreeList
Definition: los_swtmr.c:114
STATIC VOID SwtmrDebugDataInit(VOID)
Definition: los_swtmr.c:164
unsigned char UINT8
Definition: los_typedef.h:55
LOS_DL_LIST swtmrHandlerQueue
Definition: los_swtmr.c:124
UINT16 usTimerID
Definition: los_swtmr.h:271
函数调用图:
这是这个函数的调用关系图:

◆ SwtmrDebugDataClear()

STATIC INLINE VOID SwtmrDebugDataClear ( UINT32  swtmrID)

在文件 los_swtmr.c216 行定义.

217{
218#ifdef LOSCFG_SWTMR_DEBUG
219 (VOID)memset_s(&g_swtmrDebugData[swtmrID], sizeof(SwtmrDebugData), 0, sizeof(SwtmrDebugData));
220#endif
221}
这是这个函数的调用关系图:

◆ SwtmrDebugDataInit()

STATIC VOID SwtmrDebugDataInit ( VOID  )

在文件 los_swtmr.c164 行定义.

165{
166#ifdef LOSCFG_SWTMR_DEBUG
167 UINT32 size = sizeof(SwtmrDebugData) * LOSCFG_BASE_CORE_SWTMR_LIMIT;
169 if (g_swtmrDebugData == NULL) {
170 PRINT_ERR("SwtmrDebugDataInit malloc failed!\n");
171 return;
172 }
173 (VOID)memset_s(g_swtmrDebugData, size, 0, size);
174#endif
175}
函数调用图:
这是这个函数的调用关系图:

◆ SwtmrDebugDataStart()

STATIC INLINE VOID SwtmrDebugDataStart ( SWTMR_CTRL_S swtmr,
UINT16  cpuid 
)

在文件 los_swtmr.c190 行定义.

191{
192#ifdef LOSCFG_SWTMR_DEBUG
194 data->swtmrUsed = TRUE;
195 data->handler = swtmr->pfnHandler;
196 data->cpuid = cpuid;
197#endif
198}
SWTMR_PROC_FUNC handler
SWTMR_PROC_FUNC pfnHandler
Definition: los_swtmr.h:278
这是这个函数的调用关系图:

◆ SwtmrDebugDataUpdate()

STATIC INLINE VOID SwtmrDebugDataUpdate ( SWTMR_CTRL_S swtmr,
UINT32  ticks,
UINT32  times 
)

在文件 los_swtmr.c177 行定义.

178{
179#ifdef LOSCFG_SWTMR_DEBUG
181 if (data->period != ticks) {
182 (VOID)memset_s(&data->base, sizeof(SwtmrDebugBase), 0, sizeof(SwtmrDebugBase));
183 data->period = ticks;
184 }
185 data->base.startTime = swtmr->startTime;
186 data->base.times += times;
187#endif
188}
SwtmrDebugBase base
UINT64 startTime
Definition: los_swtmr.h:280
clock_t times(struct tms *buf)
Definition: time.c:1107
函数调用图:
这是这个函数的调用关系图:

◆ SwtmrDebugWaitTimeCalculate()

STATIC INLINE VOID SwtmrDebugWaitTimeCalculate ( UINT32  swtmrID,
SwtmrHandlerItemPtr  swtmrHandler 
)

在文件 los_swtmr.c200 行定义.

201{
202#ifdef LOSCFG_SWTMR_DEBUG
203 SwtmrDebugBase *data = &g_swtmrDebugData[swtmrID].base;
204 swtmrHandler->swtmrID = swtmrID;
205 UINT64 currTime = OsGetCurrSchedTimeCycle();
206 UINT64 waitTime = currTime - data->startTime;
207 data->waitTime += waitTime;
208 if (waitTime > data->waitTimeMax) {
209 data->waitTimeMax = waitTime;
210 }
211 data->readyStartTime = currTime;
212 data->waitCount++;
213#endif
214}
UINT64 readyStartTime
函数调用图:
这是这个函数的调用关系图:

◆ SwtmrDelete()

STATIC INLINE VOID SwtmrDelete ( SWTMR_CTRL_S swtmr)

在文件 los_swtmr.c590 行定义.

591{
592 /* insert to free list */
593 LOS_ListTailInsert(&g_swtmrFreeList, &swtmr->stSortList.sortLinkNode);//直接插入空闲链表中,回收再利用
594 swtmr->ucState = OS_SWTMR_STATUS_UNUSED;//又干净着呢
595 swtmr->uwOwnerPid = 0;//谁拥有这个定时器? 是 0号进程
597}
STATIC INLINE VOID SwtmrDebugDataClear(UINT32 swtmrID)
Definition: los_swtmr.c:216
@ OS_SWTMR_STATUS_UNUSED
Definition: los_swtmr_pri.h:56
UINT8 ucState
Definition: los_swtmr.h:269
UINT32 uwOwnerPid
Definition: los_swtmr.h:279
函数调用图:
这是这个函数的调用关系图:

◆ SwtmrHandler()

STATIC INLINE VOID SwtmrHandler ( SwtmrHandlerItemPtr  swtmrHandle)

在文件 los_swtmr.c223 行定义.

224{
225#ifdef LOSCFG_SWTMR_DEBUG
226 UINT32 intSave;
227 SwtmrDebugBase *data = &g_swtmrDebugData[swtmrHandle->swtmrID].base;
228 UINT64 startTime = OsGetCurrSchedTimeCycle();
229#endif
230 swtmrHandle->handler(swtmrHandle->arg);
231#ifdef LOSCFG_SWTMR_DEBUG
232 UINT64 runTime = OsGetCurrSchedTimeCycle() - startTime;
233 SWTMR_LOCK(intSave);
234 data->runTime += runTime;
235 if (runTime > data->runTimeMax) {
236 data->runTimeMax = runTime;
237 }
238 runTime = startTime - data->readyStartTime;
239 data->readyTime += runTime;
240 if (runTime > data->readyTimeMax) {
241 data->readyTimeMax = runTime;
242 }
243 data->runCount++;
244 SWTMR_UNLOCK(intSave);
245#endif
246}
SWTMR_PROC_FUNC handler
Definition: los_swtmr_pri.h:66
函数调用图:
这是这个函数的调用关系图:

◆ SwtmrRestart()

STATIC INLINE VOID SwtmrRestart ( UINT64  startTime,
SortLinkList sortList,
UINT16  cpuid 
)

在文件 los_swtmr.c599 行定义.

600{
601 UINT32 intSave;
602
603 SWTMR_CTRL_S *swtmr = LOS_DL_LIST_ENTRY(sortList, SWTMR_CTRL_S, stSortList);
604 SWTMR_LOCK(intSave);
605 swtmr->startTime = startTime;
606 (VOID)SwtmrToStart(swtmr, cpuid);
607 SWTMR_UNLOCK(intSave);
608}
STATIC INLINE UINT64 SwtmrToStart(SWTMR_CTRL_S *swtmr, UINT16 cpuid)
Definition: los_swtmr.c:538
函数调用图:
这是这个函数的调用关系图:

◆ SwtmrRunqueueFind()

STATIC INLINE BOOL SwtmrRunqueueFind ( SortLinkAttribute swtmrSortLink,
SCHED_TL_FIND_FUNC  checkFunc,
UINTPTR  arg 
)

在文件 los_swtmr.c631 行定义.

632{
633 LOS_DL_LIST *listObject = &swtmrSortLink->sortLink;
634 LOS_DL_LIST *list = listObject->pstNext;
635
636 LOS_SpinLock(&swtmrSortLink->spinLock);
637 while (list != listObject) {
638 SortLinkList *listSorted = LOS_DL_LIST_ENTRY(list, SortLinkList, sortLinkNode);
639 if (checkFunc((UINTPTR)listSorted, arg)) {
640 LOS_SpinUnlock(&swtmrSortLink->spinLock);
641 return TRUE;
642 }
643 list = list->pstNext;
644 }
645
646 LOS_SpinUnlock(&swtmrSortLink->spinLock);
647 return FALSE;
648}
unsigned long UINTPTR
Definition: los_typedef.h:68
函数调用图:
这是这个函数的调用关系图:

◆ SwtmrStart()

STATIC INLINE VOID SwtmrStart ( SWTMR_CTRL_S swtmr)

在文件 los_swtmr.c571 行定义.

572{
573 UINT64 responseTime;
574 UINT16 idleCpu = 0;
575#ifdef LOSCFG_KERNEL_SMP
576 FindIdleSwtmrRunqueue(&idleCpu);
577#endif
579 responseTime = SwtmrToStart(swtmr, idleCpu);
580
581 SwtmrDebugDataStart(swtmr, idleCpu);
582
583 SwtmrAdjustCheck(idleCpu, responseTime);
584}
STATIC INLINE VOID FindIdleSwtmrRunqueue(UINT16 *idleCpuid)
Definition: los_swtmr.c:474
STATIC INLINE VOID SwtmrDebugDataStart(SWTMR_CTRL_S *swtmr, UINT16 cpuid)
Definition: los_swtmr.c:190
STATIC VOID SwtmrAdjustCheck(UINT16 cpuid, UINT64 responseTime)
Definition: los_swtmr.c:509
函数调用图:
这是这个函数的调用关系图:

◆ SwtmrStop()

STATIC VOID SwtmrStop ( SWTMR_CTRL_S swtmr)

在文件 los_swtmr.c690 行定义.

691{
693 swtmr->uwOverrun = 0;
694
696}
STATIC INLINE VOID DeSwtmrFromTimeList(SortLinkList *node)
Definition: los_swtmr.c:497
@ OS_SWTMR_STATUS_CREATED
Definition: los_swtmr_pri.h:57
UINT32 uwOverrun
Definition: los_swtmr.h:272
函数调用图:
这是这个函数的调用关系图:

◆ SwtmrTask()

STATIC VOID SwtmrTask ( VOID  )

软时钟的入口函数,拥有任务的最高优先级 0 级!

返回
LITE_OS_SEC_TEXT

在文件 los_swtmr.c325 行定义.

326{
327 SwtmrHandlerItem swtmrHandle;
328 UINT32 intSave;
329 UINT64 waitTime;
330
332 LOS_DL_LIST *head = &srq->swtmrHandlerQueue;
333 for (;;) {//死循环获取队列item,一直读干净为止
335 if (waitTime != 0) {
336 SCHEDULER_LOCK(intSave);
337 srq->swtmrTask->ops->delay(srq->swtmrTask, waitTime);
338 OsHookCall(LOS_HOOK_TYPE_MOVEDTASKTODELAYEDLIST, srq->swtmrTask);
339 SCHEDULER_UNLOCK(intSave);
340 }
341
343
344 while (!LOS_ListEmpty(head)) {
345 SwtmrHandlerItemPtr swtmrHandlePtr = LOS_DL_LIST_ENTRY(LOS_DL_LIST_FIRST(head), SwtmrHandlerItem, node);
346 LOS_ListDelete(&swtmrHandlePtr->node);
347
348 (VOID)memcpy_s(&swtmrHandle, sizeof(SwtmrHandlerItem), swtmrHandlePtr, sizeof(SwtmrHandlerItem));
349 (VOID)LOS_MemboxFree(g_swtmrHandlerPool, swtmrHandlePtr);//静态释放内存,注意在鸿蒙内核只有软时钟注册用到了静态内存
350 SwtmrHandler(&swtmrHandle);
351 }
352 }
353 }
LITE_OS_SEC_ALW_INLINE STATIC INLINE VOID LOS_ListDelete(LOS_DL_LIST *node)
Definition: los_list.h:292
LITE_OS_SEC_TEXT UINT32 LOS_MemboxFree(VOID *pool, VOID *box)
释放指定的一块静态内存块
Definition: los_membox.c:174
STATIC INLINE VOID ScanSwtmrTimeList(SwtmrRunqueue *srq)
Definition: los_swtmr.c:282
STATIC INLINE VOID SwtmrHandler(SwtmrHandlerItemPtr swtmrHandle)
Definition: los_swtmr.c:223
UINT32(* delay)(LosTaskCB *taskCB, UINT64 waitTime)
延时执行
LOS_DL_LIST node
挂入定时器超时队列,详见 SwtmrWake( ... )
Definition: los_swtmr_pri.h:69
const SchedOps * ops
函数调用图:
这是这个函数的调用关系图:

◆ SwtmrTaskCreate()

STATIC UINT32 SwtmrTaskCreate ( UINT16  cpuid,
UINT32 swtmrTaskID 
)

创建软时钟任务,每个cpu core都可以拥有自己的软时钟任务

在文件 los_swtmr.c356 行定义.

357{
358 UINT32 ret;
359 TSK_INIT_PARAM_S swtmrTask;
360
361 (VOID)memset_s(&swtmrTask, sizeof(TSK_INIT_PARAM_S), 0, sizeof(TSK_INIT_PARAM_S));//清0
362 swtmrTask.pfnTaskEntry = (TSK_ENTRY_FUNC)SwtmrTask;//入口函数
363 swtmrTask.uwStackSize = LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE;//16K默认内核任务栈
364 swtmrTask.pcName = "Swt_Task";//任务名称
365 swtmrTask.usTaskPrio = 0;//哇塞! 逮到一个最高优先级的任务 @note_thinking 这里应该用 OS_TASK_PRIORITY_HIGHEST 表示
366 swtmrTask.uwResved = LOS_TASK_STATUS_DETACHED;//分离模式
367#ifdef LOSCFG_KERNEL_SMP
368 swtmrTask.usCpuAffiMask = CPUID_TO_AFFI_MASK(cpuid);//交给当前CPU执行这个任务
369#endif
370 ret = LOS_TaskCreate(swtmrTaskID, &swtmrTask);//创建任务并申请调度
371 if (ret == LOS_OK) {
372 OS_TCB_FROM_TID(*swtmrTaskID)->taskStatus |= OS_TASK_FLAG_SYSTEM_TASK;//告知这是一个系统任务
373 }
374
375 return ret;
376}
struct tagTskInitParam TSK_INIT_PARAM_S
LITE_OS_SEC_TEXT_INIT UINT32 LOS_TaskCreate(UINT32 *taskID, TSK_INIT_PARAM_S *initParam)
创建任务,并使该任务进入ready状态,如果就绪队列中没有更高优先级的任务,则运行该任务
Definition: los_task.c:718
UINT16 usTaskPrio
Definition: los_task.h:505
UINT16 usCpuAffiMask
Definition: los_task.h:511
UINT32 uwStackSize
Definition: los_task.h:508
CHAR * pcName
Definition: los_task.h:509
TSK_ENTRY_FUNC pfnTaskEntry
Definition: los_task.h:504
UINT32 uwResved
Definition: los_task.h:513
函数调用图:
这是这个函数的调用关系图:

◆ SwtmrTimeListFind()

STATIC BOOL SwtmrTimeListFind ( SCHED_TL_FIND_FUNC  checkFunc,
UINTPTR  arg 
)

在文件 los_swtmr.c650 行定义.

651{
652 for (UINT16 cpuid = 0; cpuid < LOSCFG_KERNEL_CORE_NUM; cpuid++) {
654 if (SwtmrRunqueueFind(swtmrSortLink, checkFunc, arg)) {
655 return TRUE;
656 }
657 }
658 return FALSE;
659}
STATIC INLINE BOOL SwtmrRunqueueFind(SortLinkAttribute *swtmrSortLink, SCHED_TL_FIND_FUNC checkFunc, UINTPTR arg)
Definition: los_swtmr.c:631
函数调用图:
这是这个函数的调用关系图:

◆ SwtmrToStart()

STATIC UINT64 SwtmrToStart ( SWTMR_CTRL_S swtmr,
UINT16  cpuid 
)

在文件 los_swtmr.c538 行定义.

539{
540 UINT32 ticks;
541 UINT32 times = 0;
542
543 if ((swtmr->uwOverrun == 0) && ((swtmr->ucMode == LOS_SWTMR_MODE_ONCE) ||
544 (swtmr->ucMode == LOS_SWTMR_MODE_OPP) ||
545 (swtmr->ucMode == LOS_SWTMR_MODE_NO_SELFDELETE))) {//如果是一次性的定时器
546 ticks = swtmr->uwExpiry; //获取时间间隔
547 } else {
548 ticks = swtmr->uwInterval;//获取周期性定时器时间间隔
549 }
550 swtmr->ucState = OS_SWTMR_STATUS_TICKING;//计数状态
551
552 UINT64 period = (UINT64)ticks * OS_CYCLE_PER_TICK;
553 UINT64 responseTime = swtmr->startTime + period;
554 UINT64 currTime = OsGetCurrSchedTimeCycle();
555 if (responseTime < currTime) {
556 times = (UINT32)((currTime - swtmr->startTime) / period);
557 swtmr->startTime += times * period;
558 responseTime = swtmr->startTime + period;
559 PRINT_WARN("Swtmr already timeout! SwtmrID: %u\n", swtmr->usTimerID);
560 }
561
562 AddSwtmr2TimeList(&swtmr->stSortList, responseTime, cpuid);
563 SwtmrDebugDataUpdate(swtmr, ticks, times);
564 return responseTime;
565}
@ LOS_SWTMR_MODE_OPP
Definition: los_swtmr.h:235
@ LOS_SWTMR_MODE_ONCE
Definition: los_swtmr.h:232
@ LOS_SWTMR_MODE_NO_SELFDELETE
Definition: los_swtmr.h:234
STATIC INLINE VOID SwtmrDebugDataUpdate(SWTMR_CTRL_S *swtmr, UINT32 ticks, UINT32 times)
Definition: los_swtmr.c:177
STATIC INLINE VOID AddSwtmr2TimeList(SortLinkList *node, UINT64 responseTime, UINT16 cpuid)
Definition: los_swtmr.c:491
@ OS_SWTMR_STATUS_TICKING
Definition: los_swtmr_pri.h:58
UINT32 uwInterval
Definition: los_swtmr.h:274
UINT32 uwExpiry
Definition: los_swtmr.h:275
函数调用图:
这是这个函数的调用关系图:

◆ SwtmrWake()

STATIC INLINE VOID SwtmrWake ( SwtmrRunqueue srq,
UINT64  startTime,
SortLinkList sortList 
)

在文件 los_swtmr.c248 行定义.

249{
250 UINT32 intSave;
251 SWTMR_CTRL_S *swtmr = LOS_DL_LIST_ENTRY(sortList, SWTMR_CTRL_S, stSortList);
253 LOS_ASSERT(swtmrHandler != NULL);
254
255 OsHookCall(LOS_HOOK_TYPE_SWTMR_EXPIRED, swtmr);
256
257 SWTMR_LOCK(intSave);
258 swtmrHandler->handler = swtmr->pfnHandler;
259 swtmrHandler->arg = swtmr->uwArg;
260 LOS_ListTailInsert(&srq->swtmrHandlerQueue, &swtmrHandler->node);
261 SwtmrDebugWaitTimeCalculate(swtmr->usTimerID, swtmrHandler);
262
263 if (swtmr->ucMode == LOS_SWTMR_MODE_ONCE) {
264 SwtmrDelete(swtmr);
265
266 if (swtmr->usTimerID < (OS_SWTMR_MAX_TIMERID - LOSCFG_BASE_CORE_SWTMR_LIMIT)) {
267 swtmr->usTimerID += LOSCFG_BASE_CORE_SWTMR_LIMIT;
268 } else {
269 swtmr->usTimerID %= LOSCFG_BASE_CORE_SWTMR_LIMIT;
270 }
271 } else if (swtmr->ucMode == LOS_SWTMR_MODE_NO_SELFDELETE) {
273 } else {
274 swtmr->uwOverrun++;
275 swtmr->startTime = startTime;
276 (VOID)SwtmrToStart(swtmr, ArchCurrCpuid());
277 }
278
279 SWTMR_UNLOCK(intSave);
280}
LITE_OS_SEC_TEXT VOID * LOS_MemboxAlloc(VOID *pool)
从指定的静态内存池中申请一块静态内存块,整个内核源码只有 OsSwtmrScan中用到了静态内存.
Definition: los_membox.c:150
STATIC INLINE VOID SwtmrDelete(SWTMR_CTRL_S *swtmr)
Definition: los_swtmr.c:590
STATIC INLINE VOID SwtmrDebugWaitTimeCalculate(UINT32 swtmrID, SwtmrHandlerItemPtr swtmrHandler)
Definition: los_swtmr.c:200
SwtmrHandlerItem * SwtmrHandlerItemPtr
Definition: los_swtmr_pri.h:79
UINTPTR uwArg
Definition: los_swtmr.h:276
函数调用图:
这是这个函数的调用关系图:

变量说明

◆ g_swtmrCBArray

LITE_OS_SEC_BSS SWTMR_CTRL_S* g_swtmrCBArray = NULL

First address in Timer memory space
定时器池

在文件 los_swtmr.c112 行定义.

◆ g_swtmrDebugData

STATIC SwtmrDebugData* g_swtmrDebugData = NULL

在文件 los_swtmr.c131 行定义.

◆ g_swtmrFreeList

LITE_OS_SEC_BSS LOS_DL_LIST g_swtmrFreeList

Free list of Software Timer
空闲定时器链表

在文件 los_swtmr.c114 行定义.

◆ g_swtmrHandlerPool

LITE_OS_SEC_BSS UINT8* g_swtmrHandlerPool = NULL

Pool of Swtmr Handler
用于注册软时钟的回调函数

在文件 los_swtmr.c113 行定义.

◆ g_swtmrRunqueue

STATIC SwtmrRunqueue g_swtmrRunqueue[LOSCFG_KERNEL_CORE_NUM]

在文件 los_swtmr.c127 行定义.