JP2005107573A - Computer system which can restore execution state - Google Patents

Computer system which can restore execution state Download PDF

Info

Publication number
JP2005107573A
JP2005107573A JP2003336047A JP2003336047A JP2005107573A JP 2005107573 A JP2005107573 A JP 2005107573A JP 2003336047 A JP2003336047 A JP 2003336047A JP 2003336047 A JP2003336047 A JP 2003336047A JP 2005107573 A JP2005107573 A JP 2005107573A
Authority
JP
Japan
Prior art keywords
state
power
access
request
cpu
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
JP2003336047A
Other languages
Japanese (ja)
Inventor
Tadashi Omura
廉 大村
Yuichiro Anzai
祐一郎 安西
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.)
Keio University
Original Assignee
Keio University
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 Keio University filed Critical Keio University
Priority to JP2003336047A priority Critical patent/JP2005107573A/en
Publication of JP2005107573A publication Critical patent/JP2005107573A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • Power Sources (AREA)
  • Retry When Errors Occur (AREA)

Abstract

<P>PROBLEM TO BE SOLVED: To restore the states of main storage, CPU and a peripheral device while maintaining consistency between them even if the system faces sudden power supply shutdown on the premise that a main storage is non-volatile. <P>SOLUTION: The computer system is composed of elements such as: a kernel (OS) 210; device drivers 220, 230 and 240 which correspond to respective peripheral devices 142 to 144 and serve as the interfaces between the kernel and the devices; and application programs 262, 264 and 266 executed on the OS210 in a user level. By considering that the device drivers 220, 230 and 240 are the elements where dependence on the devices 142, 143 and 144 occurs, consistency is maintained between the individual devices and the device drivers. Thus, the system can be restored from sudden power supply shutdown. <P>COPYRIGHT: (C)2005,JPO&NCIPI

Description

本発明は、主記憶に不揮発メモリを用いたコンピュータ・システムの実行状態復元に関するものである。   The present invention relates to execution state restoration of a computer system using a nonvolatile memory as a main memory.

突然の電源切断に面した時にも、その実行状態が復元可能なシステムを構築することは、広く一般に普及するコンピュータ・システムの信頼性や利便性を大きく向上させる。さらに現在、「ユビキタス電源」と呼ばれ、様々な形でコンピュータ・システムに対して電力を供給する試みが盛んに行なわれている。これらの電源は基本的に不安定であり、システムへの電力供給は断続的にならざるを得ない。このような環境下で動作するコンピュータ・システムには、電源切断時のシステムの実行状態を即座に回復するような能力が求められる。電源が失われる毎にOSやアプリケーションの再起動を必要とするようでは、大きくその利便性を損なう。
システムが突然の電源切断に面した時に、その実行状態を復元するためには、電源切断前のシステム全体の状態が保存されており、システム再起動(リカバリ)時にそれらが復元可能である必要がある。また、復元される状態はシステム全体で一貫性が保証される必要がある。システムの実行状態には、CPUや主記憶と共に周辺デバイスが保持する状態が含まれる。耐故障性の向上を目的として、fail-stopモデルでの故障に対し、システム状態の復元をするための研究が多く行われている(非特許文献1〜3参照)。しかし、主にCPUと主記憶の状態を対象としており、システムに接続される周辺デバイスの状態についてはあまり考慮がなされてこなかった。例えば、libckpt(非特許文献4参照)では、デバイスについてはオープンしているファイル・ディスクリプタ及びファイル上の注視点 の情報を復元するのみであり、デバイス自体が持つ状態については考慮されていない。
Building a system that can restore its execution state even when sudden power-off is faced greatly improves the reliability and convenience of widely used computer systems. At present, there are many attempts to supply power to computer systems in various forms called “ubiquitous power supplies”. These power supplies are basically unstable and power supply to the system must be intermittent. A computer system that operates in such an environment is required to have an ability to immediately recover the execution state of the system when the power is turned off. If the OS or application needs to be restarted every time the power is lost, the convenience is greatly impaired.
In order to restore the running state when the system faces a sudden power off, the state of the entire system before the power is turned off is saved and must be recoverable when the system is restarted (recovered) is there. In addition, the restored state needs to be consistent throughout the system. The execution state of the system includes a state held by a peripheral device together with the CPU and main memory. For the purpose of improving fault tolerance, many studies have been conducted to restore the system state against failures in the fail-stop model (see Non-Patent Documents 1 to 3). However, it mainly targets the state of the CPU and main memory, and the state of peripheral devices connected to the system has not been considered much. For example, libckpt (see Non-Patent Document 4) only restores information on open file descriptors and gazing points on files, and does not consider the status of the device itself.

APM(非特許文献5参照)やACPI(非特許文献6参照)などのシステムの電源管理仕様では、周辺デバイスの状態も含めたシステムの実行状態復元(サスペンド/レジュームやハイバネーション)を実現する。これらの実装では、システムの電源状態の遷移要求が通知された際に、周辺デバイスを含めたシステムの状態を保存/復元する。しかし、状態の保存処理は電力が十分に残されている間に行われることを前提とするため、突然電力が失われるような場合や保存処理に必要な電力が十分に残されていないような場合には対応できない。さらに、現在までの技術は、そのほとんどが主記憶の内容は電源切断と共に失われるものとし、主記憶の大部分の状態の保存を必要とした。また、保存先にはディスク等の低速なデバイスが利用されていた。一方、現在主記憶として用いることが可能な不揮発性メモリの実用化がなされてきている。電源切断時に不揮発である主記憶に残る状態と共に、適切なCPUや周辺デバイスの状態が復帰されれば、ほぼ実行時そのままのシステム実行状態を高速に復元可能となる。   System power management specifications such as APM (see Non-Patent Document 5) and ACPI (see Non-Patent Document 6) realize system execution state restoration (suspend / resume and hibernation) including the state of peripheral devices. In these implementations, the system state including peripheral devices is saved / restored when a power supply state transition request is notified. However, since it is assumed that the state storage process is performed while sufficient power is left, the case where power is suddenly lost or the power required for the storage process is not sufficiently left. Cannot handle the case. Furthermore, most of the technologies up to now assume that the contents of the main memory are lost when the power is turned off, and it is necessary to save the main state of the main memory. In addition, a low-speed device such as a disk has been used as a storage destination. On the other hand, a nonvolatile memory that can be used as a main memory has been put into practical use. If the state of the appropriate CPU and peripheral devices is restored together with the state that remains in the nonvolatile main memory when the power is turned off, the system execution state can be restored almost at the time of execution at high speed.

Elnozahy, M., Alvisi, L., Wang, Y.-M. and Johnson, D.B.: A Survery of Rollback-Recovery Protocols in Message-Passing Systems, Technical Report CMU-CS-99-148, Carnegie Mellon University (1999).Elnozahy, M., Alvisi, L., Wang, Y.-M. and Johnson, DB: A Survery of Rollback-Recovery Protocols in Message-Passing Systems, Technical Report CMU-CS-99-148, Carnegie Mellon University (1999 ). Joe, D., Glasco, D. and Flynn, M.: Fault Tolerance: Methods of Rollback Recovery, Technical Report CSL-TR-97-718, Stanford University (1997)Joe, D., Glasco, D. and Flynn, M .: Fault Tolerance: Methods of Rollback Recovery, Technical Report CSL-TR-97-718, Stanford University (1997) Morin, C. and Puaut, I.: A Survey of Recoverable Distributed Shared Memory Systems, IEEE Trans. on Parallel and Distributed Systems, Vol. 8, No. 9, pp. 959〜969 (1997)Morin, C. and Puaut, I .: A Survey of Recoverable Distributed Shared Memory Systems, IEEE Trans. On Parallel and Distributed Systems, Vol. 8, No. 9, pp. 959-969 (1997) Plank, J. S., Beck, M. and Kingsley, G.: Libckpt: Transparent Checkpointing under Unix, USENIX Winter 1995 Technical Conference, pp. 213〜223 (1995)Plank, J. S., Beck, M. and Kingsley, G .: Libckpt: Transparent Checkpointing under Unix, USENIX Winter 1995 Technical Conference, pp. 213-223 (1995) Intel and Microsoft: Advanced Power Management BIOS Interface Specification Rev.1.2 (1996) http://www.microsoft.com/hwdev/archive/BUSBIOS/apm 12.asp.Intel and Microsoft: Advanced Power Management BIOS Interface Specification Rev.1.2 (1996) http://www.microsoft.com/hwdev/archive/BUSBIOS/apm 12.asp. Corporation, C. C., Corporation, I., Corporation, M., Ltd., P. T. and Corporation,T.: Advanced Configuration and Power Interface Specification Rev. 2.0a (2002) http://www.acpi.infoCorporation, C. C., Corporation, I., Corporation, M., Ltd., P. T. and Corporation, T .: Advanced Configuration and Power Interface Specification Rev. 2.0a (2002) http://www.acpi.info

