[go: up one dir, main page]

TWI462020B - Method for managing threads and electronic device using the same method - Google Patents

Method for managing threads and electronic device using the same method Download PDF

Info

Publication number
TWI462020B
TWI462020B TW101144571A TW101144571A TWI462020B TW I462020 B TWI462020 B TW I462020B TW 101144571 A TW101144571 A TW 101144571A TW 101144571 A TW101144571 A TW 101144571A TW I462020 B TWI462020 B TW I462020B
Authority
TW
Taiwan
Prior art keywords
time
thread
registered
interval
threads
Prior art date
Application number
TW101144571A
Other languages
Chinese (zh)
Other versions
TW201421366A (en
Inventor
pei hao Huang
Pei Jun Ko
yuan yao Tu
Chih Chun Wei
Yu Hsien Yang
Original Assignee
Htc Corp
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Htc Corp filed Critical Htc Corp
Priority to TW101144571A priority Critical patent/TWI462020B/en
Publication of TW201421366A publication Critical patent/TW201421366A/en
Application granted granted Critical
Publication of TWI462020B publication Critical patent/TWI462020B/en

Links

Landscapes

  • Power Sources (AREA)

Description

執行緒管理方法及其電子裝置Thread management method and electronic device thereof

本案是有關於一種執行緒管理機制,且特別是有關於利用執行時間排程技術來實現的一種執行緒管理方法及其電子裝置。The present invention relates to a thread management mechanism, and in particular to a thread management method and an electronic device thereof implemented by using an execution time scheduling technique.

目前在電子裝置上的應用程式趨於多元化且有通常需要同時段運作多個的執行緒。當獨自運作的各執行緒需要運作時,作業系統會喚醒處理器來執行一或多個需被處理的執行緒,因此處理器的使用時段可能會太密集,而減少處理器進入休眠的時間,進而消耗過多功率。Currently, applications on electronic devices tend to be diversified and there are threads that typically need to operate multiple segments simultaneously. When the various threads that operate on their own need to operate, the operating system wakes up the processor to execute one or more threads to be processed, so the processor's usage period may be too dense, and the processor's sleep time is reduced. In turn, it consumes too much power.

圖1A至圖1C為繪示一種執行緒與處理器的執行時序的示意圖。請參照圖1A,橫軸為時間軸且向右為時間增加,而時間軸上的時間點A1~A6為執行緒A需要被執行的的執行時間,由圖1A可觀察到執行緒A的執行週期,例如為100ms。請參照圖1B,時間軸上的時間點B1~B3為執行緒B需要被執行的的執行時間,由圖1B可觀察到執行緒B的執行週期,例如為200 ms。1A to 1C are schematic diagrams showing the execution timing of a thread and a processor. Referring to FIG. 1A, the horizontal axis is the time axis and the time is increased to the right, and the time points A1 to A6 on the time axis are the execution time that the thread A needs to be executed. The execution of the thread A can be observed from FIG. 1A. The period is, for example, 100 ms. Referring to FIG. 1B, the time points B1 B B3 on the time axis are the execution time that the thread B needs to be executed. The execution period of the thread B can be observed from FIG. 1B, for example, 200 ms.

執行緒A與執行緒B為各自獨立運作的執行緒。當執行緒A與執行緒B都需要被執行時,皆會喚醒處理器在適當的時間點執行執行緒A與執行緒B。圖1C繪示當執行緒A與執行緒B沒有經過適當時間排程管理的執行時序的示意圖,由圖1C可觀察到處理器最短每隔50 ms即需要 處理執行緒A或執行緒B,如此運作頻率太高而有高峰執行時段太密集的問題,且處理器沒有足夠時間進入休眠模式,導致較高功率消耗。因此,如何有效排程多個執行緒以改善處理器的功率消耗,仍為此項領域中需解決的問題。Thread A and Thread B are threads that operate independently. When both thread A and thread B need to be executed, the processor will wake up to execute thread A and thread B at the appropriate point in time. FIG. 1C is a schematic diagram showing the execution timing when the thread A and the thread B are not properly scheduled by the schedule. It can be observed from FIG. 1C that the processor needs to be every 50 ms. Handling thread A or thread B, the frequency of operation is too high and there is a problem that the peak execution period is too dense, and the processor does not have enough time to enter sleep mode, resulting in higher power consumption. Therefore, how to efficiently schedule multiple threads to improve the power consumption of the processor is still a problem to be solved in this field.

本案提供一種執行緒管理方法及其電子裝置,可經由作業系統中的一執行緒管理者來規劃排程記憶體中的多個執行緒的執行時間,以降低處理器的使用頻率,進而減少不必要的功率消耗。The present invention provides a thread management method and an electronic device thereof, which can plan the execution time of multiple threads in the scheduling memory through a thread manager in the operating system to reduce the frequency of use of the processor, thereby reducing The necessary power consumption.

本案提出一種執行緒管理方法。根據本案的一實施例,所述的方法適用於一電子裝置,並包括下列步驟。首先,取得目前時間,並計算處理器距離下一醒來時間點的間隔時間。再者,在達到此間隔時間之前,釋放此處理器。另外,當判斷達到間隔時間時或接收到處理器的第一通知信號,則取得第一最新時間以更新目前時間,並記錄目前時間作為基準時間,接著針對此執行緒中的多個已註冊執行緒,分別檢查此目前時間是否滿足記憶體所包括的多個已註冊執行緒的預設時間條件。此外,當判斷目前時間滿足這些已註冊執行緒中的一第一已註冊執行緒的預設時間條件時,喚醒並執行此第一已註冊執行緒。This case proposes a method of thread management. According to an embodiment of the present invention, the method is applicable to an electronic device and includes the following steps. First, the current time is taken and the interval between the processor and the next waking time point is calculated. Again, release this processor before this interval is reached. In addition, when it is judged that the interval time is reached or the first notification signal of the processor is received, the first latest time is obtained to update the current time, and the current time is recorded as the reference time, and then the plurality of registered executions in the thread are executed. Check whether the current time meets the preset time condition of multiple registered threads included in the memory. In addition, when it is determined that the current time satisfies the preset time condition of a first registered thread in the registered threads, the first registered thread is awake and executed.

本案提出一種電子裝置。根據本案的一實施例,所述的電子裝置包括了記憶體及處理器。此記憶體包括作業系統與多個執行緒,其中此作業系統包括執行緒管理者。此 處理器用來執行此作業系統、此執行緒管理者與這些執行緒。再者,執行緒管理者取得目前時間,並計算處理器距離下一醒來時間點的間隔時間。此執行緒管理者在達到間隔時間之前,釋放此處理器。當執行緒管理者判斷達到間隔時間時或接收到來自處理器的第一通知信號,執行緒管理者取得第一最新時間來更新目前時間,記錄目前時間作為基準時間,並針對記憶體內的多個已註冊執行緒,分別檢查目前時間是否滿足這些已註冊執行緒的預設時間條件。當判斷目前時間滿足這些已註冊執行緒中的一第一已註冊執行緒的預設時間條件時,執行緒管理者喚醒此第一已註冊執行緒。This case proposes an electronic device. According to an embodiment of the present disclosure, the electronic device includes a memory and a processor. The memory includes an operating system and a plurality of threads, wherein the operating system includes a thread manager. this The processor is used to execute this operating system, the thread manager and these threads. Furthermore, the thread manager takes the current time and calculates the interval between the processor and the next waking time. This thread manager releases the processor before the interval is reached. When the thread manager determines that the interval time has elapsed or receives the first notification signal from the processor, the thread manager obtains the first latest time to update the current time, records the current time as the reference time, and targets the plurality of memories. The registered thread is checked to check whether the current time meets the preset time conditions of these registered threads. The thread manager wakes up the first registered thread when it is determined that the current time satisfies the preset time condition of a first registered thread in the registered threads.

基於上述,本案之實施例提出執行緒管理方法及其電子裝置。經由執行緒管理者註冊多個執行緒,根據各執行緒的執行間隔的對應的預設時間條件,來規劃處理器的執行流程,並將對應預設時間條件被滿足的執行緒喚醒,以增加處理器被釋放的時間,進而達到節省功率消耗的功效。Based on the above, the embodiment of the present invention proposes a thread management method and an electronic device thereof. Registering a plurality of threads via the thread manager, planning a execution flow of the processor according to a corresponding preset time condition of the execution interval of each thread, and awakening the thread corresponding to the preset time condition to be awakened to increase The time the processor is released, which in turn saves power consumption.

為讓本案之上述特徵和優點能更明顯易懂,下文特舉實施例,並配合所附圖式作詳細說明如下。In order to make the above features and advantages of the present invention more comprehensible, the following detailed description of the embodiments and the accompanying drawings.

圖2是根據本案之一實施例所繪示一種電子裝置的功能方塊圖。請參照圖2,此電子裝置20包括記憶體210及處理器220。記憶體210連接至處理器220,用以儲存作業系統211、驅動程式單元213、應用程式單元214、程式單 元215及程式單元216的程式碼分別對應的多個執行緒等,由處理器220處理執行。另外,作業系統211包括一執行緒管理者(thread manager)212,可以由處理器220執行,用來管理此電子裝置20中多個執行緒的執行時序。處理器220例如為中央處理器或具有多個處理器核心組合的處理器電路。FIG. 2 is a functional block diagram of an electronic device according to an embodiment of the present invention. Referring to FIG. 2 , the electronic device 20 includes a memory 210 and a processor 220 . The memory 210 is connected to the processor 220 for storing the operating system 211, the driver unit 213, the application unit 214, and the program list. The plurality of threads corresponding to the code of the unit 215 and the program unit 216 are processed and executed by the processor 220. In addition, the operating system 211 includes a thread manager 212 that can be executed by the processor 220 to manage the execution timing of the plurality of threads in the electronic device 20. Processor 220 is, for example, a central processing unit or a processor circuit having a plurality of combinations of processor cores.

更清楚說明,此執行緒管理者212可以註冊此電子裝置20中多個執行緒,但並非此電子裝置20中所有執行緒都會向執行緒管理者212註冊。執行緒管理者212可以包括一資料庫(未繪示),用來記錄已註冊執行緒與其對應的預設時間條件。執行緒管理者212取得目前時間(current tick),此目前時間可以為處理器提供的系統時間。執行緒管理者212利用目前時間計算處理器220距離下一醒來時間點的間隔時間。再者,此執行緒管理者212使處理器220在到達間隔時間之前處於被釋放的狀態。此即,此執行緒管理者212在間隔時間之前釋放處理器220,不執行已註冊執行緒。當處理器220不處理執行緒管理者212之已註冊執行緒時,此即被釋放狀態,處理器220可以進入休眠,或是處理器220執行非註冊的執行緒。More clearly, the thread manager 212 can register a plurality of threads in the electronic device 20, but not all threads in the electronic device 20 register with the thread manager 212. The thread manager 212 can include a database (not shown) for recording the preset time conditions corresponding to the registered thread. The thread manager 212 obtains the current tick, which can be the system time provided by the processor. The thread manager 212 utilizes the current time to calculate the interval between the processor 220 and the next waking time point. Again, the thread manager 212 causes the processor 220 to be in a released state before the interval time is reached. That is, the thread manager 212 releases the processor 220 before the interval time and does not execute the registered thread. When the processor 220 does not process the registered thread of the thread manager 212, the state is released, the processor 220 can go to sleep, or the processor 220 executes the unregistered thread.

當執行緒管理者212判斷在尚未到達間隔時間之前,假若接收到來自處理器220的第一通知信號(或作第一通知信息),則此執行緒管理者212取得一第一最新時間來更新所述目前時間,並記錄所述目前時間為一基準時間。所述基準時間為代表此處理器220最近一次(或作最後一次)執行完成 已註冊執行緒中的任何一執行緒的結束時間。接著,執行緒管理者212可以針對記憶體210中多個執行緒中的多個已註冊執行緒,分別檢查已更新的目前時間是否滿足這些已註冊執行緒的多個預設時間條件。此外,當執行緒管理者212檢查到目前時間滿足這些已註冊執行緒中的一已註冊執行緒的預設時間條件時,此執行緒管理者212會喚醒此一已註冊執行緒,並由處理器220來執行此第一已註冊執行緒。例如,所述已註冊執行緒的預設時間條件包括:已註冊執行緒的一理想間隔時間(ideal interval)、一最大容許間隔時間(maximum interval)與一最小容許間隔時間(minimum interval)。When the thread manager 212 determines that the first notification signal (or the first notification information) from the processor 220 is received before the interval has elapsed, the thread manager 212 obtains a first latest time to update. The current time, and recording the current time as a reference time. The reference time is the last (or last) execution of the processor 220. The end time of any thread in the registered thread. Then, the thread manager 212 can separately check whether the updated current time meets a plurality of preset time conditions of the registered threads for the plurality of registered threads in the plurality of threads in the memory 210. In addition, when the thread manager 212 checks that the current time meets the preset time condition of a registered thread in the registered threads, the thread manager 212 wakes up the registered thread and processes it. The device 220 executes the first registered thread. For example, the preset time condition of the registered thread includes: an ideal interval of the registered thread, a maximum interval, and a minimum interval.

圖3是根據本案之一實施例所繪示一種執行緒管理方法的流程圖。請同時參照圖2與圖3,此執行緒管理方法300起始於步驟S301。在步驟S301中,執行緒管理者212取得目前時間(例如,利用預設函式軟體取得系統時間),並計算處理器220從現在開始到下一醒來時間點之間的一段間隔時間。具體的執行緒管理者212計算間隔時間方法將參照圖5來詳細描述。FIG. 3 is a flow chart showing a method of thread management according to an embodiment of the present invention. Referring to FIG. 2 and FIG. 3 simultaneously, the thread management method 300 starts at step S301. In step S301, the thread manager 212 obtains the current time (for example, using the preset function to obtain the system time), and calculates an interval between the processor 220 from now to the next waking time point. The specific thread manager 212 calculates the interval method, which will be described in detail with reference to FIG.

在步驟S302,在此段間隔時間中,執行緒管理者212使處理器220處於被釋放的狀態以使其可進行其他任務或處於省電狀態(例如,進入休眠模式)。接著,在步驟S303中,執行緒管理者212判斷是否在到達間隔時間之前有接收到來自處理器220的第一通知信號,此第一通知信號例如為處理器220因被其它非註冊執行緒喚醒而產生的通知 信號,用來通知執行緒管理者212處理器220沒有在休眠模式。在步驟S303中,假若執行緒管理者212有接收到此第一通知信號,則在步驟S303之後執行步驟S305;假若執行緒管理者212沒有接收到此第一通知信號,則在步驟S303之後執行步驟S304。At step S302, during this interval, the thread manager 212 places the processor 220 in a released state to enable it to perform other tasks or to be in a power saving state (eg, to enter a sleep mode). Next, in step S303, the thread manager 212 determines whether a first notification signal from the processor 220 is received before the interval time is reached. The first notification signal is, for example, that the processor 220 is awakened by other unregistered threads. Generated notification A signal is used to notify the thread manager 212 that the processor 220 is not in sleep mode. In step S303, if the thread manager 212 has received the first notification signal, step S305 is performed after step S303; if the thread manager 212 does not receive the first notification signal, it is executed after step S303. Step S304.

在步驟S304中,執行緒管理者212進一步判斷目前時間是否已達到上述所計算處理器220的下一個醒來時間點,此即是否到達在步驟S301計算的間隔時間。在步驟S304中,假若執行緒管理者212判斷已到達間隔時間,則在步驟S304之後執行步驟S305;假若執行緒管理者212判斷尚未到達下一醒來時間點,則處理器220繼續保持被釋放狀態而不執行任何一已註冊執行緒,並在步驟S304之後返回執行步驟S303作重新確認。In step S304, the thread manager 212 further determines whether the current time has reached the next wake-up time point of the above-mentioned calculated processor 220, that is, whether the interval time calculated in step S301 has been reached. In step S304, if the thread manager 212 determines that the interval has been reached, step S305 is performed after step S304; if the thread manager 212 determines that the next wake-up time point has not been reached, the processor 220 continues to be released. The state does not execute any of the registered threads, and after step S304, returns to step S303 for reconfirmation.

由上述可知,在判斷到達所計算下一醒來時間點或接收到來自處理器220的第一通知信號時,皆會執行步驟S305。在此步驟S305中,處理器220已開始執行記憶體210中的一或多個執行緒,這些執行緒可以為已註冊執行緒或非註冊執行緒。因此,為了更新處理器220的執行時間紀錄,在步驟S305中,執行緒管理者212取得一第一最新時間以更新所述目前時間,並記錄所述目前時間為一基準時間,所述基準時間代表此處理器220最近一次(或作最後一次)執行完成已註冊執行緒中的任何一個執行緒的結束時間(或作last round tickcount)。As can be seen from the above, when it is determined that the calculated next wake-up time point is reached or the first notification signal from the processor 220 is received, step S305 is performed. In this step S305, the processor 220 has started executing one or more threads in the memory 210, which may be registered or unregistered threads. Therefore, in order to update the execution time record of the processor 220, in step S305, the thread manager 212 obtains a first latest time to update the current time, and records the current time as a reference time, the reference time. Represents the last (or last) execution of this processor 220 to complete the end time of any of the registered threads (or last round tickcount).

在步驟S305之後接續進行步驟S306。在步驟S306 中,執行緒管理者212判斷是否有尚未檢查過的已註冊執行緒。在步驟S306中,當執行緒管理者212判斷仍有尚未檢查過的已註冊執行緒,則在步驟S306之後進行步驟S307;當執行緒管理者212判斷沒有尚未檢查過的已註冊執行緒,則在步驟S306之後返回進行步驟S301,重新計算一間隔時間,並使處理器220再度回到被釋放的狀態。。Step S306 is continued after step S305. At step S306 The thread manager 212 determines whether there is a registered thread that has not been checked. In step S306, when the thread manager 212 determines that there is still a registered thread that has not been checked yet, step S307 is performed after step S306; when the thread manager 212 determines that there is no registered thread that has not been checked yet, Returning to step S301 after step S306, the interval time is recalculated and the processor 220 is returned to the released state again. .

在步驟S307中,執行緒管理者212由尚未被檢查的一或多個已註冊執行緒中,選取一已註冊執行緒來判斷目前時間是否滿足已註冊執行緒的預設時間條件。在步驟S307中,當執行緒管理者212判斷目前時間沒有滿足當前被檢查之已註冊執行緒的預設時間條件,則在步驟S307之後返回執行步驟S305,更新目前時間並重新設定基準時間;當執行緒管理者212判斷目前時間已滿足當前被檢查之已註冊執行緒的預設時間條件,則在步驟S307之後執行步驟S308。在步驟S308中,由執行緒管理者212喚醒此已註冊執行緒,並由處理器220執行已註冊執行緒的相關步驟(或作讓執行緒進行對應工作)。In step S307, the thread manager 212 selects a registered thread from one or more registered threads that have not been checked to determine whether the current time satisfies the preset time condition of the registered thread. In step S307, when the thread manager 212 determines that the current time does not meet the preset time condition of the currently checked registered thread, then returns to step S305 after step S307 to update the current time and reset the reference time; The thread manager 212 determines that the current time has met the preset time condition of the currently registered registered thread, and then performs step S308 after step S307. In step S308, the registered thread is awakened by the thread manager 212, and the processor 220 executes the relevant steps of the registered thread (or the thread to perform the corresponding work).

從另一角度來看,步驟S305、S306、S307整體可視為分別檢查此目前時間是否滿足執行緒管理者212記錄的多個已註冊執行緒各自的預設時間條件。From another point of view, the steps S305, S306, and S307 are generally regarded as respectively checking whether the current time satisfies the preset time condition of each of the plurality of registered threads recorded by the thread manager 212.

假若處理器220是因為執行緒管理者212到達間隔時間而被喚醒運作,則詳細的判斷方式將利用圖6來描述。假若執行緒管理者212在到達間隔時間之前因為接收到處理器220的第一通知訊號,詳細的判斷方式將利用圖7來 描述。If the processor 220 is awakened to operate because the thread manager 212 has reached the interval, the detailed determination will be described using FIG. If the thread manager 212 receives the first notification signal from the processor 220 before the interval interval, the detailed judgment manner will be as shown in FIG. description.

圖4A至圖4C是根據本案之一實施例所繪示另一種執行緒管理方法的流程圖。請同時參照圖2、圖4A至圖4C,在此實施例中,圖4B的步驟S301至步驟S308類似於圖3的步驟S301至步驟S308,因此相關的詳細技術內容可以參照圖3,在此不重新描述這些技術內容。4A-4C are flowcharts illustrating another thread management method according to an embodiment of the present disclosure. Referring to FIG. 2 and FIG. 4A to FIG. 4C simultaneously, in this embodiment, steps S301 to S308 of FIG. 4B are similar to steps S301 to S308 of FIG. 3, and thus the related detailed technical content may refer to FIG. These technical contents are not re-described.

請參照圖2與圖4A,在步驟S401中,在作業系統211中創建一執行緒管理者212,此執行緒管理者212的程式碼被儲存於記憶體210內,當處理器220處理執行緒管理者212的相關程序之程式碼時,執行緒管理者212可以排程已註冊的一或多個執行緒,並規劃處理器220的使用時間,進而使已註冊執行緒的執行時間,儘量與處理器220的省電模式週期一致。如此可以降低處理器220由省電模式(或作休眠模式)被喚醒的頻率,或者減少處理器220的忙碌時間。Referring to FIG. 2 and FIG. 4A, in step S401, a thread manager 212 is created in the operating system 211. The code of the thread manager 212 is stored in the memory 210, and the processor 220 processes the thread. When the code of the related program of the manager 212 is coded, the thread manager 212 can schedule one or more threads that have been registered, and plan the usage time of the processor 220, thereby making the execution time of the registered thread as much as possible. The power saving mode period of the processor 220 is consistent. This can reduce the frequency at which the processor 220 is woken up by the power saving mode (or the sleep mode), or reduce the busy time of the processor 220.

所述註冊這些已註冊執行緒的步驟可以包括,利用一表格(如下表1所述)、記憶體210中的一資料結構(未繪示)或記憶體210中的一資料庫(未繪示)分別記錄這些已註冊執行緒的理想間隔時間(Interval(ideal))、最大容許間隔時間(Interval(max))與最小容許間隔時間(Interval(min)),其中為了使執行緒具有實行彈性度,執行緒管理者212記錄的最大容許間隔時間與最小容許間隔時間之間的差值大於或等於處理器的睡眠模式單位時間(或作CPU_IDLE_REQUIRE_TIME)。The step of registering the registered threads may include using a table (described in Table 1 below), a data structure (not shown) in the memory 210, or a database in the memory 210 (not shown) ) Record the ideal interval (Interval(ideal)), the maximum allowable interval (Interval(max)), and the minimum allowable interval (Interval(min)) of these registered threads, in order to make the thread flexible. The difference between the maximum allowable interval and the minimum allowable interval recorded by the thread manager 212 is greater than or equal to the sleep mode unit time of the processor (or CPU_IDLE_REQUIRE_TIME).

