intel 386 Interrupt and Exceptions
1. 386프로세서의 인터럽트 동작 요약 & 정리
Interrupts
Interrupts alter the normal program flow, in order to handle external events, to report errors or exceptional conditions. Interrupts are used to handle asynchronous external events. Exceptions handle instruction faults.
In Intel 386 DX, Interrupts are externally-generated events, and exceptions are defined internally-generated events.
The Intel 386 DX has the ability to handle up to 256 different interrupts/exceptions. In order to handle the interrupts, a table with up to 256 interrupts vectors must be defined. The interrupt vectors are simply pointers to the appropriate interrupt service routine(ISR).
Interrupts types
Hardware interrupts occur as the result of an external event and are classified into two types.
1) maskable (Maskable interrupts, which are signalled via the INTR pin.)
2) non-maskable (Nonmaskable interrupts, which are signalled via the NMI (Non-Maskable Interrupt) pin.)
A maskable interrupt may not be interrupted while
performing some crucial task.
Non-maskable interrupts are, likewise, those which can (and should) not be
ignored. So events like critical hardware failure and system resets are
attached to non-maskable interrupts to ensure that there's a "way
out".
So Non-maskable interrupts provide a method of servicing very high priority interrupts.
The software interrupt is a third type of interrupt for Intel386 DX.
Interrupt Processing
First, the current program address and the Flags are saved on the stack to allow resumption of the interrupted program. Next, an 8-bit vector is supplied to the intel386 DX which identifies the appropriate entry in the interrupt table. The table contains the starting address of the interrupt service routine. Then, the user supplied interrupt service routine is executed. Finally, when an IRET(interrupt return) instruction is executed the old processor state is restored and program execution resumes at the appropriate instruction.
When NMI and maskable INTR are both recognized at the same instruction boundary, the intel 386 DX invokes the NMI service routine first.
인터럽트(Interrupt)는 프로그램 실행 중 발생하면 일단 프로그램을 멈추고 상태 레지스터와 PC(program Counter)등을 스택에 잠시 저장한 후 인터럽트 서비스 루틴(interrupt service routine)으로 점프한다. 그리고 인터럽트를 처리하고 다시 복귀주소로 돌아와서 중단하였던 프로그램을 이어서 수행한다.
두 가지 이상의 인터럽트가 동시에 발생하면 정해놓은 인터럽트 우선순위에 따라 처리되며 인터럽트넘버(interrupt number)가 작을수록 우선순위가 높다. 또한 non-maskable interrupt와 maskable intrrupts가 동시에 발생하면 NMI(non-maskable interrupt)가 우선하여 처리되고 그 이후에 INTR(maskable interrupt)가 처리된다.
2. 386 프로세서의 보호기능 요약 & 정리
Protection
The Intel 386 DX has four levels of protection which are optimized to support the needs of a multi-tasking operating system to isolate and protect user programs from each other and the operating system. And also offers an additional type of protection on a page basis, when paging is enabled.
Real-mode does not include support for protection and therefore cannot offer a secure and reliable execution environment. Buggy and hostile applications can shake the operating system integrity by overwriting various system data structures. When applied, protection can guard against software bugs and help the operating system in performing reliable multitasking.
보호 모드는 시스템 소프트웨어가 다중 작업, 가상 메모리, 페이징, 그리고 응용 소프트웨어를 넘는 운영 체제 제어 능력을 높이기 위해 고안된 운영 체제의 다른 기능들을 이용할 수 있게 도와준다. 보호 모드에서는 0(가장 높은 수준)부터 3(가장 낮은 수준)까지의 4가지 권한 수준이 있다. 이러한 권한 수준은 링(ring)이라고도 불리며 이를 사용함으로써 시스템 소프트웨어가 데이터 접근, 콜 게이트, 권한 기능 실행에 대한 제한을 허용한다. 운영 체제와 몇 가지 장치 드라이버는 링 0에서 동작하며, 응용 프로그램은 링 3에서 동작한다.