本発明の目的は、主記憶が不揮発であるシステムを前提とし、システムが突然の電源切断に面した場合にも、主記憶,CPU,周辺デバイスの状態を、一貫性を維持しつつ復元可能とすることである。   The object of the present invention is based on the premise that the main memory is non-volatile, and even if the system faces sudden power off, the states of the main memory, CPU, and peripheral devices can be restored while maintaining consistency. It is to be.

本発明の目的を達成するために、本発明は、電源切断時のシステムの実行状態を復元できるコンピュータ・システムであって、不揮発性メモリである主記憶と、システム実行中に電源切断を検出して電源切断割り込みを発生する電源切断割り込み手段と、前記電源切断割り込みにより、CPUの状態を保存するCPU状態保存手段と、周辺デバイスへのアクセスごとにログをとるか、デバイスアクセス前にチェックポインティングを行うデバイスアクセス保存手段と、デバイスへ発行された要求を保存するデバイス要求保存手段と、電源が投入され、システムが立ち上がるときに、直前にシステム実行中に電源切断となったことを検出する直前電源切断検出手段と、直前にシステム実行中に電源切断となったとき、前記デバイスアクセス保存手段およびデバイス要求保存手段により保存された情報により、周辺デバイス状態および該デバイスへのアクセス状態を復帰してCPUが復帰するポイントを決定する復帰手段と、決定されたCPUの復帰ポイントからシステム実行を再開する実行再開手段とを備えることを特徴とする。
周辺デバイスへのアクセスごとにログをとるか、デバイスアクセス前にチェックポインティングを行うデバイスアクセス保存手段と、デバイスへ発行された要求を保存するデバイス要求保存手段と、直前にシステム実行中に電源切断となったとき、前記デバイスアクセス保存手段およびデバイス要求保存手段により保存された情報により、周辺デバイス状態および該デバイスへのアクセス状態を復帰してCPUが復帰するポイントを決定する復帰手段とをコンピュータ・システムに構築させるプログラムも本発明である。
In order to achieve the object of the present invention, the present invention is a computer system capable of restoring the execution state of the system when the power is turned off, and detects the power off during the system execution and the main memory which is a nonvolatile memory. A power-off interrupt means for generating a power-off interrupt, a CPU state saving means for saving the CPU state by the power-off interrupt, and a log for each access to a peripheral device, or checkpointing before device access Device access storage means to perform, device request storage means to store a request issued to the device, and power supply immediately before detecting that the power was turned off during system execution when the power was turned on and the system started Disconnection detection means and device access save when power is cut off during system execution Based on the information saved by the stage and the device request saving means, the peripheral device state and the access state to the device are restored to determine a point at which the CPU returns, and the system execution is executed from the determined CPU return point. And an execution restarting means for restarting.
Logs every access to peripheral devices, or device access storage means that performs checkpointing before device access, device request storage means that stores requests issued to devices, and power-off during system execution immediately before And a return means for determining a point at which the CPU returns by returning the peripheral device state and the access state to the device based on the information stored by the device access storage means and the device request storage means. A program to be constructed is also the present invention.

本発明は、基本的にソフトウェア・ベースのアプローチであり、補助的な電源を仮定しない。このため、小型化や軽量化などの要求から、補助的な電源の利用が困難なシステムにも適用可能である。また、不安定な電源環境下で、補助電源に十分な容量の電力が残されていなかった場合など、前述の電源管理仕様を補うことができる。   The present invention is basically a software-based approach and does not assume an auxiliary power supply. For this reason, it can be applied to a system in which it is difficult to use an auxiliary power source due to demands for size reduction and weight reduction. Further, the power management specification described above can be supplemented when, for example, a sufficient amount of power is not left in the auxiliary power supply in an unstable power supply environment.

本発明の実施形態を、図を用いて説明する。
図1に本発明の実施形態のハードウェア構成を、図2にシステムのソフトウェア構成を示す。本発明では、図1に示すように、主記憶120が不揮発性メモリで構成されたシステムを対象とする。現在、MRAMやFeRAMなど、主記憶に用いられるメモリと同様の方法で読込/書込アクセスが可能な不揮発性メモリが実用化されている。これらは速度や容量の面においても、現状の主記憶の代替として十分な能力を持つことができる。
また、電源切断時のCPU110の状態は復帰可能とする。電源152を監視する電源監視IC156を用い、システムに供給される電源152が一定値以下になった場合にCPU110に対して、割込線158により割り込みをかける。この割り込みにより、割り込み処理(図2の割り込みハンドラ212)で特定の領域にCPU110の状態を保存する。必要であれば、キャパシタ等によってCPUの状態を保存する処理時間分、電源の減衰を鈍らせることも可能である。この保存されたCPUの状態は、リカバリ時にブート・リカバリ処理214によって利用される。
周辺デバイス142〜144には、以下のような前提を設ける。デバイスが動作していない時の状態(アイドル状態)は、再初期化および必要な情報の設定を行えば復元可能とする。また、電源切断前のデバイスの状態を復元し、同じデバイスへのアクセス(コマンド)を再実行すれば、デバイスは停止前と同一の動作をするものとする。そして、システム上の各デバイスはそれぞれ独立に動作するものとする。デバイスが電源切断によって損傷する場合は考えない。
Embodiments of the present invention will be described with reference to the drawings.
FIG. 1 shows the hardware configuration of the embodiment of the present invention, and FIG. 2 shows the software configuration of the system. In the present invention, as shown in FIG. 1, a system in which the main memory 120 is configured by a nonvolatile memory is targeted. Currently, nonvolatile memories such as MRAM and FeRAM that can be read / written by a method similar to the memory used for main memory have been put into practical use. In terms of speed and capacity, they can have sufficient capacity as an alternative to the current main memory.
Further, the state of the CPU 110 when the power is turned off can be restored. A power supply monitoring IC 156 that monitors the power supply 152 is used, and when the power supply 152 supplied to the system falls below a certain value, the CPU 110 is interrupted by an interrupt line 158. By this interruption, the state of the CPU 110 is saved in a specific area by interruption processing (interrupt handler 212 in FIG. 2). If necessary, the attenuation of the power source can be slowed by a processing time for storing the CPU state by a capacitor or the like. The stored CPU state is used by the boot / recovery process 214 during recovery.
Peripheral devices 142 to 144 have the following assumptions. The state when the device is not operating (idle state) can be restored by performing reinitialization and setting of necessary information. Further, if the state of the device before power-off is restored and the access (command) to the same device is re-executed, the device is assumed to perform the same operation as before the stop. Each device on the system operates independently. Don't think if the device is damaged by power off.

<システムモデル>
本発明の実施形態のソフトウェアのシステム構成を図2に示す。図2に示されるように、カーネル(OS)210、各周辺デバイス142〜144に対応した、カーネルとデバイスとのインターフェースであるデバイス・ドライバ220,230,240、OS210上でユーザ・レベルで実行される、アプリケーション・プログラム262,264,266等の要素により構成されている。
このような複数の要素で構成されるシステムにおいて、各要素間に依存関係が発生しなければ、各要素が独立に状態を復元し、システム全体の一貫性を維持することが可能である。
このシステムでは、主記憶120は不揮発性であり、状態を復元する必要はない。また、CPU110の状態も上述したように復元できる。
よって、まず、デバイス142〜144との依存関係が発生する要素であるデバイス・ドライバ220,230,240に注目する。そして、個々のデバイスとデバイス・ドライバの間で一貫性を維持するリカバリ手法を確立する。その手法をシステムに接続される各デバイス・ドライバにそれぞれ適用することによって、システム全体の状態を回復することができる。
本発明の実施形態では、デバイス・ドライバにコードを追加し、デバイス・ドライバやデバイスの情報を保存/復元する。追加されるコードでは、デバイス・ドライバとデバイスの間で一貫性を維持するように、必要となる情報を保存する。
<System model>
FIG. 2 shows a system configuration of software according to the embodiment of the present invention. As shown in FIG. 2, kernel (OS) 210, device drivers 220, 230, and 240 that are interfaces between the kernel and devices corresponding to the peripheral devices 142 to 144, and are executed on the OS 210 at the user level. The application program 262, 264, 266, etc.
In such a system composed of a plurality of elements, if a dependency relationship does not occur between the elements, it is possible for each element to independently restore the state and maintain the consistency of the entire system.
In this system, the main memory 120 is non-volatile, and there is no need to restore the state. Also, the state of the CPU 110 can be restored as described above.
Therefore, first, attention is paid to the device drivers 220, 230, and 240, which are elements that generate dependency relationships with the devices 142 to 144. Then, establish a recovery technique that maintains consistency between individual devices and device drivers. By applying the method to each device driver connected to the system, the state of the entire system can be recovered.
In the embodiment of the present invention, code is added to a device driver, and device driver and device information is saved / restored. The added code preserves the necessary information to maintain consistency between the device driver and the device.