在此實施例中,記憶體中仍有未向執行緒管理者212註冊的執行緒,這些執行緒不受執行緒管理者212的控制或管理,因此當這些未註冊執行緒的其中之一運作時,會導致處理器220發出第一通知信號以知會執行緒管理者212處理器220已處於忙碌狀態,或由休眠模式被喚醒。In this embodiment, there are still threads in the memory that are not registered with the thread manager 212. These threads are not controlled or managed by the thread manager 212, so when one of these unregistered threads operates At this time, the processor 220 may be caused to issue a first notification signal to notify the thread manager 212 that the processor 220 is already in a busy state or is woken up by the sleep mode.

在步驟S403中,執行緒管理者212判斷是否有驅動程式或應用程式需要週期性讀取/寫入資料或週期性執行對應工作,或是否有新的執行緒被產生且向執行緒管理者212進行註冊。在步驟S403中,假若執行緒管理者212判斷沒有發生上述事件(對應於不同執行緒要被執行的條件),則反覆執行步驟S403作重新的確認;假若執行緒管理者212判斷有發生上述事件,則在步驟S403之後執行步驟S301,後續在圖4B中的步驟S301至步驟S308的技術內容請參照圖3。此即,由於在步驟S403中有執行緒需要執行對應工作,或是否有新的執行緒被產生且向執行緒管理者212進行註冊,因此在步驟S403之後執行緒管理者212需要重新取得目前時間,並據此計算處理器220從現在的時間點到下一醒來時間點之間的間隔時間。In step S403, the thread manager 212 determines whether there is a driver or application that needs to periodically read/write data or periodically perform corresponding work, or whether a new thread is generated and directed to the thread manager 212. Sign up. In step S403, if the thread manager 212 determines that the above event has not occurred (corresponding to the condition that the different thread is to be executed), the step S403 is repeatedly performed for reconfirmation; if the thread manager 212 determines that the event occurs Then, step S301 is performed after step S403, and the technical content of step S301 to step S308 in FIG. 4B is followed by FIG. 3. That is, since there is a thread in step S403 that needs to perform the corresponding work, or whether a new thread is generated and registered with the thread manager 212, the thread manager 212 needs to reacquire the current time after step S403. And calculating the interval between the current time point of the processor 220 and the next waking time point.

請參照圖2與圖4C,在步驟S308之後接續進行步驟S405。在步驟S405中,被喚醒的已註冊執行緒自行判斷是否完成工作。在步驟S405中,當此已註冊執行緒已完成工作,在步驟S405之後接續進行步驟S407;當此已註冊執行緒尚未完成工作,在步驟S405之後反覆執行步驟S405以重新確認。Referring to FIG. 2 and FIG. 4C, step S405 is performed after step S308. In step S405, the awakened registered thread determines whether or not the work is completed. In step S405, when the registered thread has completed the work, the step S407 is continued after the step S405; when the registered thread has not completed the work, the step S405 is repeatedly executed after the step S405 to reconfirm.

值得注意的是,在步驟S308中,當一已註冊執行緒被喚起而執行相關動作後,會進入步驟S405反覆判斷此執行緒是否完成相關動作,又或者在完成所有相關動作後才進入步驟S405;若已完成相關動作,則此已註冊執行緒會在步驟S407中送出第二通知信號至執行緒管理者212,並接續進行步驟S301,以取得一第二最新時間以更新目前時間,並利用所述目前時間來重新計算處理器220距離下一次醒來時間點的另一間隔時間。It should be noted that, in step S308, after a registered thread is invoked to perform the related action, the process proceeds to step S405 to repeatedly determine whether the thread completes the related action, or proceeds to step S405 after completing all related actions. If the related action has been completed, the registered thread will send a second notification signal to the thread manager 212 in step S407, and then proceed to step S301 to obtain a second latest time to update the current time and utilize The current time recalculates another interval between the processor 220 and the next waking time point.

以下將參照表1作為範例來詳細描述預設時間條件可以包括的已註冊執行緒的一理想間隔時間、一最大容許間隔時間與一最小容許間隔時間。An ideal interval time, a maximum allowable interval time, and a minimum allowable interval time of the registered threads that can be included in the preset time condition will be described in detail below with reference to Table 1 as an example.

表1詳列執行緒1~執行緒4的多個預設時間條件。請參照表1,在表1的執行緒1~執行緒4例如為驅動程式單元213、應用程式單元214、程式單元215與程式單元216的預設時間條件。這些預設時間條件可在執行緒管理者212註冊這些執行緒時記錄,且之後被用來計算適合的間 隔時間。Table 1 details the preset time conditions of Thread 1 to Thread 4. Referring to Table 1, the thread 1 to thread 4 of Table 1 are, for example, preset time conditions of the driver unit 213, the application unit 214, the program unit 215, and the program unit 216. These preset time conditions can be recorded when the thread manager 212 registers these threads and are then used to calculate the appropriate interval. Every other time.

執行緒1~執行緒4的間隔時間(理想的)、間隔時間(最大的)與間隔時間(最小的)皆為處理器的睡眠模式單位時間的倍數,在表1中僅列出睡眠模式單位時間的倍數值(或作乘數),且單位皆為毫秒(ms)。最後一次被執行時間(last tick)則也被修整運算(round)為睡眠模式單位時間的倍數。舉例說明,執行緒1的最後一次被執行時間為150 ms,而其理想的間隔時間為5倍睡眠模式單位時間,最大可容許間隔時間為8倍睡眠模式單位時間,而最小可容許間隔時間為0倍睡眠模式單位時間,此即在執行完執行緒1後最小間隔時間為處理器220立即再一次處理執行緒1。The interval (ideal), interval (maximum) and interval (minimum) of thread 1 to thread 4 are all multiples of the sleep mode unit time of the processor. Only the sleep mode units are listed in Table 1. The multiple of the time (or multiplier) and the unit is milliseconds (ms). The last time tick is also rounded to a multiple of the sleep mode unit time. For example, the last execution time of thread 1 is 150 ms, and its ideal interval time is 5 times sleep mode unit time, the maximum allowable interval time is 8 times sleep mode unit time, and the minimum allowable interval time is 0 times sleep mode unit time, this is the minimum interval after executing thread 1 for processor 220 to immediately process thread 1 again.

其他執行緒2~執行緒4的理想的間隔時間,最大可容許間隔時間,以及最小可容許間隔時間可參照表1而得知。舉例來說,假定處理器的睡眠模式單位時間為50ms,執行緒管理者212可由表1推算下一次喚醒執行緒1之理想的間隔時間為150+50*5=400 ms;可由表1推算下一次喚醒執行緒1之最大可容許的間隔時間為150+50*8=550 ms;可由表1推算下一次喚醒執行緒1之最小可容許的間隔時間為150+50*0=150 ms。依照上述原理可推算出執行緒2~執行緒4的間隔時間(理想的)、間隔時間(最大的)與間隔時間(最小的)。The ideal interval time of the other threads 2 to Thread 4, the maximum allowable interval time, and the minimum allowable interval time can be known from Table 1. For example, assuming that the sleep mode unit time of the processor is 50 ms, the thread manager 212 can estimate from Table 1 that the ideal interval time for the next wake-up thread 1 is 150+50*5=400 ms; The maximum allowable interval for wake-up thread 1 is 150+50*8=550 ms; the minimum allowable interval for wake-up thread 1 from Table 1 is 150+50*0=150 ms. According to the above principle, the interval (ideal), interval time (maximum), and interval time (minimum) of the thread 2 to the thread 4 can be derived.

在此值得一提的是,表1中各執行緒的最後執行時間會持續地因執行緒管理者212取得最新的目前時間而被更新。It is worth mentioning here that the last execution time of each thread in Table 1 is continuously updated by the thread manager 212 obtaining the latest current time.

圖5是根據本案之一實施例所繪示一種計算適合間隔時間方法的流程圖。請參照圖5,所述計算適合間隔時間方法詳細描述步驟S301的技術內容,並起始於步驟S501。在步驟S501中,執行緒管理者212可以取得一第二最新時間以更新目前時間,並將所述目前時間減去最近一次處理器220執行任何一已註冊執行緒的結束時間(或作基準時間)以取得一時間差值作為第一時間差值。FIG. 5 is a flow chart of a method for calculating a suitable interval time according to an embodiment of the present invention. Referring to FIG. 5, the calculation of the suitable interval time method details the technical content of step S301, and starts at step S501. In step S501, the thread manager 212 may obtain a second latest time to update the current time, and subtract the current time from the last time the processor 220 executed the end time of any registered thread (or the reference time). Taking a time difference as the first time difference.

接著,在步驟S502中,執行緒管理者212對此第一時間差值進行一修整運算,以將此第一時間差值調整成睡眠模式單位時間的一倍數,以成為睡眠模式單位時間與第一乘數的乘積的第二時間差值。在此,第一乘數為一倍率。例如,假若睡眠模式單位時間為50,則此修整運算以25為單位,假若第一時間差值大於或等於25,則取第一乘數為1,因此第二時間差值為50。假若睡眠模式單位時間為50,則此修整運算以25為單位,假若第一時間差值小於25,則取第一乘數為0而成第二時間差值0。如此一來,時間差值被調整為睡眠模式單位時間的倍數,使得處理器220有足夠時間進入休眠模式。Next, in step S502, the thread manager 212 performs a trimming operation on the first time difference value to adjust the first time difference value to a multiple of the sleep mode unit time to become the sleep mode unit time and the first The second time difference of the product of a multiplier. Here, the first multiplier is a magnification. For example, if the sleep mode unit time is 50, the trimming operation is in units of 25, and if the first time difference is greater than or equal to 25, the first multiplier is taken as 1, so the second time difference is 50. If the sleep mode unit time is 50, the trimming operation is in units of 25, and if the first time difference is less than 25, the first multiplier is 0 and the second time difference is 0. As such, the time difference is adjusted to a multiple of the sleep mode unit time so that the processor 220 has sufficient time to enter the sleep mode.

在步驟S503中,執行緒管理者212將睡眠模式單位時間之倍數的第二時間差值加上所述基準時間而得到第三時間差值,其中此第三時間差值為剛執行完或剛被加入之一已註冊執行緒的最近一次執行時間或註冊時間(參照圖4A及圖4C進入步驟S301的時機,即為已註冊執行緒註冊時間或執行結束時間)。因此,在步驟S504中,執行 緒管理者212還可以用此第三時間差值分別更新由基準時間到第二最新時間之間的新加入之一或多個執行緒的最近一次註冊時間,或更新由基準時間到第二最新時間之間已註冊執行緒的其中之一剛被執行的最近一次執行時間。如此一來,部份已註冊執行緒的最近一次註冊時間,或最近一次執行時間,會被調整為相同時間點。In step S503, the thread manager 212 adds the second time difference of the multiple of the sleep mode unit time to the reference time to obtain a third time difference, wherein the third time difference is just executed or just The latest execution time or registration time of one of the registered threads is added (refer to the timing of step S301 with reference to FIGS. 4A and 4C, that is, the registered thread registration time or the execution end time). Therefore, in step S504, execution is performed The manager 212 can also use the third time difference to update the latest registration time of one or more threads newly added from the reference time to the second latest time, or update from the reference time to the second latest The last execution time of one of the registered threads that has just been executed. As a result, the last registration time of some registered threads, or the last execution time, will be adjusted to the same time point.

在步驟S505中,執行緒管理者212將新加入執行緒(或作新註冊執行緒)之已更新的註冊時間或剛被執行的已註冊執行緒的最近一次執行時間分別加上對應的最大容許間隔時間,並得到多個間隔時間。In step S505, the thread manager 212 adds the updated registration time of the newly added thread (or the newly registered thread) or the latest execution time of the registered thread just executed, respectively, to the corresponding maximum tolerance. Interval and get multiple intervals.

在步驟S506中,執行緒管理者212由這些間隔時間值中,選擇一最小的間隔時間值作為處理器的一下一次最早醒來時間點,並據此更新所述間隔時間。所述間隔時間為,處理器220由目前時間到下一次醒來的一最早醒來時間點的一段間隔時間。在所述間隔時間中執行緒管理者212使處理器220處於被釋放狀態。而此間隔時間的計算方式詳細步驟介紹如下。In step S506, the thread manager 212 selects a minimum interval time value from among the interval time values as the next earliest wake-up time point of the processor, and updates the interval time accordingly. The interval is an interval between the current time and the next waking time point that the processor 220 wakes up next time. The thread manager 212 places the processor 220 in the released state during the interval. The detailed steps for calculating the interval are described below.

在步驟S507中,執行緒管理者212將此最早醒來時間點減去所述目前時間而得到一間隔時間為第四時間差值,此第四時間差值為目前時間與處理器220下次需醒來時間點之間的一時間差值。接著,在步驟S508中,執行緒管理者212將此第四時間差值修整運算成為睡眠模式單位時間的一倍數而得第五時間差值,其中,第五時間差值為睡眠模式單位時間乘以第二乘數的乘積值。In step S507, the thread manager 212 subtracts the current time from the earliest wake-up time point to obtain an interval time as a fourth time difference, the fourth time difference being the current time and the processor 220 next time. A time difference between the time points to wake up. Next, in step S508, the thread manager 212 performs the fourth time difference trimming operation to become a multiple of the sleep mode unit time to obtain a fifth time difference value, wherein the fifth time difference value is the sleep mode unit time multiplication. The product value in the second multiplier.

在步驟S509中,執行緒管理者212判斷此第二乘數是否為零。在步驟S509中,當執行緒管理者212判斷此第二乘數為零,則在步驟S509之後執行步驟S510;在步驟S509中,當執行緒管理者212判斷此第二乘數不為零,則在步驟S509之後執行步驟S511。In step S509, the thread manager 212 determines whether the second multiplier is zero. In step S509, when the thread manager 212 determines that the second multiplier is zero, step S510 is performed after step S509; in step S509, when the thread manager 212 determines that the second multiplier is not zero, Then, step S511 is performed after step S509.

在步驟S510中,執行緒管理者212以未經過修整運算的第四時間差值作為間隔時間。在步驟S511中,執行緒管理者212,以經過修整運算的第五時間差值作為間隔時間,以取得處理器220之最佳時間利用。In step S510, the thread manager 212 takes the fourth time difference value that has not undergone the trimming operation as the interval time. In step S511, the thread manager 212 takes the fifth time difference value of the trimming operation as the interval time to obtain the optimal time utilization of the processor 220.

