# US 2019/0317809 A1 · Implementation method and apparatus of timer

> Agents: this data is available as JSON from the patentgrep API and MCP server — see https://patentgrep.com/llms.txt

- Number: US 2019/0317809 A1
- Document ID: US20190317809A1
- Status: Published application
- Kind: A1
- Application number: 16/454,011
- Filed: 2019-06-26
- Published: 2019-10-17
- Earliest claimed: 2018-01-16
- Assignees: Shenzhen Goodix Technology Co., Ltd.
- Applicants: Shenzhen Goodix Technology Co., Ltd.
- Inventors: MING ZHU; MINGLIANG WANG; GUOCHAO YIN; LIHUA HU
- Web page: https://patentgrep.com/patent/US20190317809A1

## CPC

- G06F 9/4887: {involving deadlines, e.g. rate based, periodic}
- G06F 1/14: Time supervision arrangements, e.g. real time clock
- G06F 9/4825: {Interrupt from clock, e.g. time of day}
- Y02D 10/00: Energy efficient computing, e.g. low power processors, power management or thermal management
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)
- Y02D: CLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE

## Abstract

The present disclosure provides an implementation method and apparatus of timer, the method includes: determining a counting period of a hardware timer according to expiration time of a timer node expires first in a timer linked list; and when the counting period of the hardware timer is expired, traversing through the timer node in the timer linked list and updating the counting period of the hardware timer. The present disclosure provides a technical solution that can effectively reduce system power consumption and processor resource occupancy.

## Claims

### Claim 1

An implementation method of timer, comprising:
determining a counting period of a hardware timer according to expiration time of a timer node expires first in a timer linked list; and
when the counting period of the hardware timer is expired, traversing through the timer node in the timer linked list and updating the counting period of the hardware timer.

### Claim 2 (depends on 1)

The method according to claim 1, wherein the updating the counting period of the hardware timer comprises:
determining whether the timer linked list is empty and,
if the timer linked list is empty, updating the counting period of the hardware timer with a maximum counting period of the hardware timer;
if the timer linked list is not empty, obtaining the expiration time of the timer node expires first in the timer linked list and current system time;
determining whether a time interval between the expiration time of the timer node expires first and the current system time is greater than the maximum counting period of the hardware timer and,
if the time interval is greater than the maximum counting period of the hardware timer, updating the counting period of the hardware timer with the maximum counting period of the hardware timer;
if the time interval is less than or equal to the maximum counting period of the hardware timer, updating the counting period of the hardware timer with the time interval.

### Claim 3 (depends on 1)

The method according to claim 1, wherein each timer node in the timer linked list is sorted according to their expiration time.

### Claim 4 (depends on 3)

The method according to claim 3, wherein the traversing through the timer node in the timer linked list and updating the counting period of the hardware timer comprises:
setting a first timer node in the timer linked list to be a current timer node, and performing traversing operation on the current timer node, the traversing operation comprising:
obtaining current system time;
determining whether the current timer node is not empty and the current system time is greater than or equal to the expiration time of the current timer node;
updating the counting period of the hardware timer if the current timer node is empty or the current system time is less than the expiration time of the current timer node;
if the current timer node is not empty and the current system time is greater than or equal to the expiration time of the current timer node, executing a callback function of the current timer node; and
setting a next timer node in the timer linked list to be the current timer node, and returning to perform the traversing operation.

### Claim 5 (depends on 4)

The method according to claim 4, wherein, after the executing a callback function of the current timer node, the method further comprises:
determining whether the current timer node is a periodic timer and,
if the current timer node is a periodic timer, updating the expiration time of the current timer node, and setting an update flag of the timer linked list to be True;
if the current timer node is a one-time timer, deleting the current timer node;
when the current timer node is empty or the current system time is less than the expiration time of the current timer node, then before updating the counting period of the hardware timer, the method further comprises:
determining whether the update flag of the timer linked list is set to be True; and
updating ordering of the timer linked list if the update flag of the timer linked list is set to be True.

### Claim 6 (depends on 3)

The method according to claim 3, wherein the method further comprises:
inserting a new timer node into the timer linked list; and
when the new timer node is the first timer node in the timer linked list, updating the counting period of the hardware timer.

### Claim 7 (depends on 6)

The method according to claim 6, wherein the inserting a new timer node into the timer linked list comprises:
obtaining a timing duration of a timer node to be created and current system time;
calculating expiration time of the timer node to be created according to the timing duration of the timer node to be created and the current system time; and
inserting the timer node to be created as a new timer node into the timer linked list according to the expiration time of the timer node to be created.