<モデルの説明>
本実施形態を、メッセージパッシング・システムのモデルを用いて説明する。メッセージパッシング・システムのモデルでは、図3に示すようにシステムを成するプロセスの実行を横矢印で表し、それらの間で取り交わされるメッセージを斜めの矢印で表す。各プロセスは通常実行中、その実行状態を保存する。この時点は「チェックポイント」と呼ばれる。また、あるプロセスが故障により停止した後、リカバリ作業によって各プロセスが復元されるポイントを「リカバリポイント」と呼ぶ。リカバリポイントは各プロセスのチェックポイントから選ばれる。また、各リカバリポイントを結んだ線を「リカバリライン」と呼ぶ。このリカバリラインがメッセージを横切る場合に、回復後のシステム状態の一貫性が維持できない場合があることが知られている。
説明する実施形態では、デバイスを、システムを構成する1プロセスとみなす。なぜなら、メッセージパッシング・システムにおける各プロセスと同じく、通常各デバイスはCPUと並列に実行するためである。同様に、デバイス・ドライバの実行を1プロセスとみなし、また、デバイス・ドライバ内の割り込み処理についても非同期に起動されるため、単独のプロセスとみなす。そして、割り込みを含むデバイスとのやり取り(アクセス)をメッセージとみなす。デバイスとのやりとりによって、デバイス・ドライバとデバイスが保持する状態に依存関係が発生することも、メッセージパッシング・システムでのモデルに類似するためである。
このようにモデル化したとき、システムの一貫性を保つためには、各アクセスを横切らないリカバリラインを発見すればよいこととなる。
このことから、まずデバイス状態の復元可能なポイント、つまりデバイスのアイドル状態を基準として、適切なリカバリラインを発見する。そして、デバイス・ドライバやその割り込み処理について、電源切断時点の状態を利用することができない場合には、デバイス・ドライバの状態を保存するようにし、リカバリポイントを作り出す。この方針を基にして、デバイスとデバイス・ドライバ間で整合性を維持するための要件を抽出する。
<Description of model>
The present embodiment will be described using a message passing system model. In the model of the message passing system, as shown in FIG. 3, execution of processes constituting the system is represented by horizontal arrows, and messages exchanged between them are represented by diagonal arrows. Each process saves its execution state during normal execution. This point is called a “checkpoint”. A point at which each process is restored by a recovery operation after a certain process is stopped due to a failure is called a “recovery point”. Recovery points are selected from the checkpoints of each process. A line connecting the recovery points is called a “recovery line”. It is known that the consistency of the system state after recovery may not be maintained when this recovery line crosses a message.
In the described embodiment, the device is considered as one process constituting the system. This is because, as with each process in the message passing system, each device normally executes in parallel with the CPU. Similarly, the execution of the device driver is regarded as one process, and the interrupt processing in the device driver is also started asynchronously, so that it is regarded as a single process. The exchange (access) with the device including the interrupt is regarded as a message. This is because dependency between the device driver and the state held by the device due to the interaction with the device is similar to the model in the message passing system.
When modeled in this way, in order to maintain system consistency, it is only necessary to find a recovery line that does not cross each access.
From this, first, an appropriate recovery line is found on the basis of the point where the device state can be restored, that is, the idle state of the device. If the state at the time of power-off cannot be used for the device driver or its interrupt processing, the state of the device driver is saved to create a recovery point. Based on this policy, requirements for maintaining consistency between devices and device drivers are extracted.

<解析>
図3と同様な図を用いて、要件を抽出するために、デバイス・ドライバの動きを解析する。
(デバイスへの要求発行)
図4に、モデル化したデバイス・ハンドリング時の様子を示す。横の矢印は時間の経過と各要素の実行状態を表し、線が細い部分はその要素が実行されていないことを表す。これは、デバイスについてはアイドル状態を意味する。縦の矢印はデバイスへのアクセスを表す。読み込み及び書き込みのアクセスが混在する場合が多いため、上下両方を指す矢印として示してある。
図4のP1において、デバイス・ドライバはデバイスへの要求を発行し始める。デバイスが持つレジスタの設定や読み込みを複数回行った後、P2においてその要求の発行が終了する。そして、デバイスは要求に対応する実行を開始する。
P1以前にシステムの電源切断が生じた場合、デバイスはアイドル状態である。よって、図4のリカバリラインはL1のようになり、電源切断の時の状態がそのまま復元可能である。
<Analysis>
Using a diagram similar to FIG. 3, the movement of the device driver is analyzed to extract the requirements.
(Issuing requests to devices)
FIG. 4 shows a modeled device handling state. The horizontal arrow indicates the passage of time and the execution state of each element, and the thin line indicates that the element is not executed. This means an idle state for the device. A vertical arrow represents access to the device. Since there are many cases where read and write accesses are mixed, they are shown as arrows pointing up and down.
In P1 of FIG. 4, the device driver starts issuing a request to the device. After setting and reading the register of the device a plurality of times, the issue of the request is completed in P2. The device then starts executing in response to the request.
If the system is powered off before P1, the device is idle. Therefore, the recovery line in FIG. 4 becomes L1, and the state at the time of power-off can be restored as it is.

図4において、P1とP2の間で電源切断が生じた場合、復元可能なデバイスの状態はP1での状態である。そのままデバイス・ドライバの電源切断時の状態を復元したとすれば、この時のリカバリラインはL2で示される点線となる。
この場合、P1から電源切断までのアクセスに依存するデバイスの状態は失われ、デバイスは要求を正確に実行できなくなる。これは、図3においてリカバリラインLがメッセージを横切るとき、リカバリ後のシステム状態の一貫性が維持できない、ということに対応する。
この解決には2通りの方法が考えられる。一つは、P1でのCPU,主記憶,デバイスの状態を復元し、実行を再びP1から開始する方法である。これは、リカバリラインをP1での垂直線にすることである。もう一つは、実行中に各アクセスのログを保存し、P1でのデバイス状態を復元した後に、P1から電源切断までのログを用いてアクセスをもう一度行う方法である。それぞれ、メッセージパッシング・システムでのチェックポインティング手法、ロギング手法に相当し、デバイス・ドライバの製作者がP1からP2に行われる処理内容に応じて選択すれば良い。
In FIG. 4, when the power is cut off between P1 and P2, the state of the recoverable device is the state at P1. If the state at the time of powering off the device driver is restored as it is, the recovery line at this time is a dotted line indicated by L2.
In this case, the state of the device depending on the access from P1 to power off is lost, and the device cannot execute the request accurately. This corresponds to the fact that the consistency of the system state after recovery cannot be maintained when the recovery line L crosses the message in FIG.
There are two possible methods for solving this problem. One is a method of restoring the CPU, main memory, and device states at P1, and starting execution again from P1. This is to make the recovery line a vertical line at P1. The other is a method in which a log of each access is saved during execution, the device state at P1 is restored, and access is performed again using the logs from P1 to power off. Each corresponds to a checkpointing method and a logging method in a message passing system, and the device driver producer may select according to the processing contents performed from P1 to P2.

P2以降、デバイスが動作を開始した後に電源切断が生じた場合には、リカバリラインはL3のようにすれば良い。P1におけるデバイスの状態を復元し、P1からP2に行われるデバイスへのアクセスを再度実行できれば、P2でのデバイスの状態を復元可能である。よって、P1からP2間のアクセスを「デバイスへの要求」として保存し、リカバリ時に再実行することにより、P2でのデバイス状態を復元するようにする。このとき、デバイス・ドライバはデバイスとは無関係に動作するので、P2以降電源切断が生じた場合には、CPUや主記憶の状態は電源切断時の状態をそのまま使用し、システムを復帰すればよい。   After P2, if the power is turned off after the device starts operating, the recovery line may be L3. If the state of the device in P1 is restored and the access to the device performed from P1 to P2 can be executed again, the state of the device in P2 can be restored. Therefore, the access between P1 and P2 is stored as a “request to the device” and is re-executed at the time of recovery to restore the device state at P2. At this time, since the device driver operates regardless of the device, when the power is turned off after P2, the state of the CPU and the main memory can be used as they are and the system can be restored. .