圖6是根據本案之一實施例所繪示一種檢查目前時間是否符合執行緒預設時間條件的方法的流程圖。請同時參照圖2與圖6,在此實施例中,當到達間隔時間後,處理器220結束被釋放的狀態。在步驟S601中,執行緒管理者212分別對所有已註冊執行緒,分別取得目前時間減去所有已註冊執行緒之對應的最近一次執行時間而得到多個時間差值。FIG. 6 is a flow chart of a method for checking whether a current time meets a thread preset time condition according to an embodiment of the present invention. Referring to FIG. 2 and FIG. 6, at the same time, in this embodiment, when the interval time is reached, the processor 220 ends the released state. In step S601, the thread manager 212 obtains a plurality of time differences for each of the registered threads, respectively, by obtaining the current execution time minus the latest execution time of all the registered threads.

接著,在步驟S602中,執行緒管理者212分別針對這些已註冊執行緒,判斷所計算出的這些時間差值是否大於或等於這些已註冊執行緒所對應的預設理想間隔時間。此即,在步驟S602中,執行緒管理者212分別判斷已註冊執行緒的對應時間差值是否大於或等於其對應的預設理想間隔時間。在步驟S602中,若執行緒管理者判斷一已註冊執行緒之對應時間差值大於或等於對應的預設理想間隔時間,則在步驟S602之後進行步驟S604。此即,執行 緒管理者212判定目前時間符合已註冊執行緒的預設時間條件。在步驟S604中,執行緒管理者212喚醒此已註冊執行緒,並由處理器220執行此已註冊執行緒的對應動作。Next, in step S602, the thread manager 212 determines, for each of the registered threads, whether the calculated time differences are greater than or equal to a preset ideal interval time corresponding to the registered threads. That is, in step S602, the thread manager 212 determines whether the corresponding time difference value of the registered thread is greater than or equal to its corresponding preset ideal interval time. In step S602, if the thread manager determines that the corresponding time difference of a registered thread is greater than or equal to the corresponding preset ideal interval time, step S604 is performed after step S602. That is, execution The thread manager 212 determines that the current time meets the preset time condition of the registered thread. In step S604, the thread manager 212 wakes up the registered thread, and the processor 220 executes the corresponding action of the registered thread.

在步驟S602中,假若執行緒管理者212判斷一已註冊執行緒之對應時間差值小於對應的預設理想間隔時間,則在步驟S602之後進行步驟S603。在步驟S603中,執行緒管理者212判定目前時間不符合已註冊執行緒的預設時間條件。In step S602, if the thread manager 212 determines that the corresponding time difference of a registered thread is less than the corresponding preset ideal interval time, step S603 is performed after step S602. In step S603, the thread manager 212 determines that the current time does not meet the preset time condition of the registered thread.

圖7是根據本案之一實施例所繪示另一種檢查目前時間是否符合執行緒預設時間條件的方法的流程圖。請同時參照圖2與圖7,在此實施例中,由於執行緒管理者212接收到來自處理器220的第一通知信號,而得知處理器220結束其釋放狀態。所述第一通知信號發生的情況例如為當使用者有輸入動作時,處理器220因處理輸入動作的執行緒被喚醒,因此執行緒管理者212要重新排程處理器下次要醒來的間隔時間,以使得執行緒預計被執行的時間與處理器下次要醒來的間隔時間儘量一致。或者,使執行緒預計被執行的時間同步化於處理器下次要醒來的間隔時間。在步驟S701中,執行緒管理者212取得所述目前時間,並利用目前時間分別減去這些已註冊執行緒所對應的最後一次執行時間,以取得多個時間差值。FIG. 7 is a flow chart showing another method for checking whether the current time meets the thread preset time condition according to an embodiment of the present invention. Referring to FIG. 2 and FIG. 7, at the same time, in this embodiment, since the thread manager 212 receives the first notification signal from the processor 220, it is known that the processor 220 ends its release state. The first notification signal occurs, for example, when the user has an input action, the processor 220 is awakened by the thread that processes the input action, so the thread manager 212 needs to re-schedule the processor to wake up next time. The interval is such that the time the thread is expected to be executed is as close as possible to the interval at which the processor will wake up next time. Alternatively, synchronize the time that the thread is expected to be executed to the interval at which the processor will wake up next time. In step S701, the thread manager 212 obtains the current time, and subtracts the last execution time corresponding to the registered threads by the current time to obtain a plurality of time differences.

接著,在步驟S702中,執行緒管理者212分別針對這些已註冊執行緒,判斷這些時間差值是否大於或等於這些已註冊執行緒的對應最小理想間隔時間。此即相似於在 步驟S602中,執行緒管理者212分別判斷已註冊執行緒的對應時間差值是否大於或等於其對應的預設理想間隔時間。Next, in step S702, the thread manager 212 determines, for each of the registered threads, whether the time differences are greater than or equal to the corresponding minimum ideal interval of the registered threads. This is similar to In step S602, the thread manager 212 determines whether the corresponding time difference value of the registered thread is greater than or equal to its corresponding preset ideal interval time.

在步驟S702中,假若執行緒管理者212判斷時間差值小於這些已註冊執行緒的對應最小理想間隔時間,則於步驟S702之後接續進行步驟S703。此即,執行緒管理者212判定目前時間不符合已註冊執行緒的預設時間條件。在步驟S702中,假若執行緒管理者212判斷時間差值大於這些已註冊執行緒的對應最小理想間隔時間,則於步驟S702之後接續進行步驟S704。在步驟S704中,執行緒管理者212喚醒此已註冊執行緒,並由處理器220執行此已註冊執行緒的對應動作。In step S702, if the thread manager 212 determines that the time difference value is less than the corresponding minimum ideal interval time of the registered threads, then step S703 is followed by step S703. That is, the thread manager 212 determines that the current time does not meet the preset time condition of the registered thread. In step S702, if the thread manager 212 determines that the time difference is greater than the corresponding minimum ideal interval of the registered threads, then step S704 is followed by step S704. In step S704, the thread manager 212 wakes up the registered thread, and the processor 220 executes the corresponding action of the registered thread.

在圖7的實施例中,當執行緒管理者212儘快調整各已註冊執行緒的時間排程與處理器220的執行週期一致時,即可以降低跳頻(frequency hopping)的情況,因此才會在步驟S702中選擇利用對應最小理想間隔時間來判斷目前時間是否符合已註冊執行緒的預設時間條件。In the embodiment of FIG. 7, when the thread manager 212 adjusts the time schedule of each registered thread to be consistent with the execution cycle of the processor 220 as soon as possible, the frequency hopping can be reduced, and thus In step S702, it is selected to determine whether the current time meets the preset time condition of the registered thread by using the corresponding minimum ideal interval time.

