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

函数

UINTPTR LOS_Align (UINTPTR addr, UINT32 boundary)
 Align the value (addr) by some bytes (boundary) you specify. 更多...
 
VOID LOS_Msleep (UINT32 msecs)
 Sleep the current task. 更多...
 

详细描述

函数说明

◆ LOS_Align()

UINTPTR LOS_Align ( UINTPTR  addr,
UINT32  boundary 
)

Align the value (addr) by some bytes (boundary) you specify.

Description:
This API is used to align the value (addr) by some bytes (boundary) you specify.
注意
  • the value of boundary usually is 4,8,16,32.
参数
addr[IN] The variable what you want to align.
boundary[IN] The align size what you want to align.
返回值
UINTPTRThe variable what have been aligned.
Dependency:
  • los_base.h: the header file that contains the API declaration.
参见

在文件 los_misc.c35 行定义.

36{
37 if ((addr + boundary - 1) > addr) {
38 return (addr + boundary - 1) & ~((UINTPTR)(boundary - 1));
39 } else {
40 return addr & ~((UINTPTR)(boundary - 1));
41 }
42}
unsigned long UINTPTR
Definition: los_typedef.h:68
这是这个函数的调用关系图:

◆ LOS_Msleep()

VOID LOS_Msleep ( UINT32  msecs)

Sleep the current task.

Description:
This API is used to delay the execution of the current task. The task is able to be scheduled after it is delayed for a specified number of Ticks.
注意
  • The task fails to be delayed if it is being delayed during interrupt processing or it is locked.
  • If 0 is passed in and the task scheduling is not locked, execute the next task in the queue of tasks with the priority of the current task. If no ready task with the priority of the current task is available, the task scheduling will not occur, and the current task continues to be executed.
  • The parameter passed in can not be equal to LOS_WAIT_FOREVER(0xFFFFFFFF). If that happens, the task will not sleep 0xFFFFFFFF milliseconds or sleep forever but sleep 0xFFFFFFFF Ticks.
参数
msecs[IN] Type UINT32 Number of MS for which the task is delayed.
返回值
None
Dependency:
  • los_base.h: the header file that contains the API declaration.
参见
None

在文件 los_misc.c44 行定义.

45{
46 UINT32 interval;
47
48 if (msecs == 0) {
49 interval = 0;
50 } else {
51 interval = LOS_MS2Tick(msecs);
52 if (interval == 0) {
53 interval = 1;
54 }
55 }
56
57 (VOID)LOS_TaskDelay(interval);
58}
LITE_OS_SEC_TEXT_MINOR UINT32 LOS_MS2Tick(UINT32 millisec)
毫秒转换成Tick
Definition: los_sys.c:101
LITE_OS_SEC_TEXT UINT32 LOS_TaskDelay(UINT32 tick)
任务延时等待,释放CPU,等待时间到期后该任务会重新进入ready状态
Definition: los_task.c:1020
unsigned int UINT32
Definition: los_typedef.h:57
函数调用图:
这是这个函数的调用关系图: