JPH0594313A - Timer control system - Google Patents

Timer control system

Info

Publication number
JPH0594313A
JPH0594313A JP27889291A JP27889291A JPH0594313A JP H0594313 A JPH0594313 A JP H0594313A JP 27889291 A JP27889291 A JP 27889291A JP 27889291 A JP27889291 A JP 27889291A JP H0594313 A JPH0594313 A JP H0594313A
Authority
JP
Japan
Prior art keywords
time
timer
task
timer interrupt
sleep
Prior art date
Legal status (The legal status 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 status listed.)
Pending
Application number
JP27889291A
Other languages
Japanese (ja)
Inventor
Keisuke Ichieda
圭祐 一枝
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Mitsubishi Electric Corp
Original Assignee
Mitsubishi Electric 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 Mitsubishi Electric Corp filed Critical Mitsubishi Electric Corp
Priority to JP27889291A priority Critical patent/JPH0594313A/en
Publication of JPH0594313A publication Critical patent/JPH0594313A/en
Pending legal-status Critical Current

Links

Abstract

PURPOSE:To decrease the overhead of the timer interrupt processing in a multi- task operating system. CONSTITUTION:When it is requested that a certain task enters the sleeve condition, the time (sleeve designating time) up to the wake-up and the time the time-up of a timer during the present action are compared ST14, and when the sleeve designating time is shorter, the time is set ST16 to the timer as the time up to the time-up, that is, the time up to the timer interruption occurrence.

Description

【発明の詳細な説明】Detailed Description of the Invention

【0001】[0001]

【産業上の利用分野】この発明は、マルチタスクオペレ
ーティングシステムにおけるタイマ管理方式に関するも
のである。
BACKGROUND OF THE INVENTION 1. Field of the Invention The present invention relates to a timer management system in a multitasking operating system.

【0002】[0002]

【従来の技術】図5は従来のマルチタスクオペレーティ
ングシステム(マルチタスクOS)におけるタイマ割込
処理を示すフローチャートである。一般に、マルチタス
クOSは、時間管理のため、比較的短い間隔(例えば1
0ms、以下、この間隔をTCという。)のタイマ割込
を必要とする。また、マルチタスクOSは、各タスク
に、ウェイクアップ時刻を指定したスリープ(ウェイト
状態)や時間監視のための時間指定を許している。
2. Description of the Related Art FIG. 5 is a flowchart showing a timer interrupt process in a conventional multitask operating system (multitask OS). Generally, a multi-task OS uses a relatively short interval (for example, 1
0 ms, and this interval is hereinafter referred to as T C. ) Timer interrupt is required. Further, the multitask OS allows each task to specify a sleep (wait state) in which a wakeup time is specified and a time specification for time monitoring.

【0003】あるタスクが時間指定のスリープを行うと
きには、タイマ割込間隔の整数倍の時間TW (TW =T
C ×n;nは正の整数)を指定する。その後、OSのタ
イマ割込処理ルーチンは、タイマ割込が発生するたび
に、各タスクのスリープ指定時間値からTC を減算する
(ステップST31)。そして、スリープ指定時間値0
になったものがあれば、それに対応するタスクをウェイ
クアップする。すなわち、そのウェイト状態にあったタ
スクを実行可能タスクキューに接続する(ステップST
32)。
When a certain task sleeps for a specified time, a time T W (T W = T W) that is an integer multiple of the timer interrupt interval.
C × n; n is a positive integer. Thereafter, the timer interrupt processing routine of the OS subtracts T C from the sleep designated time value of each task each time a timer interrupt occurs (step ST31). Then, the sleep designated time value 0
If there is one, wake up the corresponding task. That is, the task in the wait state is connected to the executable task queue (step ST
32).

【0004】以上のような処理は、時間指定のスリープ
を行っているタスクの数が少ないときには問題はない
が、タスク数が増えるに従って、無視できないオーバヘ
ッドとなる。
The above-mentioned processing is not a problem when the number of tasks performing the sleep for a designated time is small, but becomes an overhead that cannot be ignored as the number of tasks increases.