(割り込み処理)
非同期に動作するデバイスの動作の完了は、通常割り込みを用いて行われる。また、マウスやキーボードなど、デバイス側から発生するイベントも同様に割り込みを用いてCPUに通知される。それぞれの場合をモデル化した図を、図5及び図6に示す。各図中
において、割り込みは周辺デバイスから生じる太い上向きの矢印で表されている。
図5は、P1からP2にかけて発行された要求の完了通知(割り込み)がP3において発生した場合である。割り込みに応じて、対応するデバイス・ドライバの割り込みサービス処理(ISR:Interrupt Service Routine)が、カーネルの割り込みハンドラ212(図2参照)より呼び出される。ISRの処理では、デバイスの制御やデバイスからのデータの取得などのためのアクセスが発生する(以降、このような処理を「要求の後処理」と呼ぶ)。
P3からP4において、デバイスからデータを取得するための処理が行われるとすると、P4にてこの処理が完了する以前に電源切断が生じた場合、デバイスから取得されるデータは不完全なものとなる。このため、システムの再起動時P1からP2で発行される要求を再度実行し、デバイスが同じデータを保持するようにする必要がある。これは、前述したように、保存された「デバイスへの要求」をリカバリ時に再実行することにより行われる。ここからL1に示すリカバリラインが導き出される。このため、ISRでは電源切断までに行われた処理を無効化し、状態を割り込み発生以前(P3以前)のものにする必要がある。つまり、ISRではP3での状態を保存しておき、リカバリ時に復元する必要がある。
P4以降ISR内においてデバイスアクセスが終了した後には、処理はCPUと主記憶の間で完結するため、電源切断時点からシステムを再実行させることが可能となる。このためリカバリラインはL2のようになる。このときもはやデバイスの状態をP2に戻す必要はなくなるので、保存された「デバイスへの要求」はP4の時点で破棄可能となる。
(Interrupt processing)
Completion of the operation of the device operating asynchronously is normally performed using an interrupt. In addition, events generated from the device side such as a mouse and a keyboard are similarly notified to the CPU using an interrupt. FIGS. 5 and 6 show diagrams in which each case is modeled. In each figure, interrupts are represented by thick upward arrows originating from peripheral devices.
FIG. 5 shows a case where a completion notification (interrupt) of a request issued from P1 to P2 occurs at P3. In response to the interrupt, an interrupt service process (ISR: Interrupt Service Routine) of the corresponding device driver is called from the kernel interrupt handler 212 (see FIG. 2). In ISR processing, access for device control, data acquisition from the device, and the like occurs (hereinafter, such processing is referred to as “request post-processing”).
If the process for acquiring data from the device is performed in P3 to P4, the data acquired from the device will be incomplete if the power is cut off before the process is completed in P4. . For this reason, it is necessary to execute again the request issued from P1 to P2 when the system is restarted so that the device holds the same data. As described above, this is performed by re-executing the saved “request to the device” at the time of recovery. From this, the recovery line indicated by L1 is derived. For this reason, in the ISR, it is necessary to invalidate the processing performed until the power is turned off and to change the state to before the occurrence of the interrupt (before P3). That is, in the ISR, it is necessary to save the state at P3 and restore it at the time of recovery.
Since the process is completed between the CPU and the main memory after the device access is completed in the ISR after P4, the system can be re-executed from the power-off point. For this reason, the recovery line is L2. At this time, since it is no longer necessary to return the device state to P2, the stored “request to the device” can be discarded at the time of P4.

図6は、P1においてキーボードの入力やパケットの到着などのイベントが発生し、P2においてCPUに対して割り込みが発生した場合である。P1とP2は等しくても構わない。
P2とP3の間で電源切断が生じた場合、デバイスが保持するデータはまだ取得されていない。また、デバイスの状態は失われP1時点のものしか復元できない。この時のリカバリラインはL1となり、前述の議論と同様にISRの状態はP2以前に戻す必要がある。
P1以降のデバイスの状態を回復するための情報は、CPU側からは取得および保存する術がないため、この時生じた割り込みはシステムのリカバリ後完全に失われることとなる。しかし、このようなイベントは、もともと生じるかどうか不確定であるため、無視できる場合が多い。キーボードやマウスの入力がこれにあたる。
FIG. 6 shows a case where an event such as keyboard input or packet arrival occurs at P1, and an interrupt occurs to the CPU at P2. P1 and P2 may be equal.
When the power is cut off between P2 and P3, the data held by the device has not been acquired yet. Further, the device state is lost, and only the device at the point P1 can be restored. The recovery line at this time is L1, and it is necessary to return the ISR state to P2 or earlier as in the above discussion.
Since there is no way to acquire and store the information for recovering the state of the device after P1 from the CPU side, the interrupt generated at this time is completely lost after the system is recovered. However, since it is uncertain whether such an event will occur originally, it is often negligible. This is the keyboard or mouse input.

(共有領域のアクセス)
前述では、ISRの状態はロールバックされる必要がある場合があることについて述べた。ロールバックされる要素が存在する場合、その要素に依存して他の要素もロールバックしなければならない可能性について考慮しなければならない。
図7は、ISRがロールバックされる時において、この状況が発生する場合である。ISR内でデバイスへのアクセスが終了する(P5)以前に、P3においてISRが共有領域にある共有データに対して書き込みを行い、かつP4においてデバイス・ドライバがそのデータの読み込みを行ったとする。この時、ISRとデバイス・ドライバの状態に依存関係が発生する。そして、P4とP5の間で電源切断が生じた場合、ISRの状態はP2にロールバックされるため、デバイス・ドライバの状態もP4以前に戻さなければならなくなる。
問題の解決には、ISRがロールバックされる範囲内でISRとデバイス・ドライバの間に依存関係が発生しないようにすれば良い。このことから、一つの解決策は、ISRから共有領域への書き込みアクセスはデバイスへのアクセスが終了した後に行うように、ISRをプログラムすることである。それが困難な場合、ISRが共有領域に関連する同期プリミティブのロックを、デバイスのアクセスが終了するまで保持し続けるようにしても良い。これによって、デバイス・ドライバからの共有領域への書込アクセスをP5以降まで行われないようにすれば良い。なお、ISRとデバイス・ドライバが並行もしくは並列に実行されないことが自明の場合、これらの対応は必要ない。
(Access to shared area)
In the foregoing, it was mentioned that the ISR state may need to be rolled back. If there are elements to be rolled back, you must consider the possibility that other elements may have to be rolled back depending on the element.
FIG. 7 is a case where this situation occurs when the ISR is rolled back. Assume that before the access to the device is completed in the ISR (P5), the ISR writes to the shared data in the shared area at P3, and the device driver reads the data at P4. At this time, a dependency occurs between the state of the ISR and the device driver. When the power is cut off between P4 and P5, the ISR state is rolled back to P2, so the device driver state must be returned to the state before P4.
In order to solve the problem, it is only necessary to prevent the dependency between the ISR and the device driver from occurring within the range in which the ISR is rolled back. From this, one solution is to program the ISR so that write access from the ISR to the shared area is done after the access to the device is completed. If this is difficult, the ISR may keep holding the lock on the synchronization primitive associated with the shared region until the device access is terminated. Thus, the write access from the device driver to the shared area should not be performed until P5. If it is obvious that the ISR and the device driver are not executed in parallel or in parallel, these measures are not necessary.

<解析のまとめ>
上述した解析をまとめると以下のようになる。
(1)デバイスへのアクセスは、各アクセス毎にログをとるか、デバイスアクセス前にチェックポインティングを行う。
(2)デバイスへ発行される要求を保存する。
(3)保存されたデバイスへの要求は、対応する割り込みが生じ、その要求の後処理が終了した時点で破棄可能となる。
(4)ISR内で要求の後処理等のためのデバイスアクセスが完了する前に電源切断が生じた場合、その状態は割り込み発生以前にロールバックさせる。
(5)ISR内で他の要素との共有領域へ書込アクセスを行う場合、デバイスアクセス終了後に行うようにするか、ISRがデバイスアクセス終了後までロックを保持し続けるようにする。
<Summary of analysis>
The above analysis is summarized as follows.
(1) Access to the device is logged for each access or checkpointing is performed before device access.
(2) Save the request issued to the device.
(3) A request to a stored device can be discarded when a corresponding interrupt occurs and post-processing of the request ends.
(4) If the power is cut off before the device access for request post-processing is completed in the ISR, the state is rolled back before the occurrence of the interrupt.
(5) When a write access is made to a shared area with another element in the ISR, it is performed after the device access is completed, or the ISR is kept holding the lock until the device access is completed.

