JPH03292545A - Detection/recovery device for program loop - Google Patents

Detection/recovery device for program loop

Info

Publication number
JPH03292545A
JPH03292545A JP2095659A JP9565990A JPH03292545A JP H03292545 A JPH03292545 A JP H03292545A JP 2095659 A JP2095659 A JP 2095659A JP 9565990 A JP9565990 A JP 9565990A JP H03292545 A JPH03292545 A JP H03292545A
Authority
JP
Japan
Prior art keywords
loop
counter
program
program counter
contents
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
JP2095659A
Other languages
Japanese (ja)
Inventor
Toshikazu Miyazaki
宮崎 壽和
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 JP2095659A priority Critical patent/JPH03292545A/en
Publication of JPH03292545A publication Critical patent/JPH03292545A/en
Pending legal-status Critical Current

Links

Abstract

PURPOSE:To detect a program infinite loop by saving a program counter at each fixed time, comparing the current value with the old value, and deciding a loop when the coincident state of the comparison continues with exclusion of lower rant m bits. CONSTITUTION:An old program counter 6 is compared with a current program counter 5 at each fixed time interval, and the coincidence of addresses is checked with exclusion of specific lower rant m bits. When the coincidence of addresses is confirmed, a loop counter 8 is counted up. Then a program loop detection signal is outputted when the counter 8 reaches the specific value. Based on this detection signal, the contents of a restart address register 10 are transferred to the counter 5 and the recovery processing is started. Thus a program infinite loop can be detected.

Description

【発明の詳細な説明】 〔産業上の利用分野〕 この発明は、コンピュータプログラムの無限ループを検
知し自動回復させるためのプログラムループの検知回復
装置に関するものである。
DETAILED DESCRIPTION OF THE INVENTION [Field of Industrial Application] The present invention relates to a program loop detection and recovery device for detecting and automatically recovering an infinite loop in a computer program.

〔従来の技術〕[Conventional technology]

第3図はコンピュータの逐次制御部を示す図であり、図
において、(1)はメインメモリ、(2)はメインメモ
リ(1)から読み出された命令を入れておく命令レジス
タ、(3)は命令のデコーダ、(4)はメインメモリ(
1)をアクセスするメモリアドレスレジスタ、(5)は
実行する命令のアドレスを保持するカレントプログラム
カウンタである。
FIG. 3 is a diagram showing the sequential control unit of a computer. In the figure, (1) is the main memory, (2) is an instruction register that stores instructions read from the main memory (1), and (3) is a diagram showing the sequential control unit of the computer. is the instruction decoder, and (4) is the main memory (
1) is a memory address register that is accessed, and (5) is a current program counter that holds the address of the instruction to be executed.

次に、動作について説明する。メインメモリ(1)から
読み出された命令は、−旦命令レジスタ(2)に入れら
れる。命令レジスタ(2)の命令コードは、命令デコー
ダ(3)により解読され、実行される。分岐命令の時は
、命令レジスタ(2)の例えは下位3バイトが飛び先ア
ドレスとして、カレントプログラムカウンタ(5)に入
れられる。その他の命令の時は、カレントプログラムカ
ウンタ(5)は、次の命令アドレスをポイントするため
に増加される。このカレントプログラムカウンタ(5)
の内容がメモリアドレスレジスタ(4)へ渡り、次の命
令の取り出しに使用される。
Next, the operation will be explained. The instructions read from the main memory (1) are placed in the instruction register (2). The instruction code in the instruction register (2) is decoded and executed by the instruction decoder (3). In the case of a branch instruction, the lower three bytes of the instruction register (2) are entered into the current program counter (5) as a jump address. For other instructions, the current program counter (5) is incremented to point to the next instruction address. This current program counter (5)
The contents of are passed to the memory address register (4) and used for fetching the next instruction.

〔発明が解決しようとする課題〕[Problem to be solved by the invention]