【0005】図6はそのようなオーバヘッドを軽減する
ことを目的とした特開昭64−21635号公報に示さ
れたタイマ管理方式を示すブロック図である。図におい
て、1はタイマ管理用のサブCPU、2はサブCPU1
のROM、3はサブCPU1のRAM、4はタイマ割込
を発生するタイマ、5はサブCPU1のバスである。
FIG. 6 is a block diagram showing a timer management system disclosed in Japanese Patent Laid-Open No. 64-21635 for the purpose of reducing such overhead. In the figure, 1 is a sub CPU for timer management, 2 is a sub CPU 1
ROM, 3 is RAM of the sub CPU 1, 4 is a timer for generating a timer interrupt, and 5 is a bus of the sub CPU 1.

【0006】また、6はサブCPU1と主CPU7との
間のデータ交換のためのデュアルポートRAM、7はシ
ステムにおける主CPU、8は主CPU7のROM、9
は主CPUの7のRAM、10は主CPU7のバスであ
る。
Further, 6 is a dual port RAM for exchanging data between the sub CPU 1 and the main CPU 7, 7 is the main CPU in the system, 8 is the ROM of the main CPU 7, and 9
Is a RAM of the main CPU 7 and 10 is a bus of the main CPU 7.

【0007】図6に示されたものにあっては、サブCP
U1がタイマに関連した情報をデュアルポートRAM6
を介して主CPU7から入手する。そして、サブCPU
1が、タイマ4からのタイマ割込を用いてタイマ管理を
行う。サブCPU1は、ウェイクアップ時刻の到来など
を検出したときにのみ、デュアルポートRAM6経由で
主CPU7に割込をかける。
In the case shown in FIG. 6, the sub CP
U1 sends information related to timer to dual port RAM6
It is obtained from the main CPU 7 via. And the sub CPU
1 performs timer management using the timer interrupt from timer 4. The sub CPU 1 interrupts the main CPU 7 via the dual port RAM 6 only when the arrival of the wakeup time is detected.

【0008】[0008]

【発明が解決しようとする課題】従来のタイマ管理方式
は以上のように構成されているので、図5に示すような
方式にあっては、オーバヘッドによってシステムの性能
が低下してしまうという問題点があった。また、図6に
示すような方式にあっては、タイマ管理専用のサブCP
U1およびデュアルポートRAM6などを設けなければ
ならず、コスト高になるとともに余分な実装面積を用意
しなければならないなどの問題点があった。
Since the conventional timer management system is constructed as described above, there is a problem that the system performance is deteriorated by the overhead in the system shown in FIG. was there. Further, in the system shown in FIG. 6, a sub CP dedicated to timer management is used.
Since the U1 and the dual port RAM 6 and the like must be provided, the cost becomes high and an extra mounting area must be prepared.

【0009】この発明は上記のような問題点を解消する
ためになされたもので、システムのオーバヘッドを軽減
し、かつ、余分なハードウェアを必要としないタイマ管
理方式を得ることを目的とする。
The present invention has been made to solve the above problems, and an object of the present invention is to reduce the system overhead and to obtain a timer management system which does not require extra hardware.

【0010】[0010]

【課題を解決するための手段】この発明に係るタイマ管
理方式は、各タスクが指定した時間のうちで残時間が最
短のものを検索し、その最短の時間を、タイマのタイム
アップ時間、すなわちタイマがタイマ割込を発生するま
での時間として、タイマに設定するようにしたものであ
る。
The timer management system according to the present invention searches for the shortest remaining time among the times designated by each task, and sets the shortest time to the time-up time of the timer, that is, The timer is set as the time until the timer generates a timer interrupt.

【0011】[0011]

【作用】この発明におけるタイマの設定は、あるタスク
が時間指定を行ったとき、およびタイマがタイムアップ
したときに、指定時間の残時間が最短のものに対応した
値を用いてなされる。
According to the present invention, the timer is set by using the value corresponding to the shortest remaining time of the designated time when a certain task designates the time and when the timer times out.

【0012】[0012]

【実施例】【Example】

