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

!5396 [翻译完成】#I598IQ

Merge pull request !5396 from Annie_wang/PR4359
# Time Management # Time Management
## Basic Concepts<a name="section12903185785119"></a> ## Basic Concepts
Time management provides all time-related services for applications based on the system clock. The system clock is generated by the interrupts triggered by the output pulse of a timer or counter. The system clock is generally defined as an integer or a long integer. The period of an output pulse is a "clock tick". The system clock is also called time scale or tick. The duration of a tick can be configured statically. People use second or millisecond as the time unit, while the operating system uses tick. When operations such as suspending a task or delaying a task are performed, the time management module converts time between ticks and seconds or milliseconds. Time management provides all time-related services for applications based on the system clock. The system clock is generated by the interrupts triggered by the output pulse of a timer or counter. The system clock is generally defined as an integer or a long integer. The period of an output pulse is a "clock tick". The system clock is also called time scale or tick. The duration of a tick can be configured statically. People use second or millisecond as the time unit, while the operating system uses tick. When operations such as suspending a task or delaying a task are performed, the time management module converts time between ticks and seconds or milliseconds.
...@@ -19,11 +19,11 @@ The mapping between ticks and seconds can be configured. ...@@ -19,11 +19,11 @@ The mapping between ticks and seconds can be configured.
The OpenHarmony time management module provides time conversion, statistics, and delay functions to meet users' time requirements. The OpenHarmony time management module provides time conversion, statistics, and delay functions to meet users' time requirements.
## Development Guidelines<a name="section430981720522"></a> ## Development Guidelines
The time management module provides APIs to implement conversion between the system running time, ticks, and seconds/milliseconds. The time management module provides APIs to implement conversion between the system running time, ticks, and seconds/milliseconds.
### Available APIs<a name="section1040142705214"></a> ### Available APIs
The following table describes APIs available for the OpenHarmony LiteOS-A time management. For more details about the APIs, see the API reference. The following table describes APIs available for the OpenHarmony LiteOS-A time management. For more details about the APIs, see the API reference.
...@@ -65,22 +65,23 @@ The following table describes APIs available for the OpenHarmony LiteOS-A time m ...@@ -65,22 +65,23 @@ The following table describes APIs available for the OpenHarmony LiteOS-A time m
</tbody> </tbody>
</table> </table>
### How to Develop<a name="section1381224710522"></a> ### How to Develop
1. Call APIs to convert time. 1. Call APIs to convert time.
2. Call APIs to perform time statistics. 2. Call APIs to perform time statistics.
>![](../public_sys-resources/icon-note.gif) **NOTE:** >![](public_sys-resources/icon-note.gif) **NOTE**<br/>
>- The system tick count can be obtained only after the system clock is enabled. >- The system tick count can be obtained only after the system clock is enabled.
>- The time management module depends on **OS\_SYS\_CLOCK** and **LOSCFG\_BASE\_CORE\_TICK\_PER\_SECOND** in **los\_config.h**. >- The time management module depends on **OS\_SYS\_CLOCK** and **LOSCFG\_BASE\_CORE\_TICK\_PER\_SECOND** in **los\_config.h**.
>- 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.
### Development Example<a name="section1344610245416"></a> ### Development Example
Prerequisites: **Prerequisites**<br>
The following parameters are configured:
- **LOSCFG\_BASE\_CORE\_TICK\_PER\_SECOND**, that is, the number of ticks per second in the system, is configured. - **LOSCFG\_BASE\_CORE\_TICK\_PER\_SECOND**: number of ticks per second in the system. The value range is (0, 1000].
- **OS\_SYS\_CLOCK**, that is, system clock \(in Hz\), is configured. - **OS\_SYS\_CLOCK**: system clock, in Hz.
**Sample Code** **Sample Code**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册