従来の逐次制御方式の動作は、以上のようになされるの
で、プログラムの無限ループに陥った場合にそれが検知
できず、いたずらにCPUの時間を浪費してしまったり
、システムダウンとなってしまうという問題点があった
Conventional sequential control methods operate as described above, so if a program falls into an infinite loop, it cannot be detected and the CPU time is wasted or the system goes down. There was a problem.

また、特開平1−140350号公報には、プログラム
実行中に、プログラムカウンタの状態を監視し、プログ
ラムの暴走を検知する技術が開示されているが、ウォッ
チドッグタイマの改良に基づくもので、プログラムが実
行先のアドレスを予測して比較値を設定していくことは
困難で、プログラムの負担無く実現することはできない
Furthermore, Japanese Patent Application Laid-Open No. 1-140350 discloses a technique for detecting program runaway by monitoring the state of a program counter during program execution. It is difficult to predict the execution destination address and set the comparison value, and it cannot be achieved without putting a burden on the program.

この発明は、上記のような点を鑑みてなされたもので、
プログラムの負担がなく、プログラムの無限ループを検
知できると共に、システムの回復を自動的に行い得るよ
うにする逐次制御方式のコンピュータに係るプログラム
ループの検知回復装置を得ることを目的とする。
This invention was made in view of the above points,
It is an object of the present invention to provide a program loop detection and recovery device for a sequential control computer, which can detect infinite program loops without putting a burden on the program, and can automatically recover the system.

(課題を解決するための手段) この発明に係るプログラムループの検知回復装置は、実
行する命令のアドレスを保持するカレントプログラムカ
ウンタの内容を、一定時間間隔毎にセーブするオールド
プログラムカウンタを備える共に、一定時間間隔毎に上
記カレントプログラムカウンタと上記オールドプログラ
ムカウンタの内容を特定の下位mビットを除いて比較す
る比較検知手段と、上記比較検知手段からの一致信号を
カウントするカウントループと、上記ループカウンタの
値が特定の値に達したことを示すループ検出信号により
、上記カレントプログラムカウンタへ保持内容をロード
するようリスタートアドレスレジスタとを備えたもので
ある。
(Means for Solving the Problems) A program loop detection and recovery device according to the present invention includes an old program counter that saves the contents of a current program counter that holds the address of an instruction to be executed at regular time intervals; a comparison detection means for comparing the contents of the current program counter and the old program counter excluding specific lower m bits at regular time intervals; a count loop for counting coincidence signals from the comparison detection means; and a count loop for counting coincidence signals from the comparison detection means; A restart address register is provided so that the held contents are loaded into the current program counter in response to a loop detection signal indicating that the value of has reached a specific value.

〔作用) この発明において、オールドプログラムカウンタは、一
定時間間隔毎に、カレントプログラムカウンタとして比
較され、特定の下位mビットを除いてアドレスの一致が
検査される。一致した場合は、ループカウンタをカウン
トアツプし、ループカウンタが特定の値に達した時に、
プログラムループ検知信号を出し、この信号により、リ
スタートアドレスレジスタの内容をカレントプログラム
カウンタへ移して、回復処理を起動する。
[Operation] In the present invention, the old program counter is compared with the current program counter at regular time intervals, and address matching is checked except for specific lower m bits. If they match, count up the loop counter, and when the loop counter reaches a certain value,
A program loop detection signal is issued, and this signal causes the contents of the restart address register to be transferred to the current program counter to start the recovery process.

