更新日期: 2022/06/01 来源: https://gitee.com/weharmony/kernel_liteos_a_note
Tick
Tick 的协作图:

函数

VOID OsTickHandler (VOID)
 Handle the system tick timeout. 更多...
 
VOID LOS_GetCpuCycle (UINT32 *puwCntHi, UINT32 *puwCntLo)
 Obtain system cycle count. 更多...
 
UINT64 LOS_CurrNanosec (VOID)
 Obtain system time in nanoseconds. 更多...
 
VOID LOS_Udelay (UINT32 usecs)
 spinning-delay in microsecond (us). 更多...
 
VOID LOS_Mdelay (UINT32 usecs)
 spinning-delay in millisecond (ms). 更多...
 

变量

DOUBLE g_cycle2NsScale
 周期转纳秒级 更多...
 

详细描述

函数说明

◆ LOS_CurrNanosec()

UINT64 LOS_CurrNanosec ( VOID  )

Obtain system time in nanoseconds.

Description:
This API is used to obtain system time in nanoseconds.
注意
None.
参数
None.
返回值
UINT64system time in nanoseconds.
Dependency:
  • los_tick.h: the header file that contains the API declaration.
参见

Obtain system time in nanoseconds.

在文件 los_hw_tick.c62 行定义.

63{
64 UINT64 cycle = HalClockGetCycles();
65 return (cycle / g_sysClock) * OS_SYS_NS_PER_SECOND + (cycle % g_sysClock) * OS_SYS_NS_PER_SECOND / g_sysClock;
66}
LITE_OS_SEC_DATA_INIT UINT32 g_sysClock
系统时钟,是绝大部分部件工作的时钟源,也是其他所有外设的时钟的来源
Definition: los_tick.c:40
UINT64 HalClockGetCycles(VOID)
long unsigned int UINT64
Definition: los_typedef.h:66
函数调用图:
这是这个函数的调用关系图:

◆ LOS_GetCpuCycle()

VOID LOS_GetCpuCycle ( UINT32 highCnt,
UINT32 lowCnt 
)

Obtain system cycle count.

Description:
This API is used to obtain system cycle count.
注意
  • This count is determined by the tick source.
参数
puwCntHi[OUT] Type UINT32 Pointer to the higher 32bit of cycles to be obtained.
puwCntLo[OUT] Type UINT32 Pointer to the lower 32bit of cycles to be obtained.
返回值
None.
Dependency:
  • los_tick.h: the header file that contains the API declaration.
参见

Obtain system cycle count.

在文件 los_hw_tick.c54 行定义.

55{
56 UINT64 cycle = HalClockGetCycles();
57
58 *highCnt = cycle >> 32; /* 32: offset 32 bits and retain high bits */
59 *lowCnt = cycle & 0xFFFFFFFFU;
60}
函数调用图:
这是这个函数的调用关系图:

◆ LOS_Mdelay()

VOID LOS_Mdelay ( UINT32  msecs)

spinning-delay in millisecond (ms).

Description:
This API is used to delay in millisecond.
注意
None.
参数
UINT32millisecond needs to delay.
返回值
None.
Dependency:
  • los_tick.h: the header file that contains the API declaration.
参见

spinning-delay in millisecond (ms).

在文件 los_hw_tick.c73 行定义.

74{
75 HalDelayUs(msecs * 1000); /* 1000 : 1ms = 1000us */
76}
VOID HalDelayUs(UINT32 usecs)
函数调用图:
这是这个函数的调用关系图:

◆ LOS_Udelay()

VOID LOS_Udelay ( UINT32  usecs)

spinning-delay in microsecond (us).

Description:
This API is used to delay in microsecond.
注意
None.
参数
UINT32microsecond needs to delay.
返回值
None.
Dependency:
  • los_tick.h: the header file that contains the API declaration.
参见

spinning-delay in microsecond (us).

在文件 los_hw_tick.c68 行定义.

69{
70 HalDelayUs(usecs);
71}
函数调用图:

◆ OsTickHandler()

VOID OsTickHandler ( VOID  )

Handle the system tick timeout.

Description:
This API is called when the system tick timeout and triggers the interrupt.
注意
  • None.
参数
none.
返回值
None.
Dependency:
  • los_tick.h: the header file that contains the API declaration.
参见
None.

在文件 los_tick.c50 行定义.

51{
52#ifdef LOSCFG_SCHED_TICK_DEBUG
54#endif
55
56#ifdef LOSCFG_KERNEL_VDSO
57 OsVdsoTimevalUpdate();//更新vdso数据页时间,vdso可以直接在用户进程空间绕过系统调用获取系统时间(例如:gettimeofday)
58#endif
59
60#ifdef LOSCFG_BASE_CORE_TICK_HW_TIME
61 HalClockIrqClear(); /* diff from every platform */
62#endif
63
64 OsSchedTick();//由时钟发起的调度
65}
VOID HalClockIrqClear(VOID)
VOID OsSchedTick(VOID)
Definition: los_sched.c:175
VOID OsSchedDebugRecordData(VOID)
VOID OsVdsoTimevalUpdate(VOID)
OsVdsoTimevalUpdate 更新时间,根据系统时钟中断不断将内核一些数据刷新进VDSO的数据页;
Definition: los_vdso.c:203
函数调用图:
这是这个函数的调用关系图:

变量说明

◆ g_cycle2NsScale

DOUBLE g_cycle2NsScale
extern

周期转纳秒级

Cycle to nanosecond scale

在文件 los_tick.c42 行定义.