<デバイス・ドライバへの適用>
ここでは、表1に示す擬似コード例を用い、前述の事項のデバイス・ドライバへの適用方法について述べる。なお、表1中、read,write,ioctlの各メソッドの役割は、POSIXで規定される同名のAPIの機能と同一である。また、interruptメソッドは割り込み発生時に実行されるISRである。
<Application to device driver>
Here, using the pseudo code example shown in Table 1, a method of applying the above items to the device driver will be described. In Table 1, the role of each method of read, write, and ioctl is the same as the API function of the same name defined by POSIX. The interrupt method is an ISR executed when an interrupt occurs.

[表1]
1 void write(void* request){
2 if(idle == get_device_state()){
3 DEV_ACCESS_START();
4 tell_device_request(request);
5 DEV_REQUEST_SAVE(request_log,request);
6 DEV_ACCESS_END();
7 }else{
8 lock(request_queue);
9 enqueue(request_queue,request);
10 request_count++;
11 unlock(request_queue);
12 }
13 }
14 void read(void* return_buf){
15 lock(event_buf);
16 while(event_buf_count){
17 unlock(event_buf);
18 sleep(read_wait);
19 lock(event_buf);
20 }
21 memcpy(return_buf,event_buf);
22 event_buf_count--;
23 unlock(event_buf);
24 }
25 void ioctl(void* new_state){
26 dev_state = *new_state;
27 device_state_change(new_state);
28 }
29 void interrupt(){
30 do{
31 if(request_done & interrupt_reason()){
32 ISR_STATE_SAVE();
33 post_processing_for_request();
34 ISR_STATE_DISCARD();
35 DEV_REQUEST_DISCARD(request_log);
36 lock(request_queue);
37 if(request_count){
38 request = dequeue(request_queue);
39 DEV_ACCESS_START();
40 tell_device_request(request);
41 request_count--;
42 DEV_REQUEST_SAVE(request_log,request);
43 DEV_ACCESS_END();
44 }
45 unlock(request_queue);
46 }
47 if(event_arose & interrupt_reason()){
48 ISR_STATE_SAVE();
49 lock(event_buf);
50 data = get(event_buf);
51 post_processing_for_event(&data);
52 event_buf_count++;
53 ISR_SATE_DISCARD();
54 unlock(event_buf);
55 if(someone_is(read_wait))
56 wakeup(read_wait);
57 }
58 }while(interrupt_reason());
59 }
[Table 1]
1 void write (void * request) {
2 if (idle == get_device_state ()) {
3 DEV_ACCESS_START ();
4 tell_device_request (request);
5 DEV_REQUEST_SAVE (request_log, request);
6 DEV_ACCESS_END ();
7} else {
8 lock (request_queue);
9 enqueue (request_queue, request);
10 request_count ++;
11 unlock (request_queue);
12}
13 }
14 void read (void * return_buf) {
15 lock (event_buf);
16 while (event_buf_count) {
17 unlock (event_buf);
18 sleep (read_wait);
19 lock (event_buf);
20}
21 memcpy (return_buf, event_buf);
22 event_buf_count--;
23 unlock (event_buf);
twenty four }
25 void ioctl (void * new_state) {
26 dev_state = * new_state;
27 device_state_change (new_state);
28}
29 void interrupt () {
30 do {
31 if (request_done & interrupt_reason ()) {
32 ISR_STATE_SAVE ();
33 post_processing_for_request ();
34 ISR_STATE_DISCARD ();
35 DEV_REQUEST_DISCARD (request_log);
36 lock (request_queue);
37 if (request_count) {
38 request = dequeue (request_queue);
39 DEV_ACCESS_START ();
40 tell_device_request (request);
41 request_count--;
42 DEV_REQUEST_SAVE (request_log, request);
43 DEV_ACCESS_END ();
44}
45 unlock (request_queue);
46}
47 if (event_arose & interrupt_reason ()) {
48 ISR_STATE_SAVE ();
49 lock (event_buf);
50 data = get (event_buf);
51 post_processing_for_event (&data);
52 event_buf_count ++;
53 ISR_SATE_DISCARD ();
54 unlock (event_buf);
55 if (someone_is (read_wait))
56 wakeup (read_wait);
57}
58} while (interrupt_reason ());
59}

上述の擬似コード例において、各デバイスアクセスに関する関数の役割については、表2のデバイスアクセスに関する関数を参照されたい。

Figure 2005107573
また、状態復帰に関する処理および状態復帰に関連する変数は、表3の状態復帰に関する処理,表4の状態復帰に関連する変数を参照されたい。
Figure 2005107573
Figure 2005107573
In the above pseudo code example, refer to the functions related to device access in Table 2 for the role of the functions related to each device access.
Figure 2005107573
For processing related to status recovery and variables related to status recovery, refer to processing related to status recovery in Table 3 and variables related to status recovery in Table 4.
Figure 2005107573
Figure 2005107573

(アイドル状態の復帰)
まず、アイドル時のデバイスの状態を復元できるようにしなければならない。これは基本的にはデバイスの初期化作業を行えば良い。しかし、ioctlシステムコールのように、明示的なデバイスの動作要求とは別に、デバイスの状態を変化させる場合がある。例えばUARTデバイスのボーレート設定などが該当する。
これらの設定を復元するため、デバイスの状態を変更する際に、変更後のデバイスの状態をリカバリ時に参照可能な領域へ保存しておく必要がある(表1中26行)。リカバリ時には、この情報を参照し、デバイスの状態の初期化と再設定を行うようにする。なお、要求の実行などがデバイスのアイドル状態に影響する場合も、同様にリカバリ時に参照可能な領域へその情報を保存し対応する。
(Idle state recovery)
First, it must be possible to restore the device state when idle. Basically, it is only necessary to initialize the device. However, the device state may be changed separately from an explicit device operation request, such as an ioctl system call. For example, the baud rate setting of the UART device is applicable.
In order to restore these settings, when changing the device state, it is necessary to save the changed device state in an area that can be referred to during recovery (line 26 in Table 1). At the time of recovery, this information is referred to, and the device state is initialized and reset. Note that if the execution of a request affects the idle state of the device, the information is similarly stored in an area that can be referred to during recovery.

(デバイスアクセス)
デバイスへの要求を発行するためのアクセスは、チェックポインティング手法もしくはロギング手法によって対応することを述べた。
チェックポインティング手法の場合には、デバイスへのアクセス開始時にデバイス・ドライバの主記憶状態,CPU状態の保存を行う。そして、アクセスが終了した時点でそれらの情報を破棄する。リカバリ時には、これらの情報が存在するかどうかを調べる。存在する場合には、保存された主記憶状態の復元を行った後、この時のCPU状態を用いてシステムの実行を再開すればよい。
このとき、主記憶状態の保存については、デバイス・ドライバ内全ての領域を保存する必要はない。デバイスアクセス開始時の状態が復元できれば良いため、デバイスアクセスが終了するまでに変更され、かつ復元が必要となる主記憶の状態を保存すれば良い。
ロギング手法を用いる場合には、各デバイスアクセス毎に、どのようなアクセスが行われるかを示すログをとる。そしてデバイスアクセスが終了した時点でこれらのログを破棄する。リカバリ時には、ログの存在を確認し、存在する場合には、それらのログを実行する。そして、電源切断時のCPU状態を用いてシステムの実行を再開すれば良い。
表1中DEV_ACCESS_START およびDEV_ACCESS_END(3,6,39,43行)は、それぞれ、デバイスへのアクセスの開始とデバイスへのアクセスの終了に対応する。ロギング手法ではDEV_ACCESS_STARTにおいて何も行う必要はなく、tell_device_request関数内でログをとるための変更を加える。
(Device access)
It has been stated that access to issue requests to devices is handled by checkpointing or logging.
In the case of the checkpointing method, the main memory state and CPU state of the device driver are saved when access to the device is started. Then, when the access is completed, the information is discarded. At the time of recovery, it is checked whether or not such information exists. If it exists, after the stored main memory state is restored, the execution of the system may be resumed using the CPU state at this time.
At this time, it is not necessary to save all areas in the device driver for saving the main memory state. Since it is sufficient that the state at the start of device access can be restored, the state of the main memory that is changed before the device access ends and needs to be restored may be saved.
When the logging method is used, a log indicating what kind of access is performed for each device access is taken. When the device access is completed, these logs are discarded. At the time of recovery, the existence of logs is confirmed, and if they exist, those logs are executed. Then, the execution of the system may be resumed using the CPU state at the time of power-off.
In Table 1, DEV_ACCESS_START and DEV_ACCESS_END (lines 3, 6, 39, and 43) correspond to the start of access to the device and the end of access to the device, respectively. The logging method does not need to do anything in DEV_ACCESS_START, and changes are made to log in the tell_device_request function.