(実施例〕 以下、この発明の一実施例を図について説明する。第1
図において、(1)はメインメモリ、(2)はメインメ
モリ(1)から読み出された命令を入れておく命令レジ
スタ、(3)は命令デコーダ、(4)はメインメモリ(
1)をアクセスするメモリアドレスレジスタ、(5)は
実行する命令のアドレスを保持するカレントプログラム
カウンタ、(6)はカレントプログラムカウンタの内容
を一定時間間隔毎にセーブするオールドプログラムカウ
ンタ、(ア)はカレントプログラムカウンタとオールド
プログラムカウンタを特定の下位mビットを除いて比較
し、カレント値とオールド値が一致した時は一致信号を
送出する比較検知手段、(8)は比較検知手段(7)か
らの一致信号をカウントするループカウンタ、(9)は
ループカウンタ(8)からのループ検出信号、(10)
は回復用のりスタートアドレスレジスタである。
(Example) Hereinafter, an example of the present invention will be explained with reference to the drawings.
In the figure, (1) is the main memory, (2) is an instruction register that stores instructions read from the main memory (1), (3) is an instruction decoder, and (4) is the main memory (
1) is a memory address register that is accessed; (5) is a current program counter that holds the address of the instruction to be executed; (6) is an old program counter that saves the contents of the current program counter at fixed time intervals; (a) is Comparing and detecting means (8) compares the current program counter and the old program counter excluding specific lower m bits, and sends out a match signal when the current value and the old value match; A loop counter that counts coincidence signals, (9) is a loop detection signal from the loop counter (8), (10)
is the recovery start address register.

次に、実施例の動作について第2図のフローチャートに
従って説明する。一定の時間間隔毎に、カレントプログ
ラムカウンタ(5)の内容はオールドプログラムカウン
タ(6)の内容と比較検知手段(7)により特定の下位
mビットを除いて比較される(ステップ521.S22
 )。アドレスが一致しない場合は、ループカウンタ(
8)はOクリアされ、オールドプログラムカウンタ(6
)の内容はカレントプログラムカウンタ(5)の内容に
より更新される(ステップ523〜525)。
Next, the operation of the embodiment will be explained according to the flowchart shown in FIG. At regular time intervals, the contents of the current program counter (5) are compared with the contents of the old program counter (6) by the comparison detection means (7), excluding specific lower m bits (steps 521 and S22).
). If the addresses do not match, the loop counter (
8) is cleared to O, and the old program counter (6) is cleared.
) is updated by the contents of the current program counter (5) (steps 523-525).

他方、アドレスが一致した場合は、ループカウンタ(8
)がインクリメントされる。プログラムの無限ループが
発生した場合は、ループのアドレスは通常メモリ空間の
狭いエリアに限定され、プログラムアドレスの下位mビ
ットは変動するが、上位の残りのビットは不変である。
On the other hand, if the addresses match, the loop counter (8
) is incremented. When an infinite program loop occurs, the address of the loop is usually limited to a small area of memory space, and the lower m bits of the program address change, but the remaining upper bits remain unchanged.

従って、アドレスの一致が連続して検出され、ループカ
ウンタ(8)は連続的にカウントが増加していく。そし
である特定の値に達した時(例えばカウンタのあふれ)
に、ループカウンタ(8)はループ検出信号(9)を出
力する(ステップs23゜S26〜528)。このルー
プ検出信号(9)は、リスタートアドレスレジスタ(工
0)の内容をカレントプログラムカウンタ(5)へ転送
することにより、リスタート回復処理を起動する。
Therefore, matching of addresses is detected continuously, and the count of the loop counter (8) increases continuously. and when a certain value is reached (e.g. counter overflow)
Then, the loop counter (8) outputs a loop detection signal (9) (steps s23° S26-528). This loop detection signal (9) activates the restart recovery process by transferring the contents of the restart address register (step 0) to the current program counter (5).

なお、上記実施例では、アドレスの比較検知手段(7)
と、ループカウンタ(8)をハードウェアで構成したも
のを示したが、マイクロプログラム制御にて同等の制御
を行なっても良い。
In the above embodiment, the address comparison detection means (7)
Although the loop counter (8) is shown as being constructed using hardware, equivalent control may be performed using microprogram control.