本案另提供一種電腦程式產品,此電腦程式產品儲存一電腦可執行程式,其係用以執行上述執行緒管理方法的各個步驟,此電腦程式產品基本上是由多數個程式碼片段所組成的(例如建立組織圖程式碼片段、簽核表單程式碼片段、設定程式碼片段、以及部署程式碼片段),並且這些程式碼片段在載入通信裝置中並執行之後,即可完成上述執行緒管理方法的步驟與上述電子裝置的功能。The present invention further provides a computer program product for storing a computer executable program for performing the steps of the above thread management method. The computer program product is basically composed of a plurality of code segments ( For example, creating an organization chart code segment, signing a form code segment, setting a code segment, and deploying a code segment, and the code segments are loaded into the communication device and executed, the thread management method can be completed. The steps are the same as those of the above electronic device.

綜上所述,本案的多個實施例提出執行緒管理方法及其電子裝置。經由作業系統中的執行緒管理者以註冊多個執行緒,根據各執行緒的執行間隔的對應的預設時間條件,來規劃處理器的執行流程,或彈性因應非註冊執行緒喚醒處理器情況,提前喚醒符合預設時間條件的執行緒。如此一來,可以增加處理器被釋放的時間,減少處理器由休眠模式進入忙碌模式的頻率,進而達到節省功率消耗的功效。In summary, various embodiments of the present invention propose a thread management method and an electronic device thereof. Registering multiple threads via the thread manager in the operating system, planning the execution flow of the processor according to the corresponding preset time condition of the execution interval of each thread, or flexibly waking up the processor in response to the non-registered thread , wake up the thread that meets the preset time condition in advance. In this way, the time when the processor is released can be increased, and the frequency of the processor entering the busy mode from the sleep mode can be reduced, thereby achieving the power consumption saving effect.

雖然本案已以實施例揭露如上,然其並非用以限定本案,任何所屬技術領域中具有通常知識者,在不脫離本案之精神和範圍內,當可作些許之更動與潤飾,故本案之保護範圍當視後附之申請專利範圍所界定者為準。Although the present invention has been disclosed in the above embodiments, it is not intended to limit the present invention. Anyone having ordinary knowledge in the technical field can protect the case without any deviation and refinement within the spirit and scope of the present case. The scope is subject to the definition of the scope of the patent application attached.

20‧‧‧電子裝置20‧‧‧Electronic devices

210‧‧‧記憶體210‧‧‧ memory

211‧‧‧作業系統211‧‧‧ operating system

212‧‧‧執行緒管理者212‧‧‧Thread Manager

213‧‧‧驅動程式單元213‧‧‧Driver unit

214‧‧‧應用程式單元214‧‧‧Application unit

215、216‧‧‧程式單元215, 216‧‧‧ program unit

220‧‧‧處理器220‧‧‧ processor

A1~A6、B1~B6‧‧‧時間點A1~A6, B1~B6‧‧‧ time points

S301~S308、S401~S407、S501~S511、S601~S604、S701~S704‧‧‧步驟S301~S308, S401~S407, S501~S511, S601~S604, S701~S704‧‧‧ steps

圖1A至圖1C是繪示一種執行緒與處理器的執行時序的示意圖。1A to 1C are schematic diagrams showing the execution timing of a thread and a processor.

圖2是根據本案之一實施例所繪示一種電子裝置的功能方塊圖。FIG. 2 is a functional block diagram of an electronic device according to an embodiment of the present invention.

圖3是根據本案之一實施例所繪示一種執行緒管理方法的流程圖。FIG. 3 is a flow chart showing a method of thread management according to an embodiment of the present invention.

圖4A至圖4C是根據本案之一實施例所繪示一種執行緒管理方法的流程圖4A-4C are flowcharts illustrating a thread management method according to an embodiment of the present disclosure.

圖5是根據本案之一實施例所繪示一種計算適合間隔方法的流程圖。FIG. 5 is a flow chart of a method for calculating a suitable interval according to an embodiment of the present invention.

圖6是根據本案之一實施例所繪示一種檢查目前時間符合執行緒之預設條件的方法的流程圖。FIG. 6 is a flow chart showing a method for checking that a current time meets a preset condition of a thread according to an embodiment of the present invention.

圖7是根據本案之一實施例所繪示另一種檢查目前時間符合執行緒預設條件的方法的流程圖。FIG. 7 is a flow chart showing another method for checking that the current time meets the thread preset condition according to an embodiment of the present invention.

S301~S308‧‧‧本案一實施例之執行緒管理方法的步驟S301~S308‧‧‧ steps of the thread management method of an embodiment of the present invention

Claims (22)

一種執行緒管理方法,適用於一電子裝置,所述電子裝置包括一處理器與一記憶體,所述記憶體包括多個執行緒,所述的方法包括:取得一目前時間,並計算該處理器距離下一醒來時間點的一間隔時間;在達到該間隔時間之前,釋放該處理器;當判斷達到該間隔時間時或接收到該處理器的一第一通知信號,則取得一第一最新時間以更新該目前時間,記錄該目前時間為一基準時間,並針對該些執行緒中的多個已註冊執行緒,分別檢查該目前時間是否滿足該些已註冊執行緒的多個預設時間條件;以及當該目前時間滿足該些已註冊執行緒中的一第一已註冊執行緒的預設時間條件時,喚醒該第一已註冊執行緒。A thread management method is applicable to an electronic device, the electronic device includes a processor and a memory, the memory includes a plurality of threads, and the method includes: obtaining a current time, and calculating the processing An interval time from the next wake-up time point; before the interval time is reached, the processor is released; when it is determined that the interval time is reached or a first notification signal of the processor is received, a first The latest time is to update the current time, record the current time as a reference time, and check whether the current time meets multiple presets of the registered threads for the plurality of registered threads in the threads. a time condition; and waking up the first registered thread when the current time satisfies a preset time condition of a first registered thread in the registered threads. 如申請專利範圍第1項所述的執行緒管理方法,其中在計算該處理器距離下一次醒來時間點的該間隔時間之前,所述執行緒管理方法更包括:創建一執行緒管理者;以及利用該執行緒管理者以註冊該些執行緒中的部份執行緒為該些已註冊執行緒。The thread management method of claim 1, wherein the thread management method further comprises: creating a thread manager before calculating the interval time of the processor from the next wake-up time point; And using the thread manager to register some of the threads in the threads for the registered threads. 如申請專利範圍第2項所述的執行緒管理方法,其中判斷達到該間隔時間時或接收到該第一通知信號的步驟包括:判斷在到達該間隔時間之前是否接收該處理器的該 第一通知信號,其中該處理器經由該第一通知信號告知該執行緒管理者目前該處理器已醒來。The thread management method of claim 2, wherein the step of determining that the interval time is reached or receiving the first notification signal comprises: determining whether the processor is received before the interval time is reached a first notification signal, wherein the processor informs the thread manager via the first notification signal that the processor is currently awake. 如申請專利範圍第1項所述的執行緒管理方法,其中分別檢查該目前時間是否滿足該些已註冊執行緒的該些預設時間條件的步驟包括:當判斷該目前時間無法滿足目前檢查的該第一已註冊執行緒的預設時間條件時,選取尚未檢查的一第二已註冊執行緒,並取得一第二最新時間以更新該目前時間。The thread management method of claim 1, wherein the step of separately checking whether the current time meets the preset time conditions of the registered threads comprises: determining that the current time cannot meet the current check When the preset time condition of the first registered thread is selected, a second registered thread that has not been checked is selected, and a second latest time is obtained to update the current time. 如申請專利範圍第1項所述的執行緒管理方法,其中在喚醒該第一已註冊執行緒的步驟之後,所述執行緒管理方法更包括:當接收該第一已註冊執行緒的一第二通知信號時,取得一第二最新時間以更新該目前時間,重新計算該處理器距離下一次醒來時間點的另一間隔時間,其中該第一已註冊執行緒經由該第二通知信號告知該執行緒管理者該第一已註冊執行緒已完成其執行程序。The thread management method of claim 1, wherein after the step of waking up the first registered thread, the thread management method further comprises: receiving a first registered thread When the signal is notified, a second latest time is obtained to update the current time, and another time interval between the processor and the next wake-up time point is recalculated, wherein the first registered thread is notified by the second notification signal. The thread manager has completed the execution of the first registered thread. 如申請專利範圍第4項所述的執行緒管理方法,其中分別檢查該目前時間是否滿足該些已註冊執行緒的該些預設時間條件的步驟包括:當判斷該目前時間都無法滿足該些已註冊執行緒的該些預設時間條件時,重新執行取得該目前時間,並計算該處理器距離下一醒來時間點的該間隔時間的步驟。The thread management method of claim 4, wherein the step of separately checking whether the current time meets the preset time conditions of the registered threads comprises: determining that the current time cannot satisfy the When the preset time conditions of the thread have been registered, the step of obtaining the current time and calculating the interval time of the processor from the next wake-up time point is re-executed. 如申請專利範圍第1項所述的執行緒管理方法,其中針對該些執行緒中的多個已註冊執行緒,分別檢查該目 前時間是否滿足該些已註冊執行緒的多個預設時間條件的步驟包括:當達到該間隔時間時,分別取得該目前時間減去該些已註冊執行緒的對應最後一次執行時間,以取得多個時間差值;以及分別針對該些已註冊執行緒判斷該些時間差值是否大於或等於該些已註冊執行緒的對應預設理想間隔時間;當該些已註冊執行緒中的該第一已註冊執行緒的對應時間差值大於或等於其對應預設理想間隔時間時,判定該目前時間滿足該第一已註冊執行緒的對應預設時間條件;以及當該些已註冊執行緒中的該第一已註冊執行緒的對應時間差值小於其預設理想間隔時間時,判定該目前時間沒有滿足其對應預設時間條件。The thread management method according to claim 1, wherein the target is checked for a plurality of registered threads in the threads Whether the previous time satisfies the plurality of preset time conditions of the registered threads includes: when the interval time is reached, respectively obtaining the current time minus the corresponding last execution time of the registered threads to obtain a plurality of time difference values; and determining, for each of the registered threads, whether the time difference values are greater than or equal to a corresponding preset ideal interval of the registered threads; and when the number of the registered threads is the same When the corresponding time difference of a registered thread is greater than or equal to the corresponding preset ideal interval time, determining that the current time meets the corresponding preset time condition of the first registered thread; and when the registered threads are registered When the corresponding time difference of the first registered thread is less than the preset ideal interval time, it is determined that the current time does not satisfy the corresponding preset time condition. 如申請專利範圍第1項所述的執行緒管理方法,其中針對該些執行緒中的多個已註冊執行緒,分別檢查該目前時間是否滿足該些已註冊執行緒的多個預設時間條件的步驟包括:當達到該間隔時間前接收到該第一通知信號時,分別取得該目前時間減去該些已註冊執行緒的對應最後一次執行時間,以取得多個時間差值;以及分別針對該些已註冊執行緒判斷該些時間差值是否大於該些已註冊執行緒的對應預設最小間隔時間;當該些已註冊執行緒中的該第一已註冊執行緒的對應 時間差值大於等於其對應預設最小間隔時間時,判定該目前時間滿足該第一已註冊執行緒的對應預設時間條件;以及當該些已註冊執行緒中的該第一已註冊執行緒的對應時間差值小於等於其對應預設理想間隔時間時,判定該目前時間沒有滿足其對應預設時間條件。The thread management method of claim 1, wherein for the plurality of registered threads in the threads, checking whether the current time satisfies a plurality of preset time conditions of the registered threads The step of: receiving the first notification signal before the interval time is reached, respectively obtaining the current time minus the corresponding last execution time of the registered threads to obtain a plurality of time differences; The registered threads determine whether the time difference values are greater than corresponding preset minimum interval times of the registered threads; and corresponding to the first registered threads in the registered threads When the time difference is greater than or equal to the corresponding preset minimum interval time, determining that the current time meets the corresponding preset time condition of the first registered thread; and when the first registered thread in the registered threads When the corresponding time difference is less than or equal to the corresponding preset ideal interval time, it is determined that the current time does not satisfy the corresponding preset time condition. 如申請專利範圍第2項所述的執行緒管理方法,其中註冊該些已註冊執行緒的步驟包括:分別記錄該些已註冊執行緒的一理想間隔時間、一最大容許間隔時間與一最小容許間隔時間,其中該最大容許間隔時間與該最小容許間隔時間的一差值大於等於該處理器的一睡眠模式單位時間。The thread management method of claim 2, wherein the step of registering the registered threads comprises: respectively recording an ideal interval time, a maximum allowable interval time, and a minimum tolerance of the registered threads. The interval time, wherein a difference between the maximum allowable interval time and the minimum allowable interval time is greater than or equal to a sleep mode unit time of the processor. 如申請專利範圍第9項所述的執行緒管理方法,其中計算該間隔時間的步驟包括:取得一第二最新時間以更新該目前時間,將該目前時間減去該基準時間以取得一第一時間差值,其中該基準時間為該處理器最近一次執行該些已註冊執行緒之任何一者的結束時間點;對該第一時間差值進行一修整運算,以取得該睡眠模式單位時間乘上一第一乘數的乘積為一第二時間差值;將該第二時間差值加上該基準時間以產生一第三時間差值,利用該第三時間差值分別更新在該基準時間到該第二最新時間之間的一或多個新註冊執行緒的註冊時間或該些已註冊執行緒中的一第一已註冊執行緒的最後一次執行 時間;分別將該些新註冊執行緒的最後一次註冊時間或該第一已註冊執行緒的最後一次執行時間加上對應的最大容許間隔時間,以取得多個估測間隔時間;以及取得該些估測間隔時間中的一最小估測時間值為該處理器下一次醒來的一最早醒來時間點。The thread management method of claim 9, wherein the calculating the interval time comprises: obtaining a second latest time to update the current time, subtracting the current time from the current time to obtain a first time a time difference, wherein the reference time is an end time point at which the processor last executed any one of the registered threads; performing a trimming operation on the first time difference to obtain the sleep mode unit time multiplication The product of the previous first multiplier is a second time difference value; the second time difference value is added to the reference time to generate a third time difference value, and the third time difference value is respectively updated at the reference time The registration time of one or more new registration threads between the second most recent time or the last execution of a first registered thread in the registered threads Time; respectively, the last registration time of the new registration thread or the last execution time of the first registered thread plus the corresponding maximum allowable interval time to obtain multiple estimation intervals; and obtain the A minimum estimated time value in the estimated interval is the earliest wake-up time point that the processor wakes up next time. 如申請專利範圍第10項所述的執行緒管理方法,其中計算該間隔時間的步驟更包括:將該最早醒來時間點減去該目前時間以取得一第四時間差值,並將該間隔時間更新為該第四時間差值;對該第四時間差值進行該修整運算,以取得該睡眠模式單位時間乘上一第二乘數的乘積為一第五時間差值;判斷該第二乘數是否為0;當該第二乘數為0時,更新該間隔時間為該第四時間差值;以及當該第二乘數大於0時,更新該間隔時間為該第五時間差值。The thread management method according to claim 10, wherein the calculating the interval time further comprises: subtracting the current time from the earliest wake-up time point to obtain a fourth time difference, and the interval is The time is updated to the fourth time difference; the trimming operation is performed on the fourth time difference to obtain the product of the sleep mode unit time multiplied by a second multiplier as a fifth time difference; Whether the multiplier is 0; when the second multiplier is 0, updating the interval time is the fourth time difference; and when the second multiplier is greater than 0, updating the interval time to the fifth time difference . 一種電子裝置,包括:一記憶體,包括一作業系統與多個執行緒,其中該作業系統包括一執行緒管理者;以及一處理器,用來執行該作業系統、該執行緒管理者與該些執行緒,其中:該執行緒管理者取得一目前時間,並計算該處理器距離下一醒來時間點的一間隔時間; 該執行緒管理者在達到該間隔時間之前,釋放該處理器;當該執行緒管理者判斷達到該間隔時間或接收到該處理器的一第一通知信號,該執行緒管理者取得一第一最新時間來更新該目前時間,記錄該目前時間為一基準時間,並針對該些執行緒中的多個已註冊執行緒,分別檢查該目前時間是否滿足該些已註冊執行緒的多個預設時間條件;以及當該目前時間滿足該些已註冊執行緒中的一第一已註冊執行緒的預設時間條件時,該執行緒管理者喚醒該第一已註冊執行緒。An electronic device comprising: a memory comprising an operating system and a plurality of threads, wherein the operating system includes a thread manager; and a processor for executing the operating system, the thread manager and the Threads, wherein: the thread manager obtains a current time and calculates an interval between the processor and the next waking time point; The thread manager releases the processor before the interval is reached; when the thread manager determines that the interval is reached or a first notification signal is received by the processor, the thread manager obtains a first The latest time to update the current time, record the current time as a reference time, and check whether the current time meets multiple presets of the registered threads for the plurality of registered threads in the threads. a time condition; and when the current time satisfies a preset time condition of a first registered thread in the registered threads, the thread manager wakes up the first registered thread. 如申請專利範圍第12項所述的電子裝置,其中:該執行緒管理者註冊該些執行緒中的部份執行緒為該些已註冊執行緒;以及該執行緒管理者分別記錄該些已註冊執行緒的一理想間隔時間、一最大容許間隔時間與一最小容許間隔時間,其中該最大容許間隔時間與該最小容許間隔時間的一差值大於等於該處理器的一睡眠模式單位時間。The electronic device of claim 12, wherein: the thread manager registers part of the threads in the threads as the registered threads; and the thread manager records the An ideal interval time, a maximum allowable interval time, and a minimum allowable interval time of the registration thread, wherein a difference between the maximum allowable interval time and the minimum allowable interval time is greater than or equal to a sleep mode unit time of the processor. 如申請專利範圍第12項所述的電子裝置,其中該執行緒管理者更判斷在到達該間隔時間之前是否接收該處理器的該第一通知信號,其中該處理器經由該第一通知信號告知該執行緒管理者目前該處理器已醒來。The electronic device of claim 12, wherein the thread manager further determines whether the first notification signal of the processor is received before the interval is reached, wherein the processor is notified by the first notification signal The thread manager is currently waking up with the processor. 如申請專利範圍第12項所述的電子裝置,其中當該執行緒管理者判斷該目前時間無法滿足目前檢查的該第 一已註冊執行緒的預設時間條件時,該執行緒管理者選取尚未檢查的一第二已註冊執行緒,取得一第二最新時間來更新該目前時間,重新計算該處理器距離下一次醒來時間點的另一間隔時間。The electronic device of claim 12, wherein the thread manager determines that the current time cannot satisfy the current check When a preset time condition of a registered thread is received, the thread manager selects a second registered thread that has not been checked, obtains a second latest time to update the current time, and recalculates the processor distance to wake up next time. Another interval of time to come. 如申請專利範圍第12項所述的電子裝置,其中,當該執行緒管理者接收該第一已註冊執行緒的一第二通知信號時,該執行緒管理者取得一第二最新時間來更新該目前時間,重新計算該處理器距離下一次醒來時間點的另一間隔時間,其中該第一已註冊執行緒經由該通知信號告知該執行緒管理者該第一已註冊執行緒已完成其執行程序。The electronic device of claim 12, wherein when the thread manager receives a second notification signal of the first registered thread, the thread manager obtains a second latest time to update At the current time, recalculating another interval of the processor from the next waking time point, wherein the first registered thread informs the thread manager via the notification signal that the first registered thread has completed its execute program. 如申請專利範圍第15項所述的電子裝置,其中當該執行緒管理者判斷該目前時間都無法滿足該些已註冊執行緒的該些預設時間條件時,該執行緒管理者取得一第三最新時間以更新該基準時間,並重新計算該處理器距離下一次醒來時間點的另一間隔時間。The electronic device of claim 15, wherein the thread manager obtains a first time when the thread manager determines that the current time cannot satisfy the preset time conditions of the registered threads. Three latest times to update the base time and recalculate another interval between the processor and the next wake-up time point. 如申請專利範圍第12項所述的電子裝置,其中:當達到該間隔時間時,該執行緒管理者分別取得該目前時間減去該些已註冊執行緒的對應最後一次執行時間,以取得多個時間差值;以及該執行緒管理者分別針對該些已註冊執行緒判斷該些時間差值是否大於該些已註冊執行緒的對應預設理想間隔時間;當該執行緒管理者判斷該些已註冊執行緒中的該第一已註冊執行緒的對應時間差值大於其對應預設理想間隔時 間時,該執行緒管理者判定該目前時間滿足該第一已註冊執行緒的對應預設時間條件;以及當該執行緒管理者判斷該些已註冊執行緒中的該第一已註冊執行緒的對應時間差值小於等於其預設理想間隔時間時,該執行緒管理者判定該目前時間沒有滿足其對應預設時間條件。The electronic device of claim 12, wherein: when the interval is reached, the thread manager obtains the current time minus the corresponding last execution time of the registered threads to obtain more Time difference value; and the thread manager respectively determines, for the registered threads, whether the time differences are greater than corresponding preset ideal intervals of the registered threads; when the thread manager determines the The corresponding time difference of the first registered thread in the registered thread is greater than the corresponding preset ideal interval. During the time interval, the thread manager determines that the current time meets the corresponding preset time condition of the first registered thread; and when the thread manager determines the first registered thread in the registered threads When the corresponding time difference is less than or equal to its preset ideal interval time, the thread manager determines that the current time does not satisfy its corresponding preset time condition. 如申請專利範圍第12項所述的電子裝置,其中:當達到該間隔時間前接收到該第一通知信號時,該執行緒管理者分別取得該目前時間減去該些已註冊執行緒的對應最後一次執行時間,以取得多個時間差值;以及該執行緒管理者分別針對該些已註冊執行緒判斷該些時間差值是否大於該些已註冊執行緒的對應最小理想間隔時間;當該執行緒管理者判斷該些已註冊執行緒中的該第一已註冊執行緒的對應時間差值大於其對應預設理想間隔時間時,該執行緒管理者判定該目前時間滿足該第一已註冊執行緒的對應預設時間條件;以及當該執行緒管理者判斷該些已註冊執行緒中的該第一已註冊執行緒的對應時間差值小於等於其對應預設理想間隔時間時,該執行緒管理者判定該目前時間沒有滿足其對應預設時間條件。The electronic device of claim 12, wherein: when the first notification signal is received before the interval is reached, the thread manager obtains the current time minus the correspondence of the registered threads The last execution time to obtain a plurality of time differences; and the thread manager respectively determines, for the registered threads, whether the time differences are greater than corresponding minimum ideal intervals of the registered threads; When the thread manager determines that the corresponding time difference of the first registered thread in the registered thread is greater than the corresponding preset ideal interval, the thread manager determines that the current time satisfies the first registered time. Corresponding preset time condition of the thread; and when the thread manager determines that the corresponding time difference of the first registered thread in the registered thread is less than or equal to the corresponding preset ideal interval time, the execution The administrator determines that the current time does not meet its corresponding preset time condition. 如申請專利範圍第13項所述的電子裝置,其中該執行緒管理者分別記錄該些已註冊執行緒的一理想間隔時間、一最大容許間隔時間與一最小容許間隔時間,其中該 最大容許間隔時間與該最小容許間隔時間的一差值大於等於該處理器的一睡眠模式單位時間。The electronic device of claim 13, wherein the thread manager records an ideal interval time, a maximum allowable interval time, and a minimum allowable interval time of the registered threads, wherein the A difference between the maximum allowable interval time and the minimum allowable interval time is greater than or equal to a sleep mode unit time of the processor. 如申請專利範圍第20項所述的電子裝置,其中:該執行緒管理者取得一第二最新時間以更新該目前時間,將該目前時間減去該基準時間以取得一第一時間差值,其中該基準時間為該處理器最近一次執行該些已註冊執行緒之任何一者的結束時間點;該執行緒管理者對該第一時間差值進行一修整運算,以取得該睡眠模式單位時間乘上一第一乘數的乘積為一第二時間差值;該執行緒管理者將該第二時間差值加上該基準時間以產生一第三時間差值,利用該第三時間差值分別更新在該基準時間到該第二最新時間之間的一或多個新註冊執行緒的註冊時間或該些已註冊執行緒中的一第一已註冊執行緒的最後一次執行時間;該執行緒管理者分別將該些新註冊執行緒的最後一次註冊時間或該第一已註冊執行緒的最後一次執行時間加上對應的最大容許間隔時間,以取得多個估測間隔時間;以及該執行緒管理者取得該些估測間隔時間中的一最小估測時間值為該處理器的下一次醒來的一最早醒來時間點。The electronic device of claim 20, wherein: the thread manager obtains a second latest time to update the current time, subtracting the current time from the current time to obtain a first time difference, The reference time is an end time point of the last execution of the one of the registered threads by the processor; the thread manager performs a trimming operation on the first time difference to obtain the sleep mode unit time Multiplying the product of a first multiplier into a second time difference; the thread manager adds the second time difference to the reference time to generate a third time difference, using the third time difference Updating a registration time of one or more new registration threads between the reference time and the second latest time, or a last execution time of a first registered thread in the registered threads; the execution The administrator separately adds the last registration time of the new registration thread or the last execution time of the first registered thread to the corresponding maximum allowable interval time to obtain Estimating a time interval; and a point in time of the earliest wake manager thread acquired the next time the plurality of estimating a minimum time interval of the estimated value of the primary processor to wake up. 如申請專利範圍第21項所述的電子裝置,其中:該執行緒管理者將該最早醒來時間點減去該目前時間以取得一第四時間差值,並將該間隔時間更新為該第四時 間差值;該執行緒管理者對該第四時間差值進行該修整運算,以取得該睡眠模式單位時間乘上一第二乘數的乘積為一第五時間差值;該執行緒管理者判斷該第二乘數是否為0;當該第二乘數為0時,該執行緒管理者更新該間隔時間為該第四時間差值;以及當該第二乘數不為0時,該執行緒管理者更新該間隔時間為該第五時間差值。The electronic device of claim 21, wherein: the thread manager subtracts the current time from the earliest wake-up time point to obtain a fourth time difference value, and updates the interval time to the first Four o'clock The difference is performed by the thread manager to perform the trimming operation on the fourth time difference to obtain a product of the sleep mode unit time multiplied by a second multiplier to a fifth time difference; the thread manager Determining whether the second multiplier is 0; when the second multiplier is 0, the thread manager updates the interval time to the fourth time difference value; and when the second multiplier is not 0, the The thread manager updates the interval to the fifth time difference.
TW101144571A 2012-11-28 2012-11-28 Method for managing threads and electronic device using the same method TWI462020B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
TW101144571A TWI462020B (en) 2012-11-28 2012-11-28 Method for managing threads and electronic device using the same method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
TW101144571A TWI462020B (en) 2012-11-28 2012-11-28 Method for managing threads and electronic device using the same method

Publications (2)

Publication Number Publication Date
TW201421366A TW201421366A (en) 2014-06-01
TWI462020B true TWI462020B (en) 2014-11-21

Family

ID=51393454

Family Applications (1)

Application Number Title Priority Date Filing Date
TW101144571A TWI462020B (en) 2012-11-28 2012-11-28 Method for managing threads and electronic device using the same method

Country Status (1)

Country Link
TW (1) TWI462020B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115826731B (en) * 2022-10-19 2023-07-11 科东(广州)软件科技有限公司 Sleep control method and device, storage medium and computing equipment

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
TW200411566A (en) * 2002-06-20 2004-07-01 Ibm Apparatus and method of integrating a workload manager with a system task scheduler
TW201001291A (en) * 2008-02-27 2010-01-01 Ibm Method and apparatus for moving threads in a shared processor partitioning environment
US20100122067A1 (en) * 2003-12-18 2010-05-13 Nvidia Corporation Across-thread out-of-order instruction dispatch in a multithreaded microprocessor
TW201214288A (en) * 2010-05-26 2012-04-01 Ibm Optimizing energy consumption and application performance in a multi-core multi-threaded processor system

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
TW200411566A (en) * 2002-06-20 2004-07-01 Ibm Apparatus and method of integrating a workload manager with a system task scheduler
US20100122067A1 (en) * 2003-12-18 2010-05-13 Nvidia Corporation Across-thread out-of-order instruction dispatch in a multithreaded microprocessor
TW201001291A (en) * 2008-02-27 2010-01-01 Ibm Method and apparatus for moving threads in a shared processor partitioning environment
TW201214288A (en) * 2010-05-26 2012-04-01 Ibm Optimizing energy consumption and application performance in a multi-core multi-threaded processor system

Also Published As

Publication number Publication date
TW201421366A (en) 2014-06-01

Similar Documents

Publication Publication Date Title
KR101693565B1 (en) Application heartbeat period adjusting method and apparatus, and terminal
US9104423B2 (en) Method and system for advance wakeup from low-power sleep states
TWI656439B (en) Application program wake-up method and device
CN112530056B (en) Method for reducing power consumption of smart door lock, smart door lock and storage medium
US10386914B2 (en) Method and apparatus for running application program
KR102164099B1 (en) System on chip, method thereof, and device including the same
US8892923B2 (en) Data processing apparatus and method for maintaining a time count value in normal and power saving modes of operation
WO2005106623A1 (en) Cpu clock control device, cpu clock control method, cpu clock control program, recording medium, and transmission medium
US10275007B2 (en) Performance management for a multiple-CPU platform
EP2972660B1 (en) Controlling power supply unit power consumption during idle state
US10003617B2 (en) Terminal and application synchronization method thereof
CN110286739B (en) Power consumption control method and device of remote telemetry terminal
CN114174956B (en) Preemptive wake-up circuitry for waking up from low-power modes
TWI462020B (en) Method for managing threads and electronic device using the same method
WO2018063565A1 (en) Technologies for low-power and high-accuracy timestamps
US9417679B2 (en) Adaptive connected standby for a computing device
US9465655B2 (en) Method for managing threads using executing time scheduling technique and electronic device using the same method
CN103853605B (en) Thread management method and electronic device thereof
US10726702B2 (en) Information processing system, information processing method, and program
CN117290068A (en) Task scheduling method, device, electronic equipment and storage medium
Mishra et al. A Monte Carlo algorithm for real time task scheduling on multi-core processors with software controlled dynamic voltage scaling
KR102453689B1 (en) Periodical process performing system and system on chip
CN102221875B (en) Microprocessor, method of operating a microprocessor
CN111863197A (en) A sleep management method and device
CN110750150A (en) Automatic energy-saving method, system and terminal for TBOX