実施例1.以下、この発明の一実施例を図について説明
する。図1はこの発明の一実施例によるタイマ管理方式
が適用されるシステムを示すブロック図である。図にお
いて、各ブロックは同一符号を付して図6に示したもの
と同一のものであるが、ROM8に設定されているプロ
グラムは、図6に示したROM8に設定されているもの
とは異なっている。
Example 1. An embodiment of the present invention will be described below with reference to the drawings. FIG. 1 is a block diagram showing a system to which a timer management system according to an embodiment of the present invention is applied. In the figure, each block is the same as that shown in FIG. 6 with the same reference numeral, but the program set in the ROM 8 is different from that set in the ROM 8 shown in FIG. ing.

【0013】次に動作について説明する。まず、あるタ
スクが指定時間とともにスリープ依頼を発行した場合の
動作について図2のフローチャートおよび図3のタイミ
ング図を参照して説明する。例えば、時刻aにおいて、
タイマ4に対してタイムアップ時間としてt2 が設定さ
れているとする。そして、時間t1 が経過したときに
(時刻bにおいて)、あるタスクがスリープ依頼のシス
テムコールを発行したとする。また、そのとき指定時間
はt3 であったとする。
Next, the operation will be described. First, the operation when a task issues a sleep request with a designated time will be described with reference to the flowchart of FIG. 2 and the timing chart of FIG. For example, at time a,
It is assumed that t 2 is set as the time-up time for the timer 4. Then, it is assumed that a task issues a sleep request system call when the time t 1 has elapsed (at time b). Further, at that time, the designated time is assumed to be t 3 .

【0014】すると、OSは、タイマ4を停止し(ステ
ップST11)、前回のタイマスタート(時刻a)から
の経過時間t1 を求める(ステップST12)。また、
システムコールを発行したタスクの指定時間t3 に時間
1 を加算し、t1 +t3 を新たな指定時間としてその
タスクのタスクコントロールブロック(TCB)に書き
込む。そして、そのタスクをスリープタスクキューに接
続し、そのタスクをスリープ状態とする(ステップST
13)。
Then, the OS stops the timer 4 (step ST11) and obtains the elapsed time t 1 from the previous timer start (time a) (step ST12). Also,
The time t 1 is added to the specified time t 3 of the task that issued the system call, and t 1 + t 3 is written as a new specified time in the task control block (TCB) of the task. Then, the task is connected to the sleep task queue and the task is put into the sleep state (step ST
13).

【0015】次に、OSは、時間t3 と時間t2 −t1
とを比較する。すなわち、今回システムコールを発生し
たタスクの指定時間t3 と前回設定したタイムアップ時
間t2 のタイムアップ時刻までの残り時間との長短を検
査する(ステップST14)。
Next, the OS determines the time t 3 and the time t 2 −t 1.
Compare with. That is, to inspect the length of the remaining time until a specified time t 3 and time up time of the time-up time t 2 previously set for this task the system call has occurred (step ST14).