### Claim 8 (depends on 3)

The method according to claim 3, wherein the method further comprises:
when a software timer is turned off, deleting a timer node corresponding to the turned off software timer from the timer linked list; and
when the deleted timer node is a first node in the timer linked list, updating the counting period of the hardware timer.

### Claim 9 (depends on 1)

The method according to claim 1, wherein, when the counting period of the hardware timer is expired and before the traversing through the timer node in the timer linked list, the method further comprises:
updating system time with the expiration time of the counting period of the hardware timer.

### Claim 10

An implementation apparatus of timer, comprising: a processor and a memory storing instructions thereon, the processor when executing the instructions, being configured to:
determine a counting period of a hardware timer according to expiration time of a timer node expires first in a timer linked list;
traverse through the timer node in the timer linked list, and update the counting period of the hardware timer, when the counting period of the hardware timer is expired.

### Claim 11 (depends on 10)

The apparatus according to claim 10, wherein the processor is further configured to:
determine whether the timer linked list is empty;
update the counting period of the hardware timer with a maximum counting period of the hardware timer when the timer linked list is empty;
obtain the expiration time of the timer node expires first in the timer linked list and current system time when the timer linked list is not empty;
determine whether a time interval between the expiration time of the timer node expires first and the current system time is greater than the maximum counting period of the hardware timer; and
update the counting period of the hardware timer with the maximum counting period of the hardware timer when the time interval is greater than the maximum counting period of the hardware timer, and update the counting period of the hardware timer with the time interval when the time interval is less than or equal to the maximum counting period of the hardware timer.

### Claim 12 (depends on 10)

The apparatus according to claim 10, wherein each timer node in the timer linked list is sorted according to their expiration time.

### Claim 13 (depends on 12)

The apparatus according to claim 12, wherein the processor is further configured to:
set a first timer node in the timer linked list to be a current timer node;
obtain current system time;
determine whether the current timer node is not empty and the current system time is greater than or equal to the expiration time of the current timer node and,
update the counting period of the hardware timer if the current timer node is empty or the current system time is less than the expiration time of the current timer node;
if the current timer node is not empty and the current system time is greater than or equal to the expiration time of the current timer node, execute a callback function of the current timer node; and
seta next timer node in the timer linked list to be the current timer node.

### Claim 14 (depends on 13)

The apparatus according to claim 13, wherein the processor is further configured to:
determine whether the current timer node is a periodic timer, and
if the current timer node is a periodic timer, update the expiration time of the current timer node, and set an update flag of the timer linked list to be True; and
if the current timer node is a one-time timer, delete the current timer node.

### Claim 15 (depends on 13)

The apparatus according to claim 13, wherein the processor is further configured to:
determine whether the update flag of the timer linked list is set to be True when the current timer node is empty or the current system time is less than the expiration time of the current timer node, and before the counting period of the hardware timer is updated; and
update ordering of the timer linked list if the update flag of the timer linked list is set to be True.

### Claim 16 (depends on 12)

The apparatus according to claim 12, wherein the processor is further configured to:
insert a new timer node into the timer linked list; and
when the new timer node is the first node in the timer linked list, update the counting period of the hardware timer according to expiration time of the new timer node.

### Claim 17 (depends on 16)

The apparatus according to claim 16, wherein the processor is further configured to:
obtain a timing duration of a timer node to be created and current system time;
calculate expiration time of the timer node to be created according to the timing duration of the timer node to be created and the current system time; and
insert the timer node to be created as a new timer node into the timer linked list according to the expiration time of the timer node to be created.

### Claim 18 (depends on 12)

The apparatus according to claim 12, wherein the processor is further configured to:
when a software timer is turned off, delete a timer node corresponding to the turned off software timer from the timer linked list; and
when the deleted timer node is a first node in the timer linked list, update the counting period of the hardware timer.

### Claim 19 (depends on 10)

The apparatus according to claim 10, wherein the processor is further configured to: when the counting period of the hardware timer is expired and before the timer node in the timer linked list is traversed through, update system time with the expiration time of the counting period of the hardware timer.

### Claim 20 (depends on 10)

The apparatus according to claim 10, wherein the processor is further configured to: update the counting period of the hardware timer according to an expiration time of a timer node next to the timer node expires first in the timer linked list.