また、上記実施例ではオールドプログラムカウンタ(6
)に、プログラムアドレスのみセーブする例を示したが
、多重仮想記憶システムのコンピュータの場合は、アド
レス空間識別子をも含めて、第2図のフローチャートの
処理をタイマー割込毎にオペレーティングシステムにて
行なえば、アドレス空間の毎のユーザプログラムのルー
プを検知することができる。
In addition, in the above embodiment, the old program counter (6
) shows an example of saving only the program address, but in the case of a computer with a multiple virtual memory system, the operating system should perform the processing in the flowchart in Figure 2, including the address space identifier, for each timer interrupt. For example, loops in the user program for each address space can be detected.

また、上記実施例では、回復用のりスタートアドレスレ
ジスタ(10)を設けたが、マイクロコンピュータシス
テムの場合は、車にO番地からのりスタートであっても
良い。
Further, in the above embodiment, a recovery start address register (10) is provided, but in the case of a microcomputer system, the start address register (10) may be used to start the car from address O.

また、上記実施例では、コンピュータの中央処理装置の
逐次制御部の場合について説明したが、入出力制御装置
やチャネル制御装置のマイクロプログラム制御部であっ
ても良く、上記実施例と同様の効果を奏する。
Further, in the above embodiment, the case of a sequential control unit of a central processing unit of a computer was explained, but it may also be a microprogram control unit of an input/output control device or a channel control device, and the same effects as in the above embodiment can be obtained. play.

〔発明の効果〕〔Effect of the invention〕

以上のように、この発明によれば、プログラムカウンタ
を一定時間毎にセーブし、カレント値とオールド値を比
較し、下位mビットを除いて一致した状態が継続した場
合をループと判定するようにしたので、プログラムの無
限ループを検知することができ、かつ、そのループを断
ち切って回復処理を行なうことができるので、むだなC
Pu時間の消費を防ぐことができ、また、システムダウ
ンやコンピュータ機器の自動回復を行なうことができる
As described above, according to the present invention, the program counter is saved at regular intervals, the current value and the old value are compared, and if they continue to match except for the lower m bits, a loop is determined. As a result, it is possible to detect an infinite loop in a program, and also to break the loop and perform recovery processing.
Consumption of Pu time can be prevented, and system down and computer equipment can be automatically recovered.

【図面の簡単な説明】[Brief explanation of the drawing]

第1図はこの発明の一実施例によるコンピュータの逐次
制御部を示す構成図、第2図はこの発明のプログラムル
ープ検知の方式を示すフローチャート、第3図は従来の
コンピュータの逐次制御部を示す構成図である。 (5)はカレントプログラムカウンタ、(6)はオール
ドプログラムカウンタ、(7)は比較検知手段、(8)
はループカウンタ、(9)はループ検圧信号、  (1
0)はりスタートアドレスレジスタ。 尚、図、中間−符号は同−又は相当部分を示す。
FIG. 1 is a block diagram showing a sequential control section of a computer according to an embodiment of the present invention, FIG. 2 is a flowchart showing a program loop detection method of the present invention, and FIG. 3 is a diagram showing a sequential control section of a conventional computer. FIG. (5) is the current program counter, (6) is the old program counter, (7) is the comparison detection means, (8)
is the loop counter, (9) is the loop pressure detection signal, (1
0) Beam start address register. In the figures, middle symbols indicate the same or equivalent parts.

Claims (1)

【特許請求の範囲】[Claims] 実行する命令のアドレスを保持するカレントプログラム
カウンタの内容を、一定時間間隔毎にセーブするオール
ドプログラムカウンタを備える共に、一定時間間隔毎に
上記カレントプログラムカウンタと上記オールドプログ
ラムカウンタの内容を特定の下位mビットを除いて比較
する比較検知手段と、上記比較検知手段からの一致信号
をカウントするカウントループと、上記ループカウンタ
の値が特定の値に達したことを示すループ検出信号によ
り、上記カレントプログラムカウンタへ保持内容をロー
ドするようリスタートアドレスレジスタとを備えたこと
を特徴とするプログラムループの検知回復装置。
It includes an old program counter that saves the contents of the current program counter that holds the address of the instruction to be executed at regular time intervals, and also saves the contents of the current program counter and the old program counter at regular time intervals to a specific lower order m. The current program counter is controlled by a comparison detection means for comparing bits excluding bits, a count loop for counting coincidence signals from the comparison detection means, and a loop detection signal indicating that the value of the loop counter has reached a specific value. A program loop detection and recovery device comprising: a restart address register for loading retained contents into a program loop detection/recovery device.
JP2095659A 1990-04-11 1990-04-11 Detection/recovery device for program loop Pending JPH03292545A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2095659A JPH03292545A (en) 1990-04-11 1990-04-11 Detection/recovery device for program loop

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2095659A JPH03292545A (en) 1990-04-11 1990-04-11 Detection/recovery device for program loop