(デバイスへの要求の保存)
デバイスへの要求は、デバイスへのアクセスが終了した後、アクセスを復元するための情報の破棄(DEV_ACCESS_END) が行われる前に、保存する必要がある。アクセスの情報を破棄した後、要求を保存したとする。これらの処理の間で電源切断が生じたとすると、アクセスを再実行するための情報は失われ、かつデバイスへの要求もまだ保存されていないこととなる。このため、デバイスの実行状態を復元できなくなってしまう。
また、前述したように、この情報が破棄されるのはISR内となる。破棄作業の注意点については、次で説明する。
前に、デバイス・ドライバのコンテキスト内で要求が発行される場合を述べたが、デバイスへの要求はISRの中でも発行される場合がある。デバイスがビジー状態の時に新たなデバイスへの要求が発行された場合、デバイス・ドライバのコンテキストではその要求をキューイングすることがある。キューイングされた要求は、実行中の要求が終了したとき、ISRの中でデバイスに発行される。しかし、ISR内で実行されたとしても、ロールバックされる範囲でなければ、まえに述べた議論と同一となる。つまり、通常実行時と同じ対応をISR内で行えば良い。このことは表1中、7〜11行および36〜44行に対応する。表1中、要求のログをとる処理に対応するのがDEV_REQUEST_SAVE(5,42行) である。また、ログの破棄に対応するのはDEV_REQUEST_DISCARD(35行)である。
(Save request to device)
The request to the device must be saved after the access to the device is completed and before the information for restoring the access is discarded (DEV_ACCESS_END). Assume that the request is saved after discarding the access information. If the power is cut off between these processes, the information for re-executing the access is lost, and the request to the device is not saved yet. For this reason, the execution state of the device cannot be restored.
As described above, this information is discarded in the ISR. Points to note about the discarding operation will be described below.
Although the case where the request is issued in the context of the device driver has been described before, the request to the device may be issued in the ISR. If a request for a new device is issued while the device is busy, the request may be queued in the context of the device driver. The queued request is issued to the device in the ISR when the running request is finished. However, even if it is executed within the ISR, it is the same as the discussion described above if it is not in a rollback range. That is, the same correspondence as in normal execution may be performed in the ISR. This corresponds to lines 7-11 and 36-44 in Table 1. In Table 1, DEV_REQUEST_SAVE (line 5, 42) corresponds to the process of logging the request. Also, DEV_REQUEST_DISCARD (35th line) corresponds to log discard.

(ISRのロールバック)
ISRの中で要求の後処理等のためのデバイスアクセスが終了する以前に電源切断が生じた場合、ISR の状態をロールバックしなければならない。このため、ISR の実行が開始する時に、ISRの主記憶状態を保存する必要がある。そして、デバイスへのアクセスが終了した時点で、破棄可能となる。
表1中、ISRの状態保存を行う処理に対応するのがISR_SATE_SAVE(32行,48行)、保存された情報を破棄する処理がISR_STATE_DISCARD(34行,53行)である。
これらの処理は、デバイスアクセスをチェックポインティング手法で復元させる場合の対応と類似するが、復帰後ISRを再実行する必要はないため、CPUの状態を保存する必要はない。リカバリ時には、カーネルが割り込み受け付けた時に保存したCPU状態(割り込み時に実行されていたコンテキスト) を用いてシステムを再開させれば良い。
再実行が必要な「デバイスへの要求」について、ISRがロールバックされる時に失われないようにする必要がある。このため、ISRの情報が破棄された後、この情報の破棄を行うようにする(35行)、もしくは、ISRの状態がロールバックされた時に、破棄された要求も復元するようにする必要がある。
(ISR rollback)
If the power is cut off before the device access for request post-processing is completed in the ISR, the state of the ISR must be rolled back. For this reason, it is necessary to save the main storage state of the ISR when the execution of the ISR starts. Then, when access to the device is completed, it can be discarded.
In Table 1, ISR_SATE_SAVE (line 32, line 48) corresponds to the process for saving the ISR state, and ISR_STATE_DISCARD (line 34, line 53) corresponds to the process for discarding the stored information.
These processes are similar to the case where device access is restored by the checkpointing method, but it is not necessary to re-execute the ISR after returning, and therefore it is not necessary to save the CPU state. At the time of recovery, the system may be restarted using the CPU state (context executed at the time of interruption) saved when the kernel accepted the interruption.
“Requests to devices” that need to be re-executed need not be lost when the ISR is rolled back. For this reason, it is necessary to discard the information after the ISR information is discarded (line 35), or to restore the discarded request when the ISR state is rolled back. is there.

ISRは複数の要因で起動されることが多い。例えば、ネットワークに対する送信終了割り込みと受信割り込みは同一のISRで処理されることがある。この場合、ISRでは、割り込み要因の特定を行い対応する割り込みを処理する。また、ISR実行中に割り込みが発生する場合がある。このため、ISRの処理は割り込み要因が無くなるまでループする場合がある。
ISRがロールバックされる範囲はそれぞれの割り込み要因の特定がなされてからのものとする必要がある。例えば、要求の終了とイベントによる割り込みが同時に発生したとする。このとき表1に示す擬似コードでは、ISRが起動され、要求に対応する処理終了に続いて、イベントの処理が行われることになる。要求に対応する処理が終り、50行目の処理中に電源切断が生じたとすれば、この場合ロールバックされなければならない内容はイベント処理に関するもののみである。要求に対応する処理までロールバックする必要はない。よって、ISR_STATE_SAVEとISR_STATE_DISCARDは表1の擬似コードのようにそれぞれ別々に挿入される(32と34行目及び48と53行目)。
また、ISR内で割り込み要因を特定する時に、「現在の状態」を確認する必要がある。同上の例において、38行目で電源切断が生じたとする。リカバリ後39行目以降の処理が継続されるが、デバイスの状態は失われているため電源切断前のイベントの処理を続けて行うことはできない。このため、復帰後には31、47行目や58行目でその時点の割り込み要因の特定がなされるようにする必要がある。
49行目と54行目のロックの操作は前に述べた「共有領域へのアクセス」の説明に対応するものである。51行目でreadメソッドとの共有領域であるevent_bufをアクセスする。このため、49行目で取得したロックは54行目まで保持される。ただし、ISRとデバイス・ドライバのコンテキストが同時に実行しないことが解っている場合には、これらの操作は必要ない。
ISR is often triggered by multiple factors. For example, a transmission end interrupt and a reception interrupt for the network may be processed with the same ISR. In this case, in the ISR, the interrupt factor is specified and the corresponding interrupt is processed. An interrupt may occur during ISR execution. For this reason, the ISR process may loop until there is no interrupt factor.
The range in which the ISR is rolled back needs to be determined after each interrupt factor is specified. For example, it is assumed that the end of the request and the interruption due to the event occur simultaneously. At this time, in the pseudo code shown in Table 1, the ISR is activated, and the event processing is performed following the end of the processing corresponding to the request. If the processing corresponding to the request is finished and the power is cut off during the processing of the 50th line, in this case, the only content that needs to be rolled back is related to the event processing. There is no need to roll back to the processing corresponding to the request. Therefore, ISR_STATE_SAVE and ISR_STATE_DISCARD are inserted separately as shown in the pseudo code in Table 1 (lines 32 and 34 and lines 48 and 53).
Further, when specifying the interrupt factor in the ISR, it is necessary to confirm the “current state”. In the above example, it is assumed that the power is cut off at the 38th line. Processing after the 39th line is continued after recovery, but since the state of the device is lost, it is not possible to continue processing the event before the power is turned off. For this reason, it is necessary to specify the interrupt factor at that time in the 31st, 47th and 58th lines after the return.
The operations for locking the 49th and 54th lines correspond to the explanation of “access to shared area” described above. In line 51, event_buf, which is a shared area with the read method, is accessed. For this reason, the lock acquired in the 49th line is held up to the 54th line. However, if it is known that the context of the ISR and the device driver do not execute at the same time, these operations are not necessary.