【0016】前回設定したタイムアップ時間の残り時間
の方が短ければ、あるいは両者が等しければそのまま処
理を終了する(図3(B)に対応)。一方、指定時間t
3 の方が短ければ、OS内部のワークエリア「タイマ割
込時間」の値をt1 +t3 としておく(ステップST1
5)。そして、タイマ4のタイムアップ時間をt3 に設
定してタイマ4をスタートさせる(ステップST16、
図3(A)に対応)。
If the remaining time of the time-up time set last time is shorter, or if both are the same, the processing is terminated as it is (corresponding to FIG. 3B). On the other hand, the designated time t
If 3 is shorter, the value of the work area "timer interrupt time" in the OS is set to t 1 + t 3 (step ST1
5). Then, the time-up time of the timer 4 is set to t 3 and the timer 4 is started (step ST16,
(Corresponding to FIG. 3 (A)).

【0017】その後、タイマ4がタイムアップすると
(図3(A)における時刻cあるいは図3(B)におけ
る時刻d)、タイマ割込が発生する。すると、タイマ割
込処理ルーチンは、スリープ状態にある各タスクのTC
B内の指定時間を、「タイマ割込時間」に設定されてい
る値分だけ減算する(図4のステップST21)。
After that, when the timer 4 times out (time c in FIG. 3A or time d in FIG. 3B), a timer interrupt occurs. Then, the timer interrupt processing routine executes the TC of each task in the sleep state.
The designated time in B is subtracted by the value set in the "timer interrupt time" (step ST21 in FIG. 4).

【0018】そして、減算によって指定時間の値が0と
なったものに対応するタスクをスリープタスクキューか
ら取り出し、実行可能タスクキューに接続する(ステッ
プST22)。図3(A)に示した例では、時刻bにお
いてスリープ状態となったタスクが実行可能状態とな
り、図3(B)に示した例では、例えば時刻aにスリー
ブ状態となったタスクが実行可能状態となる。
Then, the task corresponding to the one whose designated time value becomes 0 by subtraction is taken out from the sleep task queue and connected to the executable task queue (step ST22). In the example shown in FIG. 3A, the task in the sleep state at time b is in the executable state, and in the example shown in FIG. 3B, for example, the task in the sleeve state at time a is executable. It becomes a state.

【0019】さらに、タイマ割込処理ルーチンは、スリ
ープタスクキューに接続されている各タスクのTCBに
ある指定時間のうち最短のものを検索する(ステップS
T23)。そして、その最短の値t4 を「タイマ割込時
間」に設定し(ステップST24)、かつ、タイマ4
に、タイムアップ時間としてt4 を設定し、タイマ4を
スタートさせる(ステップST25)。
Further, the timer interrupt processing routine searches for the shortest specified time in the TCB of each task connected to the sleep task queue (step S).
T23). Then, the shortest value t 4 is set as the “timer interrupt time” (step ST24), and the timer 4
Then, t 4 is set as the time-up time, and the timer 4 is started (step ST25).

【0020】なお、上記実施例では、スリープ依頼に伴
う指定時間を例にして説明したが、タスク間通信におけ
る時間監視など、各タスクが必要とする各種の時間につ
いて本方式は適用可能である。
In the above embodiment, the designated time associated with the sleep request has been described as an example, but the present method is applicable to various times required by each task such as time monitoring in communication between tasks.

【0021】また、上記実施例では、タイマ4の設定値
を変更する場合について説明したが、タイマ4が一定周
期で割込を発生するようにして、その割込回数をタイマ
割込処理ルーチンがカウントし、各タスクが指定した時
間のうち最短のものとカウント値とが一致したら図4に
示した処理を行うようにしてよい。なお、その場合に
は、タイマ4に対する処理は不要である。
Further, in the above embodiment, the case where the set value of the timer 4 is changed has been described. It is possible to count and perform the process shown in FIG. 4 when the shortest one of the times designated by each task matches the count value. In that case, the processing for the timer 4 is unnecessary.

【0022】[0022]

【発明の効果】以上のように、この発明によれば、タイ
マ管理方式を、各タスクの指定時間のうち残り時間が最
も短いものを検索し、その時間を、タイマ割込を発生さ
せるまでの時間としてタイマに設定するようにしたの
で、ハードウェア追加なしに、すなわちコスト高となら
ずにシステムのオーバヘッドを軽減させる方式が得られ
る効果がある。
As described above, according to the present invention, the timer management system searches for the shortest remaining time out of the designated time of each task, and determines the time until the timer interrupt is generated. Since the timer is set as the time, there is an effect that the system overhead can be reduced without adding hardware, that is, without increasing the cost.

【図面の簡単な説明】[Brief description of drawings]

【図1】この発明の一実施例によるタイマ管理方式が適
用されるシステムの一例を示すブロック図である。
FIG. 1 is a block diagram showing an example of a system to which a timer management system according to an embodiment of the present invention is applied.

【図2】スリープ依頼システムコール発行時のOSの処
理を示すフローチャートである。
FIG. 2 is a flowchart showing processing of the OS when issuing a sleep request system call.

【図3】タイマスタートおよびタイムアップの一例を示
すタイミング図である。
FIG. 3 is a timing chart showing an example of timer start and time up.