Publications (1)

Publication Number Publication Date
JPH03292545A true JPH03292545A (en) 1991-12-24

Family

ID=14143620

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2095659A Pending JPH03292545A (en) 1990-04-11 1990-04-11 Detection/recovery device for program loop

Country Status (1)

Country Link
JP (1) JPH03292545A (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7281171B2 (en) * 2003-01-14 2007-10-09 Hewlwtt-Packard Development Company, L.P. System and method of checking a computer system for proper operation
JP2007272581A (en) * 2006-03-31 2007-10-18 Fujitsu Ltd Monitoring program, method and device
JP2012137877A (en) * 2010-12-24 2012-07-19 Toshiba Corp Secondary battery device, processor, monitoring program and vehicle
US10552155B2 (en) * 2016-06-20 2020-02-04 Imagination Technologies Limited Livelock recovery circuit configured to detect illegal repetition of an instruction and transition to a known state

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7281171B2 (en) * 2003-01-14 2007-10-09 Hewlwtt-Packard Development Company, L.P. System and method of checking a computer system for proper operation
JP2007272581A (en) * 2006-03-31 2007-10-18 Fujitsu Ltd Monitoring program, method and device
JP2012137877A (en) * 2010-12-24 2012-07-19 Toshiba Corp Secondary battery device, processor, monitoring program and vehicle
US10552155B2 (en) * 2016-06-20 2020-02-04 Imagination Technologies Limited Livelock recovery circuit configured to detect illegal repetition of an instruction and transition to a known state
US11467840B2 (en) * 2016-06-20 2022-10-11 Imagination Technologies Limited Livelock recovery circuit for detecting illegal repetition of an instruction and transitioning to a known state
US11847456B2 (en) 2016-06-20 2023-12-19 Imagination Technologies Limited Livelock recovery circuit for detecting illegal repetition of an instruction and transitioning to a known state

Similar Documents

Publication Publication Date Title
US4476525A (en) Pipeline-controlled data processing system capable of performing a plurality of instructions simultaneously
EP0495165B1 (en) Overlapped serialization
JPS63175934A (en) Data processor
JPH04223532A (en) Improved processor
EP0402856B1 (en) Instruction execution control system
JP2008535072A (en) Selective subroutine return structure
JP2002342114A (en) Processor capable of collecting trace data
US5146569A (en) System for storing restart address of microprogram, determining the validity, and using valid restart address to resume execution upon removal of suspension
JPH03292545A (en) Detection/recovery device for program loop
JPS6250934A (en) Interrupting control system of processor
JPH11345121A (en) Instruction extracting device for program control unit and method thereof
JP2000076081A (en) Task manager and program recording medium
JPH08171504A (en) Emulation device
JPH0475147A (en) Time monitoring device in information processing system
JP3129873B2 (en) Microcomputer
JPH0764822A (en) Microcomputer
JPS6259818B2 (en)
JPS61175733A (en) Control system of branch estimation
JPH0325617A (en) Loop instruction control device for microprocessor
JPH08263324A (en) Debug facilitation device
JPH04213727A (en) Information processor
JPS58223855A (en) Storage address controller using microprogram
JPS63247834A (en) Processing method for pseudo instruction of floating point function
JPH0378832A (en) Data processor
JPH01211048A (en) Measuring system for executing instruction number of program