未验证 提交 60393c9d 编写于 作者: O openharmony_ci 提交者: Gitee

!1985 #I4UBNS已完成,请审批

Merge pull request !1985 from Annie_wang/PR1551
# Time Management<a name="EN-US_TOPIC_0000001078876462"></a> # Time Management<a name="EN-US_TOPIC_0000001078876462"></a>
- [Basic Concepts](#section36251149131120)
- [Time Unit](#section97172532397)
- [Available APIs](#section158501652121514)
- [How to Develop](#section783435801510)
- [Development Example](#section460018317164)
- [Example Description](#section127752801718)
- [Sample Code](#section321653551711)
- [Verification](#section4366193318167)
## Basic Concepts<a name="section36251149131120"></a> ## Basic Concepts<a name="section36251149131120"></a>
...@@ -37,56 +29,18 @@ The following table describes APIs available for the OpenHarmony LiteOS-M time m ...@@ -37,56 +29,18 @@ The following table describes APIs available for the OpenHarmony LiteOS-M time m
**Table 1** APIs of the time management module **Table 1** APIs of the time management module
<a name="table14277123518139"></a> | Category| API| Description|
<table><thead align="left"><tr id="row152771935131315"><th class="cellrowborder" valign="top" width="17.77177717771777%" id="mcps1.2.4.1.1"><p id="p1127733591316"><a name="p1127733591316"></a><a name="p1127733591316"></a>Function</p> | -------- | -------- | -------- |
</th> | Time conversion| LOS_MS2Tick | Converts milliseconds into ticks.|
<th class="cellrowborder" valign="top" width="23.782378237823785%" id="mcps1.2.4.1.2"><p id="p22771357138"><a name="p22771357138"></a><a name="p22771357138"></a>API</p> | | LOS_Tick2MS | Converts ticks into milliseconds.|
</th> | | OsCpuTick2MS | Converts cycles into milliseconds. Two UINT32 values indicate the high-order and low-order 32 bits of the result value, respectively.|
<th class="cellrowborder" valign="top" width="58.44584458445845%" id="mcps1.2.4.1.3"><p id="p327714358130"><a name="p327714358130"></a><a name="p327714358130"></a>Description</p> | | OsCpuTick2US | Converts cycles into microseconds. Two UINT32 values indicate the high-order and low-order 32 bits of the result value, respectively.|
</th> | Time statistics| LOS_SysClockGet | Obtains the system clock.|
</tr> | | LOS_TickCountGet | Obtains the number of ticks since the system starts.|
</thead> | | LOS_CyclePerTickGet | Obtains the number of cycles for each tick.|
<tbody><tr id="row1627793517136"><td class="cellrowborder" rowspan="4" valign="top" width="17.77177717771777%" headers="mcps1.2.4.1.1 "><p id="p10525141151410"><a name="p10525141151410"></a><a name="p10525141151410"></a>Time conversion</p> | | LOS_CurrNanosec |Obtains the number of nanoseconds since the system starts.|
</td> | Delay management| LOS_UDelay |Performs busy waiting in μs, which can be preempted by a task with a higher priority.|
<td class="cellrowborder" valign="top" width="23.782378237823785%" headers="mcps1.2.4.1.2 "><p id="p1027783551315"><a name="p1027783551315"></a><a name="p1027783551315"></a>LOS_MS2Tick</p> | | LOS_MDelay |Performs busy waiting in ms, which can be preempted by a task with a higher priority.|
</td>
<td class="cellrowborder" valign="top" width="58.44584458445845%" headers="mcps1.2.4.1.3 "><p id="p1717215119159"><a name="p1717215119159"></a><a name="p1717215119159"></a>Converts milliseconds into ticks.</p>
</td>
</tr>
<tr id="row20278035131316"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p148921018154"><a name="p148921018154"></a><a name="p148921018154"></a>LOS_Tick2MS</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p61721311101517"><a name="p61721311101517"></a><a name="p61721311101517"></a>Converts ticks into milliseconds.</p>
</td>
</tr>
<tr id="row1736713145208"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p13367171492014"><a name="p13367171492014"></a><a name="p13367171492014"></a>OsCpuTick2MS</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p14367121422016"><a name="p14367121422016"></a><a name="p14367121422016"></a>Converts cycles into milliseconds. Two UINT32 values indicate the high-order and low-order 32 bits of the result value, respectively.</p>
</td>
</tr>
<tr id="row19475718122016"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p14475121882012"><a name="p14475121882012"></a><a name="p14475121882012"></a>OsCpuTick2US</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p26621730152310"><a name="p26621730152310"></a><a name="p26621730152310"></a>Converts cycles into microseconds. Two UINT32 values indicate the high-order and low-order 32 bits of the result value, respectively.</p>
</td>
</tr>
<tr id="row327873511316"><td class="cellrowborder" rowspan="3" valign="top" width="17.77177717771777%" headers="mcps1.2.4.1.1 "><p id="p1743134312156"><a name="p1743134312156"></a><a name="p1743134312156"></a>Time statistics</p>
</td>
<td class="cellrowborder" valign="top" width="23.782378237823785%" headers="mcps1.2.4.1.2 "><p id="p18278435131316"><a name="p18278435131316"></a><a name="p18278435131316"></a>LOS_SysClockGet</p>
</td>
<td class="cellrowborder" valign="top" width="58.44584458445845%" headers="mcps1.2.4.1.3 "><p id="p1827813571317"><a name="p1827813571317"></a><a name="p1827813571317"></a>Obtains the system clock.</p>
</td>
</tr>
<tr id="row1127823541313"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p1927810354132"><a name="p1927810354132"></a><a name="p1927810354132"></a>LOS_TickCountGet</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p17278163512131"><a name="p17278163512131"></a><a name="p17278163512131"></a>Obtains the number of ticks since the system starts.</p>
</td>
</tr>
<tr id="row1027814354131"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p1727843510137"><a name="p1727843510137"></a><a name="p1727843510137"></a>LOS_CyclePerTickGet</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p827819358134"><a name="p827819358134"></a><a name="p827819358134"></a>Obtains the number of cycles for each tick.</p>
</td>
</tr>
</tbody>
</table>
## How to Develop<a name="section783435801510"></a> ## How to Develop<a name="section783435801510"></a>
...@@ -95,7 +49,8 @@ The typical development process of time management is as follows: ...@@ -95,7 +49,8 @@ The typical development process of time management is as follows:
1. Complete board configuration and adaptation as required, and configure the system clock frequency \(**OS\_SYS\_CLOCK** in Hz and **LOSCFG\_BASE\_CORE\_TICK\_PER\_SECOND**\). The default value of **OS\_SYS\_CLOCK** varies with the hardware platform. 1. Complete board configuration and adaptation as required, and configure the system clock frequency \(**OS\_SYS\_CLOCK** in Hz and **LOSCFG\_BASE\_CORE\_TICK\_PER\_SECOND**\). The default value of **OS\_SYS\_CLOCK** varies with the hardware platform.
2. Call the clock conversion and statistics APIs. 2. Call the clock conversion and statistics APIs.
>![](../public_sys-resources/icon-note.gif) **NOTE:** >![](../public_sys-resources/icon-note.gif) **NOTE**
>
>- The time management module depends on **OS\_SYS\_CLOCK** and **LOSCFG\_BASE\_CORE\_TICK\_PER\_SECOND**. >- The time management module depends on **OS\_SYS\_CLOCK** and **LOSCFG\_BASE\_CORE\_TICK\_PER\_SECOND**.
>- The number of system ticks is not counted when the interrupt feature is disabled. Therefore, the number of ticks cannot be used as the accurate time. >- The number of system ticks is not counted when the interrupt feature is disabled. Therefore, the number of ticks cannot be used as the accurate time.
>- The configuration options are maintained in the **target\_config.h** file of the development board project. >- The configuration options are maintained in the **target\_config.h** file of the development board project.
...@@ -106,8 +61,8 @@ The typical development process of time management is as follows: ...@@ -106,8 +61,8 @@ The typical development process of time management is as follows:
The following example describes basic time management methods, including: The following example describes basic time management methods, including:
1. Time conversion: convert milliseconds to ticks or convert ticks to milliseconds. - Time conversion: convert milliseconds to ticks or convert ticks to milliseconds.
2. Time statistics: obtain the number of cycles per tick, number of ticks since system startup, and number of delayed ticks. - Time statistics: obtain the number of cycles per tick, number of ticks since system startup, and number of delayed ticks.
### Sample Code<a name="section321653551711"></a> ### Sample Code<a name="section321653551711"></a>
...@@ -175,4 +130,3 @@ LOS_CyclePerTickGet = 495000 ...@@ -175,4 +130,3 @@ LOS_CyclePerTickGet = 495000
LOS_TickCountGet = 1 LOS_TickCountGet = 1
LOS_TickCountGet after delay = 201 LOS_TickCountGet after delay = 201
``` ```
...@@ -49,52 +49,24 @@ The following table describes APIs available for the OpenHarmony LiteOS-M interr ...@@ -49,52 +49,24 @@ The following table describes APIs available for the OpenHarmony LiteOS-M interr
**Table 1** APIs of the interrupt module **Table 1** APIs of the interrupt module
<a name="table12470505188"></a> | Category| API| Description|
<table><thead align="left"><tr id="row16470160111812"><th class="cellrowborder" valign="top" width="12.85128512851285%" id="mcps1.2.4.1.1"><p id="p164707031814"><a name="p164707031814"></a><a name="p164707031814"></a>Function</p> | -------- | -------- | -------- |
</th> | Creating or deleting an interrupt| LOS_HwiCreate | Creates an interrupt and registers the interrupt ID, triggering mode, priority, and interrupt handler. When an interrupt is triggered, the interrupt handler will be called.|
<th class="cellrowborder" valign="top" width="29.8029802980298%" id="mcps1.2.4.1.2"><p id="p15470190151816"><a name="p15470190151816"></a><a name="p15470190151816"></a>API</p> | | LOS_HwiDelete | Deletes an interrupt based on the specified interrupt ID.|
</th> | Locking or unlocking interrupts| LOS_IntUnLock | Enables the CPU to respond to all interrupt requests.|
<th class="cellrowborder" valign="top" width="57.34573457345735%" id="mcps1.2.4.1.3"><p id="p194701609186"><a name="p194701609186"></a><a name="p194701609186"></a>Description</p> | | LOS_IntLock | Disables the CPU from responding to interrupt requests.|
</th> | | LOS_IntRestore | Restores the interrupt status before the **LOS_IntLock** and **LOS_IntUnLock** operations are performed.|
</tr> | Enabling or disabling an interrupt| LOS_HwiDisable | Disables the CPU from responding to the specified interrupt by setting the register.|
</thead> | | LOS_HwiEnable | Enables the CPU to respond to the specified interrupt by setting the register.|
<tbody><tr id="row14701707188"><td class="cellrowborder" rowspan="2" valign="top" width="12.85128512851285%" headers="mcps1.2.4.1.1 "><p id="p54707061819"><a name="p54707061819"></a><a name="p54707061819"></a>Creating or deleting interrupts</p> | Setting the interrupt priority| LOS_HwiSetPriority | Sets the interrupt priority.|
</td> | Triggering an interrupt| LOS_HwiTrigger | Triggers an interrupt (simulate an external interrupt by writing the related register of the interrupt controller).|
<td class="cellrowborder" valign="top" width="29.8029802980298%" headers="mcps1.2.4.1.2 "><p id="p5470603184"><a name="p5470603184"></a><a name="p5470603184"></a>HalHwiCreate</p> | Clearing interrupt register status| LOS_HwiClear | Clears the status bit of the interrupt register corresponding to the interrupt ID. The implementation of this API depends on the interrupt controller version. It is optional.|
</td>
<td class="cellrowborder" valign="top" width="57.34573457345735%" headers="mcps1.2.4.1.3 "><p id="p74706011818"><a name="p74706011818"></a><a name="p74706011818"></a>Creates an interrupt and registers the interrupt ID, interrupt triggering mode, interrupt priority, and interrupt handler. When an interrupt is triggered, the interrupt handler will be called.</p>
</td>
</tr>
<tr id="row154703013184"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p84702002181"><a name="p84702002181"></a><a name="p84702002181"></a>HalHwiDelete</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p114700091815"><a name="p114700091815"></a><a name="p114700091815"></a>Deletes an interrupt based on the specified interrupt ID.</p>
</td>
</tr>
<tr id="row15470506188"><td class="cellrowborder" rowspan="3" valign="top" width="12.85128512851285%" headers="mcps1.2.4.1.1 "><p id="p147010001812"><a name="p147010001812"></a><a name="p147010001812"></a>Enabling or disabling interrupts</p>
</td>
<td class="cellrowborder" valign="top" width="29.8029802980298%" headers="mcps1.2.4.1.2 "><p id="p184701906185"><a name="p184701906185"></a><a name="p184701906185"></a>LOS_IntUnLock</p>
</td>
<td class="cellrowborder" valign="top" width="57.34573457345735%" headers="mcps1.2.4.1.3 "><p id="p1847018014188"><a name="p1847018014188"></a><a name="p1847018014188"></a>Enables the CPU to respond to all interrupt requests.</p>
</td>
</tr>
<tr id="row2470902182"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p04711408181"><a name="p04711408181"></a><a name="p04711408181"></a>LOS_IntLock</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p194719071819"><a name="p194719071819"></a><a name="p194719071819"></a>Disables the CPU from responding to interrupt requests.</p>
</td>
</tr>
<tr id="row447117051814"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p1047112011188"><a name="p1047112011188"></a><a name="p1047112011188"></a>LOS_IntRestore</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p1947100121811"><a name="p1947100121811"></a><a name="p1947100121811"></a>Restores the interrupt status before the <strong id="b160497829844357"><a name="b160497829844357"></a><a name="b160497829844357"></a>LOS_IntLock</strong> and <strong id="b123452092644357"><a name="b123452092644357"></a><a name="b123452092644357"></a>LOS_IntUnLock</strong> operations are performed.</p>
</td>
</tr>
</tbody>
</table>
## How to Develop<a name="section11841123033618"></a> ## How to Develop<a name="section11841123033618"></a>
1. Create an interrupt by calling **HalHwiCreate**. 1. Call **LOS_HwiCreate** to create an interrupt.
2. Call **TestHwiTrigger** to trigger the specified interrupt. \(This API is defined in the test suite. It simulates an external interrupt by writing the related register of the interrupt controller. Skip this step for common peripheral devices.\) 2. Call **LOS_HwiTrigger** to trigger the interrupt.
3. Call **HalHwiDelete** to delete the specified interrupt. Use this API based on actual requirements. 3. Call **LOS_HwiDelete** to delete the specified interrupt. Use this API based on actual requirements.
>![](../public_sys-resources/icon-note.gif) **NOTE:** >![](../public_sys-resources/icon-note.gif) **NOTE:**
>- Configure the maximum number of interrupts supported and the number of configurable interrupt priorities based on the specific hardware. >- Configure the maximum number of interrupts supported and the number of configurable interrupt priorities based on the specific hardware.
...@@ -131,9 +103,9 @@ static UINT32 Example_Interrupt(VOID) ...@@ -131,9 +103,9 @@ static UINT32 Example_Interrupt(VOID)
HwiIrqParam irqParam; HwiIrqParam irqParam;
(void)memset_s(&irqParam, sizeof(HwiIrqParam), 0, sizeof(HwiIrqParam)); (void)memset_s(&irqParam, sizeof(HwiIrqParam), 0, sizeof(HwiIrqParam));
irqParam.pDevId = 0; irqParam.pDevId = 0;
/* Create an interrupt. */ /* Create an interrupt. */
ret = LOS_HwiCreate(HWI_NUM_TEST, hwiPrio, mode, (HWI_PROC_FUNC)HwiUsrIrq, &irqParam); ret = LOS_HwiCreate(HWI_NUM_TEST, hwiPrio, mode, (HWI_PROC_FUNC)HwiUsrIrq, &irqParam);
if(ret == LOS_OK){ if(ret == LOS_OK){
printf("Hwi create success!\n"); printf("Hwi create success!\n");
} else { } else {
...@@ -141,11 +113,17 @@ static UINT32 Example_Interrupt(VOID) ...@@ -141,11 +113,17 @@ static UINT32 Example_Interrupt(VOID)
return LOS_NOK; return LOS_NOK;
} }
/* Delay 50 ticks. When a hardware interrupt occurs, the HwiUsrIrq function will be called. */ /* Trigger the interrupt. */
LOS_TaskDelay(50); ret = LOS_HwiTrigger(HWI_NUM_TEST);
if(ret == LOS_OK){
printf("Hwi trigger success!\n");
} else {
printf("Hwi trigger failed!\n");
return LOS_NOK;
}
/* Delete an interrupt. */ /* Delete the interrupt. */
ret = HalHwiDelete(HWI_NUM_TEST); ret = LOS_HwiDelete(HWI_NUM_TEST);
if(ret == LOS_OK){ if(ret == LOS_OK){
printf("Hwi delete success!\n"); printf("Hwi delete success!\n");
} else { } else {
...@@ -164,4 +142,3 @@ The development is successful if the return result is as follows: ...@@ -164,4 +142,3 @@ The development is successful if the return result is as follows:
Hwi create success! Hwi create success!
Hwi delete success! Hwi delete success!
``` ```
...@@ -109,149 +109,35 @@ The following table describes APIs available for the OpenHarmony LiteOS-M task m ...@@ -109,149 +109,35 @@ The following table describes APIs available for the OpenHarmony LiteOS-M task m
**Table 1** APIs of the task management module **Table 1** APIs of the task management module
<a name="table14287183117205"></a> | Category| API| Description|
<table><thead align="left"><tr id="row2287133115203"><th class="cellrowborder" valign="top" width="12.85128512851285%" id="mcps1.2.4.1.1"><p id="p6287103142013"><a name="p6287103142013"></a><a name="p6287103142013"></a>Function</p> | -------- | -------- | -------- |
</th> | Creating or deleting a task| LOS_TaskCreateOnly | Creates a task and suspends the task to disable scheduling of the task. To enable scheduling of the task, call **LOS_TaskResume** to make the task enter the Ready state.|
<th class="cellrowborder" valign="top" width="29.8029802980298%" id="mcps1.2.4.1.2"><p id="p62871931152011"><a name="p62871931152011"></a><a name="p62871931152011"></a>API</p> | | LOS_TaskCreate | Creates a task and places the task in the Ready state. If there is no task with a higher priority in the Ready queue, the task will be executed.|
</th> | | LOS_TaskDelete | Deletes a task.|
<th class="cellrowborder" valign="top" width="57.34573457345735%" id="mcps1.2.4.1.3"><p id="p1328733110202"><a name="p1328733110202"></a><a name="p1328733110202"></a>Description</p> | Controlling task status| LOS_TaskResume | Resumes a suspended task to place it in the Ready state.|
</th> | | LOS_TaskSuspend | Suspends the specified task and performs task switching.|
</tr> | | LOS_TaskJoin | Suspends this task till the specified task is complete and the task control block resources are reclaimed.|
</thead> | | LOS_TaskDetach | Changes the task attribute from **joinable** to **detach**. After the task of the **detach** attribute is complete, the task control block resources will be automatically reclaimed.|
<tbody><tr id="row4287183182010"><td class="cellrowborder" rowspan="3" valign="top" width="12.85128512851285%" headers="mcps1.2.4.1.1 "><p id="p6287831122018"><a name="p6287831122018"></a><a name="p6287831122018"></a>Creating or deleting a task</p> | | LOS_TaskDelay | Makes a task wait for a period of time (in ticks) and releases CPU resources. When the delay time expires, the task enters the Ready state again. The input parameter is the number of ticks.|
</td> | | LOS_Msleep | Converts the input number of milliseconds into number of ticks, and use the result to call **LOS_TaskDelay**.|
<td class="cellrowborder" valign="top" width="29.8029802980298%" headers="mcps1.2.4.1.2 "><p id="p11287193111207"><a name="p11287193111207"></a><a name="p11287193111207"></a>LOS_TaskCreateOnly</p> | | LOS_TaskYield | Sets the time slice of the current task to **0** to release CPU resources and schedule the task with the highest priority in the Ready queue to run.|
</td> | Controlling task scheduling| LOS_TaskLock | Locks task scheduling. However, tasks can still be interrupted.|
<td class="cellrowborder" valign="top" width="57.34573457345735%" headers="mcps1.2.4.1.3 "><p id="p14287173112013"><a name="p14287173112013"></a><a name="p14287173112013"></a>Creates a task and suspends the task to disable scheduling of the task. To enable scheduling of the task, call <strong id="b129220316444426"><a name="b129220316444426"></a><a name="b129220316444426"></a>LOS_TaskResume</strong> to make the task enter the Ready state.</p> | | LOS_TaskUnlock | Unlocks task scheduling.|
</td> | | LOS_Schedule | Triggers task scheduling|
</tr> | Controlling task priority| LOS_CurTaskPriSet | Sets the priority for the current task.|
<tr id="row13288113122019"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p15288131122016"><a name="p15288131122016"></a><a name="p15288131122016"></a>LOS_TaskCreate</p> | | LOS_TaskPriSet | Sets the priority for a specified task.|
</td> | | LOS_TaskPriGet | Obtains the priority of a specified task.|
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p12886315207"><a name="p12886315207"></a><a name="p12886315207"></a>Creates a task and places the task in the Ready state. If there is no task with a higher priority in the Ready queue, the task will be executed.</p> | Obtaining Job information| LOS_CurTaskIDGet | Obtains the ID of the current task.|
</td> | | LOS_NextTaskIDGet | Obtains the ID of the task with the highest priority in the Ready queue.|
</tr> | | LOS_NewTaskIDGet | Same as **LOS_NextTaskIDGet**.|
<tr id="row10288123152019"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p2288193132015"><a name="p2288193132015"></a><a name="p2288193132015"></a>LOS_TaskDelete</p> | | LOS_CurTaskNameGet | Obtains the name of the current task.|
</td> | | LOS_TaskNameGet | Obtains the name of a specified task.|
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p17288133172017"><a name="p17288133172017"></a><a name="p17288133172017"></a>Deletes the specified task.</p> | | LOS_TaskStatusGet | Obtains the state of a specified task.|
</td> | | LOS_TaskInfoGet | Obtains information about a specified task, including the task state, priority, stack size, stack pointer (SP), task entry function, and used stack space.|
</tr> | | LOS_TaskIsRunning | Checks whether the task module has started scheduling.|
<tr id="row10288143112201"><td class="cellrowborder" rowspan="6" valign="top" width="12.85128512851285%" headers="mcps1.2.4.1.1 "><p id="p92883313201"><a name="p92883313201"></a><a name="p92883313201"></a>Controlling task status</p> | Updating task information| LOS_TaskSwitchInfoGet | Obtains task switching information. The macro **LOSCFG_BASE_CORE_EXC_TSK_SWITCH** must be enabled.|
</td> | Reclaiming task stack resources| LOS_TaskResRecycle | Reclaims all task stack resources.|
<td class="cellrowborder" valign="top" width="29.8029802980298%" headers="mcps1.2.4.1.2 "><p id="p1328833112015"><a name="p1328833112015"></a><a name="p1328833112015"></a>LOS_TaskResume</p>
</td>
<td class="cellrowborder" valign="top" width="57.34573457345735%" headers="mcps1.2.4.1.3 "><p id="p228823192011"><a name="p228823192011"></a><a name="p228823192011"></a>Resumes a suspended task to place the task in the Ready state.</p>
</td>
</tr>
<tr id="row92884314208"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p1328815311204"><a name="p1328815311204"></a><a name="p1328815311204"></a>LOS_TaskSuspend</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p628816315207"><a name="p628816315207"></a><a name="p628816315207"></a>Suspends the specified task and performs task switching.</p>
</td>
</tr>
<tr id="row1928893112015"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p4288193142010"><a name="p4288193142010"></a><a name="p4288193142010"></a>LOS_TaskJoin</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p20288123172015"><a name="p20288123172015"></a><a name="p20288123172015"></a>Suspends this task till the specified task is complete and the task control block resources are reclaimed.</p>
</td>
</tr>
<tr id="row928853152014"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p1728863114208"><a name="p1728863114208"></a><a name="p1728863114208"></a>LOS_TaskDelay</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p202881831192011"><a name="p202881831192011"></a><a name="p202881831192011"></a>Makes a task wait for a period of time (in ticks) and releases CPU resources. When the delay time expires, the task enters the Ready state again. The input parameter is the number of ticks.</p>
</td>
</tr>
<tr id="row1628873122011"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p128873119204"><a name="p128873119204"></a><a name="p128873119204"></a>LOS_Msleep</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p128803112012"><a name="p128803112012"></a><a name="p128803112012"></a>Converts the input parameter number of milliseconds into number of ticks, and use the result to call <strong id="b56235690044426"><a name="b56235690044426"></a><a name="b56235690044426"></a>LOS_TaskDelay</strong>.</p>
</td>
</tr>
<tr id="row142888310203"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p1328853115203"><a name="p1328853115203"></a><a name="p1328853115203"></a>LOS_TaskYield</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p1728893192018"><a name="p1728893192018"></a><a name="p1728893192018"></a>Sets the time slice of the current task to <strong id="b5591310044426"><a name="b5591310044426"></a><a name="b5591310044426"></a>0</strong> to release CPU resources and schedule the task with the highest priority in the Ready queue to run.</p>
</td>
</tr>
<tr id="row1228813117202"><td class="cellrowborder" rowspan="3" valign="top" width="12.85128512851285%" headers="mcps1.2.4.1.1 "><p id="p128814312206"><a name="p128814312206"></a><a name="p128814312206"></a>Control task scheduling</p>
</td>
<td class="cellrowborder" valign="top" width="29.8029802980298%" headers="mcps1.2.4.1.2 "><p id="p1028813115207"><a name="p1028813115207"></a><a name="p1028813115207"></a>LOS_TaskLock</p>
</td>
<td class="cellrowborder" valign="top" width="57.34573457345735%" headers="mcps1.2.4.1.3 "><p id="p328863117203"><a name="p328863117203"></a><a name="p328863117203"></a>Locks task scheduling. However, tasks can still be interrupted.</p>
</td>
</tr>
<tr id="row1728815310206"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p15288331132013"><a name="p15288331132013"></a><a name="p15288331132013"></a>LOS_TaskUnlock</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p3288731142017"><a name="p3288731142017"></a><a name="p3288731142017"></a>Unlocks task scheduling.</p>
</td>
</tr>
<tr id="row328817319204"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p1128916312201"><a name="p1128916312201"></a><a name="p1128916312201"></a>LOS_Schedule</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p20289173112017"><a name="p20289173112017"></a><a name="p20289173112017"></a>Triggers task scheduling</p>
</td>
</tr>
<tr id="row172891531202015"><td class="cellrowborder" rowspan="3" valign="top" width="12.85128512851285%" headers="mcps1.2.4.1.1 "><p id="p14289123182010"><a name="p14289123182010"></a><a name="p14289123182010"></a>Controlling task priority</p>
</td>
<td class="cellrowborder" valign="top" width="29.8029802980298%" headers="mcps1.2.4.1.2 "><p id="p228933114208"><a name="p228933114208"></a><a name="p228933114208"></a>LOS_CurTaskPriSet</p>
</td>
<td class="cellrowborder" valign="top" width="57.34573457345735%" headers="mcps1.2.4.1.3 "><p id="p728993182020"><a name="p728993182020"></a><a name="p728993182020"></a>Sets the priority for the current task.</p>
</td>
</tr>
<tr id="row152891331122017"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p18289113110209"><a name="p18289113110209"></a><a name="p18289113110209"></a>LOS_TaskPriSet</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p20289163122017"><a name="p20289163122017"></a><a name="p20289163122017"></a>Sets the priority for a specified task.</p>
</td>
</tr>
<tr id="row1928912314205"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p1128973112014"><a name="p1128973112014"></a><a name="p1128973112014"></a>LOS_TaskPriGet</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p228933119206"><a name="p228933119206"></a><a name="p228933119206"></a>Obtains the priority of a specified task.</p>
</td>
</tr>
<tr id="row10289113192017"><td class="cellrowborder" rowspan="8" valign="top" width="12.85128512851285%" headers="mcps1.2.4.1.1 "><p id="p128923116206"><a name="p128923116206"></a><a name="p128923116206"></a>Obtaining task information</p>
</td>
<td class="cellrowborder" valign="top" width="29.8029802980298%" headers="mcps1.2.4.1.2 "><p id="p132897312209"><a name="p132897312209"></a><a name="p132897312209"></a>LOS_CurTaskIDGet</p>
</td>
<td class="cellrowborder" valign="top" width="57.34573457345735%" headers="mcps1.2.4.1.3 "><p id="p15289031122015"><a name="p15289031122015"></a><a name="p15289031122015"></a>Obtains the ID of the current task.</p>
</td>
</tr>
<tr id="row16289123117202"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p13289153115207"><a name="p13289153115207"></a><a name="p13289153115207"></a>LOS_NextTaskIDGet</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p16289133142013"><a name="p16289133142013"></a><a name="p16289133142013"></a>Obtains the ID of the task with the highest priority in the Ready queue.</p>
</td>
</tr>
<tr id="row1728933119202"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p1428915312205"><a name="p1428915312205"></a><a name="p1428915312205"></a>LOS_NewTaskIDGet</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p18289163192018"><a name="p18289163192018"></a><a name="p18289163192018"></a>Same as <strong id="b59459526844426"><a name="b59459526844426"></a><a name="b59459526844426"></a>LOS_NextTaskIDGet</strong>.</p>
</td>
</tr>
<tr id="row828953110201"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p192891831112015"><a name="p192891831112015"></a><a name="p192891831112015"></a>LOS_CurTaskNameGet</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p10289631132012"><a name="p10289631132012"></a><a name="p10289631132012"></a>Obtains the name of the current task.</p>
</td>
</tr>
<tr id="row1028943115207"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p628911316201"><a name="p628911316201"></a><a name="p628911316201"></a>LOS_TaskNameGet</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p4289331142014"><a name="p4289331142014"></a><a name="p4289331142014"></a>Obtains the name of a specified task.</p>
</td>
</tr>
<tr id="row14289153142017"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p1128963122020"><a name="p1128963122020"></a><a name="p1128963122020"></a>LOS_TaskStatusGet</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p19289153142013"><a name="p19289153142013"></a><a name="p19289153142013"></a>Obtains the state of a specified task.</p>
</td>
</tr>
<tr id="row1728915310209"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p1290143113205"><a name="p1290143113205"></a><a name="p1290143113205"></a>LOS_TaskInfoGet</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p62901231112010"><a name="p62901231112010"></a><a name="p62901231112010"></a>Obtains information about a specified task, including the task state, priority, stack size, stack pointer (SP), task entry function, and used stack space.</p>
</td>
</tr>
<tr id="row1029053162016"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p529053113209"><a name="p529053113209"></a><a name="p529053113209"></a>LOS_TaskIsRunning</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p1290113114206"><a name="p1290113114206"></a><a name="p1290113114206"></a>Checks whether the task module has started scheduling.</p>
</td>
</tr>
<tr id="row1529017317206"><td class="cellrowborder" valign="top" width="12.85128512851285%" headers="mcps1.2.4.1.1 "><p id="p14290143162014"><a name="p14290143162014"></a><a name="p14290143162014"></a>Maintaining and testing task information</p>
</td>
<td class="cellrowborder" valign="top" width="29.8029802980298%" headers="mcps1.2.4.1.2 "><p id="p18290831112013"><a name="p18290831112013"></a><a name="p18290831112013"></a>LOS_TaskSwitchInfoGet</p>
</td>
<td class="cellrowborder" valign="top" width="57.34573457345735%" headers="mcps1.2.4.1.3 "><p id="p17290153116200"><a name="p17290153116200"></a><a name="p17290153116200"></a>Obtains task switching information. The macro <strong id="b125259128644426"><a name="b125259128644426"></a><a name="b125259128644426"></a>LOSCFG_BASE_CORE_EXC_TSK_SWITCH</strong> must be enabled.</p>
</td>
</tr>
</tbody>
</table>
## How to Develop<a name="section783435801510"></a> ## How to Develop<a name="section783435801510"></a>
...@@ -410,4 +296,3 @@ TaskHi LOS_TaskSuspend Success. ...@@ -410,4 +296,3 @@ TaskHi LOS_TaskSuspend Success.
TaskHi LOS_TaskResume Success. TaskHi LOS_TaskResume Success.
Join Example_TaskHi Success! Join Example_TaskHi Success!
``` ```
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册