【図4】タイマ割込処理を示すフローチャートである。FIG. 4 is a flowchart showing a timer interrupt process.

【図5】従来のタイマ割込処理を示すフローチャートで
ある。
FIG. 5 is a flowchart showing a conventional timer interrupt process.

【図6】従来のタイマ管理方式が適用されるシステムを
示すブロック図である。
FIG. 6 is a block diagram showing a system to which a conventional timer management system is applied.

【符号の説明】[Explanation of symbols]

4 タイマ 4 timer

Claims (1)

【特許請求の範囲】[Claims] 【請求項1】 マルチタスクオペレーティングシステム
下の各タスクが必要とする時間を、タイマのタイムアッ
プによるタイマ割込を用いて管理するタイマ管理方式に
おいて、前記各タスクが指定した時間のうち残り時間が
最も短いものを検索し、その検索の結果得られた時間を
タイムアップまでの時間として前記タイマに設定するこ
とを特徴とするタイマ管理方式。
1. In a timer management system for managing a time required by each task under a multitasking operating system by using a timer interrupt due to a time-up of a timer, the remaining time out of the time designated by each task A timer management method characterized in that the shortest one is searched and the time obtained as a result of the search is set in the timer as the time until the time is up.
JP27889291A 1991-10-01 1991-10-01 Timer control system Pending JPH0594313A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP27889291A JPH0594313A (en) 1991-10-01 1991-10-01 Timer control system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP27889291A JPH0594313A (en) 1991-10-01 1991-10-01 Timer control system

Publications (1)

Publication Number Publication Date
JPH0594313A true JPH0594313A (en) 1993-04-16

Family

ID=17603559

Family Applications (1)

Application Number Title Priority Date Filing Date
JP27889291A Pending JPH0594313A (en) 1991-10-01 1991-10-01 Timer control system

Country Status (1)

Country Link
JP (1) JPH0594313A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7386853B2 (en) 2001-07-12 2008-06-10 Denso Corporation Multitasking operating system capable of reducing power consumption and vehicle electronic control unit using same
JP2016095655A (en) * 2014-11-13 2016-05-26 富士通株式会社 Timer control program, timer control method, and information processing device

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH01259430A (en) * 1988-04-11 1989-10-17 Oki Electric Ind Co Ltd Subtracting method for interval timer value

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH01259430A (en) * 1988-04-11 1989-10-17 Oki Electric Ind Co Ltd Subtracting method for interval timer value

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7386853B2 (en) 2001-07-12 2008-06-10 Denso Corporation Multitasking operating system capable of reducing power consumption and vehicle electronic control unit using same
JP2016095655A (en) * 2014-11-13 2016-05-26 富士通株式会社 Timer control program, timer control method, and information processing device

Similar Documents

Publication Publication Date Title
JPH0454255B2 (en)
JP2005539322A (en) Method and apparatus for managing threads in a data processing system
JPH02300939A (en) Semaphore operation system
JPH0594313A (en) Timer control system
JP2654612B2 (en) Exclusive weight reduction control method
JPH07191863A (en) Multitask execution managing system
JP3005562B1 (en) Task management device and task scheduling method
JP2597283B2 (en) Scheduling method for interrupt
JPS6368934A (en) Task scheduing system
JPH0877039A (en) Test method
JPH05134960A (en) Local processing system
JPH03244040A (en) Parallel run type debug system
JPH0451329A (en) Context switching device
JP2003044292A (en) Multiplex parallel processor, multiplex parallel processing method and multiplex parallel processing program executed by computer
JPS59146387A (en) Stack control system of multiprocessing
JPH03168818A (en) Clock control system for computer
JPH0659915A (en) Method and device for controlling execution order of transaction
JPH0778091A (en) Multitask managing method
JPH02211545A (en) Job execution control system
JPH01251142A (en) Program trace system
JPH0797322B2 (en) Dispatch control method
JPH04352237A (en) Automatic control system for job execution
JPS63163640A (en) Scheduling system
KR950020229A (en) Multiprocessor Data Control Method
JPH04162140A (en) Changing system for os interruption level