<リカバリ>
デバイス状態の復帰は、コールバック関数により行われる。コールバック関数の例を表5に示す。
[表5]コールバック関数の例(模擬コード)
1 int recovery_call_back(CPU_t **cpu_state){
2 initialize_device(dev_state);
3 recover_memory_area();
4 replay_request();
5 return flag;
6 }
表5の関数は、システム全体のリカバリ処理時にカーネル内のブート・リカバリ処理214(図2)から呼び出される。これまでの説明からわかるように、この関数では主に、デバイスの再初期化、主記憶状態の復元、デバイスへの要求の再実行を行うことになる。まず、前に述べたように、デバイスの再初期化は、通常実行中保存された情報を元に、アイドル時のデバイス状態を復元する(2行)。次に、DEV_ACCESS_START(チェックポインティング手法の場合) 、ISR_STATE_SAVEで保存された主記憶状態が存在する場合には、それぞれを復元する(3行)。そして、再実行すべきデバイスアクセスのログ(ロギング手法の場合)や再実行すべきデバイスへの要求が存在する場合にはこれらを実行する(4行)。また、リカバリ時にはISR_STATE_SAVEで保存された情報の破棄を行う必要があり、これは、ISRの状態を復元した後に行えば良い。DEV_ACCESS_STARTでの主記憶状態やログについては、リカバリ後の通常動作によって破棄されるため、この関数内では何も行う必要はない。
前に述べたように、ロールバックが必要となる範囲で電源切断が生じた場合、システムを再開させるためのCPU状態をカーネルが把握する必要がある。このため、このメソッドは例えば表5に示すように、CPU状態構造体へのポインタを参照受け渡しするようにし、DEV_ACCESS_STARTで保存されたCPU状態をカーネルに返せるようにする。また、ISR内で電源切断が生じた場合には、割り込み発生時に保存されたCPU状態を用いる必要があるので、このことを示せるように、返戻値として値を返す等を行う。これらの各デバイス・ドライバのコールバック関数から返される情報を元に、カーネルのブート・リカバリ処理はシステムの再実行に用いるCPUの状態を決定し、システムを復帰する。
<Recovery>
The device state is restored by a callback function. An example of the callback function is shown in Table 5.
[Table 5] Callback function example (simulated code)
1 int recovery_call_back (CPU_t ** cpu_state) {
2 initialize_device (dev_state);
3 recover_memory_area ();
4 replay_request ();
5 return flag;
6}
The functions in Table 5 are called from the boot recovery process 214 (FIG. 2) in the kernel during the recovery process of the entire system. As can be seen from the above description, this function mainly re-initializes the device, restores the main memory state, and re-executes the request to the device. First, as described above, the device re-initialization restores the device state during idling based on the information saved during normal execution (line 2). Next, when there is a main memory state saved by DEV_ACCESS_START (in the case of the checkpointing method) and ISR_STATE_SAVE, each is restored (line 3). If there is a device access log to be re-executed (in the case of a logging method) or a request for a device to be re-executed, these are executed (line 4). Further, at the time of recovery, it is necessary to discard the information stored in ISR_STATE_SAVE, which may be performed after restoring the ISR state. Since the main memory state and log in DEV_ACCESS_START are destroyed by normal operation after recovery, nothing needs to be done in this function.
As described above, when the power is cut off in a range where rollback is necessary, the kernel needs to grasp the CPU state for restarting the system. For this reason, as shown in Table 5, for example, this method allows a pointer to the CPU state structure to be passed by reference, so that the CPU state saved by DEV_ACCESS_START can be returned to the kernel. Further, when the power is cut off in the ISR, it is necessary to use the CPU state stored at the time of occurrence of the interrupt, so that a value is returned as a return value so as to indicate this. Based on the information returned from the callback function of each device driver, the boot recovery processing of the kernel determines the state of the CPU used for re-execution of the system and returns the system.

<電源切断およびリカバリ処理のまとめ>
上述の電源切断とリカバリのときのカーネルにおける処理をまとめると、以下の通りである。
(電源切断の処理)
1.電源切断が起こると、電源監視IC156等によってCPU110に割り込みが通知される。
2.カーネルの割り込みハンドラ212が、CPU110の状態をある特定の主記憶領域に保存する。
3.システム停止
(リカバリの処理)
1.システムに電源が投入される。
2.カーネルのブート・リカバリ処理214によって、直前にシステム実行中電源切断が生じたことを判断し、リカバリ・モードに入る。
3.リカバリ処理によって、各デバイス・ドライバ220,230,240のコールバック関数222,232,242が呼び出される。
4.各デバイス・ドライバのコールバック関数222,232,242は、各対応するデバイスの状態及びデバイス・ドライバの状態を復帰する(表5の擬似サンプルコード中recovery 関数)。
5.各コールバック関数から返される情報を元に、ブート・リカバリ処理214はCPUが復帰するポイントを決定する。
6.決定されたポイントにおけるCPUの状態を復帰し、システムの実行を再開する。
なお、これまでの説明は基本的な場合について述べたものである。例えば、要求の再実行が必要ないようなデバイスでは、リカバリ時に要求を再実行しなくとも良い。また、デバイスへの要求自体を保存しなくてもかまわない。これまでの議論をもとに、対象となるデバイスの特徴に応じてこれまで述べた方法を応用し、実際のデバイス・ドライバに適用すればよい。
<Summary of power-off and recovery processing>
The processing in the kernel at the time of power-off and recovery described above is summarized as follows.
(Power-off process)
1. When the power is cut off, an interrupt is notified to the CPU 110 by the power monitoring IC 156 or the like.
2. The kernel interrupt handler 212 saves the state of the CPU 110 in a specific main storage area.
3. System stop (recovery process)
1. The system is turned on.
2. It is determined by the kernel boot recovery process 214 that the power was cut off during the system execution immediately before, and the recovery mode is entered.
3. By the recovery processing, the callback functions 222, 232, and 242 of the device drivers 220, 230, and 240 are called.
4). The callback functions 222, 232, and 242 of each device driver restore the state of each corresponding device and the state of the device driver (recovery function in the pseudo sample code in Table 5).
5). Based on the information returned from each callback function, the boot recovery process 214 determines the point at which the CPU returns.
6). The CPU state at the determined point is restored, and the execution of the system is resumed.
The description so far has described the basic case. For example, in a device that does not require re-execution of a request, it is not necessary to re-execute the request during recovery. Further, it is not necessary to save the request to the device itself. Based on the discussion so far, the method described so far may be applied to the actual device driver according to the characteristics of the target device.

本発明の手法をlinux 2.4.4 カーネルを用いて実施した。CPUはモトローラ社のMPC860(40MHz動作)を用いた。またFeRAMを用いた不揮発RAM ボードを作成し、これを主記憶として用いた。デバイスとしては、オンチップ上に存在するUART及びEthernet(10Mbps)コントローラを用いた。まず、上述の手法を実装したシステムにおいて、実行状態の復元が可能であるかどうかを調べた。システム上でUARTデバイスに対して出力を続けるプロセスを実行し、電源を切断した。そして電源を再度入れシステムを再起動した際に、走行していたプロセスの実行が復元され、再びUARTデバイスに出力を開始することを確認した。
次に、提案手法が適切に動作しているかどうかを調べた。UARTデバイスから電源切断直前の文字が出力される場合があることを確認した。これは、UARTデバイスに対して、要求の再実行が適切に行われた結果だと考えることができる。また、デバイスアクセスの復元やISRの状態復元が適切に動作しているかを調べるため、システム上の最も高いレベルの割り込みにプッシュボタンを取りつけ、この割り込みを仮想的な電源切断として、この時のCPU状態を保存するようにした。そして、システムの実行中にこの割り込みを発生させた。割り込み発生時のアドレスを確認し、一度システムの電源を切断した後、再度システムの電源を投入してシステムを再起動させた。UARTデバイス、Ethernetデバイス両方について、デバイスアクセス中及びISR処理中に割り込みが発生した場合でも、電源切断時に実行中だった処理が継続することを確認した。この事により、デバイスへのアクセスの復帰や、ISRの状態復元処理が適切に行なわれていると考えることができる。
そして、実装したシステム上での提案手法によるオーバヘッドの測定をおこなった。提案手法を用いない場合(通常実行)、提案手法においてデバイスのアクセスに対しチェックポインティング手法を用いた場合、同じくロギング手法を用いた場合について2つのタスクを実行した。タスクAは、UARTデバイスに対し1文字を出力する動作を10000回繰り返すプロセスを実行し、time コマンドによってその実行時間を測定した。UARTのボーレート設定は9600bps である。タスクBはリモートのマシンに対し2MbyteのNFS上ファイルをcp コマンドによりコピーした。コピー先も同様にNFS上とした。それぞれの結果を図8に示す。
通常実行に対し、チェックポインティング手法、ロギング手法いずれを用いた場合にも、実行時間の増加がほとんどないことがわかる。
The method of the present invention was implemented using a linux 2.4.4 kernel. The CPU used was a Motorola MPC860 (40 MHz operation). A nonvolatile RAM board using FeRAM was prepared and used as the main memory. As devices, UART and Ethernet (10 Mbps) controllers existing on-chip were used. First, it was examined whether or not the execution state can be restored in the system in which the above-described method is implemented. A process of continuing output to the UART device was executed on the system, and the power was turned off. It was confirmed that when the power was turned on again and the system was restarted, the running process was restored and output to the UART device was started again.
Next, we investigated whether the proposed method was working properly. It was confirmed that the characters immediately before power off may be output from the UART device. This can be considered as a result of the appropriate re-execution of the request to the UART device. In addition, in order to check whether device access restoration and ISR state restoration are operating properly, a push button is attached to the highest level interrupt on the system, and this interrupt is assumed to be a virtual power off. The state was saved. This interrupt was generated while the system was running. After confirming the address when the interrupt occurred, the system was turned off once, and then the system was turned on again to restart the system. For both UART devices and Ethernet devices, even if an interrupt occurred during device access and ISR processing, it was confirmed that the processing that was being executed when the power was turned off continues. As a result, it can be considered that the return of access to the device and the ISR state restoration processing are appropriately performed.
And the overhead was measured by the proposed method on the implemented system. Two tasks were executed when the proposed method was not used (normal execution), when the checkpointing method was used for device access in the proposed method, and when the logging method was also used. Task A executed a process of repeating the operation of outputting one character to the UART device 10,000 times, and the execution time was measured by a time command. The UART baud rate setting is 9600 bps. Task B copied a 2Mbyte NFS file to the remote machine using the cp command. The copy destination was also on NFS. Each result is shown in FIG.
It can be seen that there is almost no increase in execution time when either the checkpointing method or the logging method is used for normal execution.

実施形態のハードウェアの構成例を示す図である。It is a figure which shows the structural example of the hardware of embodiment. 実施形態のソフトウェアの構成例を示す図である。It is a figure which shows the structural example of the software of embodiment. メッセージパッシング・システムでのモデルとリカバリラインを説明する図である。It is a figure explaining the model and recovery line in a message passing system. 基本的なデバイスへの要求発行処理を示す図である。It is a figure which shows the request issue process to a basic device. 要求に対応する割り込み処理を示す図である。It is a figure which shows the interruption process corresponding to a request | requirement. 外部イベントに対する割り込み処理を示す図である。It is a figure which shows the interruption process with respect to an external event. 共有領域のアクセスを含む処理を示す図である。It is a figure which shows the process including access of a shared area. 各実装手法による実行時間を比較するための図である。It is a figure for comparing the execution time by each mounting method.

Claims (2)

電源切断時のシステムの実行状態を復元できるコンピュータ・システムであって、
不揮発性メモリである主記憶と、
システム実行中に電源切断を検出して電源切断割り込みを発生する電源切断割り込み手段と、
前記電源切断割り込みにより、CPUの状態を保存するCPU状態保存手段と、
周辺デバイスへのアクセスごとにログをとるか、デバイスアクセス前にチェックポインティングを行うデバイスアクセス保存手段と、
デバイスへ発行された要求を保存するデバイス要求保存手段と、
電源が投入され、システムが立ち上がるときに、直前にシステム実行中に電源切断となったことを検出する直前電源切断検出手段と、
直前にシステム実行中に電源切断となったとき、前記デバイスアクセス保存手段およびデバイス要求保存手段により保存された情報により、周辺デバイス状態および該デバイスへのアクセス状態を復帰してCPUが復帰するポイントを決定する復帰手段と、
決定されたCPUの復帰ポイントからシステム実行を再開する実行再開手段と
を備えることを特徴とするコンピュータ・システム。
A computer system capable of restoring the running state of the system when the power is turned off,
A main memory which is a nonvolatile memory;
A power-off interrupt means for detecting power-off during system execution and generating a power-off interrupt;
CPU state storage means for storing the state of the CPU by the power-off interrupt;
Device access storage means to log every access to peripheral devices, or checkpoint before device access,
Device request storage means for storing a request issued to the device;
When power is turned on and the system starts up, immediately before power-off detection means for detecting that power was cut off during system execution immediately before,
When the power is cut off during system execution immediately before, the information stored by the device access storage means and the device request storage means restores the peripheral device state and the access state to the device and returns the point where the CPU returns. A return means to determine;
An execution restarting means for restarting the system execution from the determined return point of the CPU.
周辺デバイスへのアクセスごとにログをとるか、デバイスアクセス前にチェックポインティングを行うデバイスアクセス保存手段と、
デバイスへ発行された要求を保存するデバイス要求保存手段と、
直前にシステム実行中に電源切断となったとき、前記デバイスアクセス保存手段およびデバイス要求保存手段により保存された情報により、周辺デバイス状態および該デバイスへのアクセス状態を復帰してCPUが復帰するポイントを決定する復帰手段と
をコンピュータ・システムに構築させるプログラム。
Device access storage means to log every access to peripheral devices, or checkpoint before device access,
Device request storage means for storing a request issued to the device;
When the power is cut off during system execution immediately before, the information stored by the device access storage means and the device request storage means restores the peripheral device state and the access state to the device and returns the point where the CPU returns. A program that causes a computer system to construct a return means for determination.
JP2003336047A 2003-09-26 2003-09-26 Computer system which can restore execution state Pending JP2005107573A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2003336047A JP2005107573A (en) 2003-09-26 2003-09-26 Computer system which can restore execution state

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2003336047A JP2005107573A (en) 2003-09-26 2003-09-26 Computer system which can restore execution state

Publications (1)

Publication Number Publication Date
JP2005107573A true JP2005107573A (en) 2005-04-21

Family

ID=34532313

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2003336047A Pending JP2005107573A (en) 2003-09-26 2003-09-26 Computer system which can restore execution state

Country Status (1)

Country Link
JP (1) JP2005107573A (en)

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2009205502A (en) * 2008-02-28 2009-09-10 Nec Corp Application recorder/reproducer, method for rewinding application, and application recording/reproduction program
WO2010116405A1 (en) * 2009-04-06 2010-10-14 株式会社日立製作所 Calculation system provided with nonvolatile main memory
US7971014B2 (en) 2007-12-27 2011-06-28 Kabushiki Kaisha Toshiba Information processing apparatus and data recovering method
US8219767B2 (en) 2007-12-21 2012-07-10 Kabushiki Kaisha Toshiba Information processing apparatus and data recovering method
CN108664655A (en) * 2018-05-18 2018-10-16 上海赛治信息技术有限公司 The log storing method and system of embedded system

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8219767B2 (en) 2007-12-21 2012-07-10 Kabushiki Kaisha Toshiba Information processing apparatus and data recovering method
US7971014B2 (en) 2007-12-27 2011-06-28 Kabushiki Kaisha Toshiba Information processing apparatus and data recovering method
JP2009205502A (en) * 2008-02-28 2009-09-10 Nec Corp Application recorder/reproducer, method for rewinding application, and application recording/reproduction program
WO2010116405A1 (en) * 2009-04-06 2010-10-14 株式会社日立製作所 Calculation system provided with nonvolatile main memory
CN108664655A (en) * 2018-05-18 2018-10-16 上海赛治信息技术有限公司 The log storing method and system of embedded system

Similar Documents

Publication Publication Date Title
US10705741B1 (en) Transparent checkpointing and process migration in a distributed system
Scales et al. The design of a practical system for fault-tolerant virtual machines
US8990617B2 (en) Fault-tolerant computer system, fault-tolerant computer system control method and recording medium storing control program for fault-tolerant computer system
US9417965B2 (en) Low overhead fault tolerance through hybrid checkpointing and replay
CN101377750B (en) System and method for cluster fault toleration
EP2306318B1 (en) Enhanced solid-state drive management in high availability and virtualization contexts
US7941700B2 (en) Operating system-based application recovery
US8510597B2 (en) Providing restartable file systems within computing devices
US7516361B2 (en) Method for automatic checkpoint of system and application software
US7373530B2 (en) Systems and methods for providing power-loss protection to sleeping computers systems
US9329958B2 (en) Efficient incremental checkpointing of virtual devices
Lomet et al. Efficient transparent application recovery in client-server information systems
US9940152B2 (en) Methods and systems for integrating a volume shadow copy service (VSS) requester and/or a VSS provider with virtual volumes (VVOLS)
US10929234B2 (en) Application fault tolerance via battery-backed replication of volatile state
EP1329809B1 (en) Distributed computing system and method
Lorch et al. Tardigrade: Leveraging Lightweight Virtual Machines to Easily and Efficiently Construct {Fault-Tolerant} Services
EP1326160A1 (en) Data processing system and method
Baude et al. A hybrid message logging-cic protocol for constrained checkpointability
JP2005107573A (en) Computer system which can restore execution state
US8914680B2 (en) Resolution of system hang due to filesystem corruption
CN112286727B (en) Space-time isolation domain rapid recovery method and system based on incremental snapshot
CN114756355A (en) Method and device for automatically and quickly recovering process of computer operating system
Zhou et al. {RRC}: Responsive Replicated Containers
Shalev et al. Csr: Core surprise removal in commodity operating systems
Lee et al. Process resurrection: A fast recovery mechanism for real-time embedded systems