KR100506254B1 - Apparatus and method for handling interrupt in non-privileged of embedded system - Google Patents

Apparatus and method for handling interrupt in non-privileged of embedded system Download PDF

Info

Publication number
KR100506254B1
KR100506254B1 KR10-2003-0083060A KR20030083060A KR100506254B1 KR 100506254 B1 KR100506254 B1 KR 100506254B1 KR 20030083060 A KR20030083060 A KR 20030083060A KR 100506254 B1 KR100506254 B1 KR 100506254B1
Authority
KR
South Korea
Prior art keywords
interrupt
isr
cache
service routine
privileged
Prior art date
Application number
KR10-2003-0083060A
Other languages
Korean (ko)
Other versions
KR20050049170A (en
Inventor
정재용
Original Assignee
삼성전자주식회사
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 삼성전자주식회사 filed Critical 삼성전자주식회사
Priority to KR10-2003-0083060A priority Critical patent/KR100506254B1/en
Publication of KR20050049170A publication Critical patent/KR20050049170A/en
Application granted granted Critical
Publication of KR100506254B1 publication Critical patent/KR100506254B1/en

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/30Arrangements for executing machine instructions, e.g. instruction decode
    • G06F9/32Address formation of the next instruction, e.g. by incrementing the instruction counter
    • G06F9/322Address formation of the next instruction, e.g. by incrementing the instruction counter for non-sequential address
    • G06F9/327Address formation of the next instruction, e.g. by incrementing the instruction counter for non-sequential address for interrupts
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/22Microcontrol or microprogram arrangements
    • G06F9/26Address formation of the next micro-instruction ; Microprogram storage or retrieval arrangements
    • G06F9/262Arrangements for next microinstruction selection
    • G06F9/268Microinstruction selection not based on processing results, e.g. interrupt, patch, first cycle store, diagnostic programs
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2213/00Indexing scheme relating to interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
    • G06F2213/24Interrupt
    • G06F2213/2414Routing of interrupt among interrupt handlers in processor system or interrupt controller

Abstract

본 발명은 특권 모드와 비특권 모드의 서로 다른 수행 모드를 제공하는 운영 체제를 구비한 시스템에서 인터럽트를 처리하기 위한 방법에 있어서, 상기 비특권 모드에서 동작하는 임의의 프로세스로에서 소정의 인터럽트를 처리하기 위한 인터럽트 서비스 루틴(ISR)을 등록하는 과정과, 상기 인터럽트 서비스 루틴(ISR)에 대응되는 인터럽트 발생시 이전 프로세스 작업을 일시 중지하고 상기 등록된 인터럽트 서비스 루틴(ISR)을 수행하도록 하는 과정을 포함함을 특징으로 한다.The present invention provides a method for handling interrupts in a system having an operating system that provides a different execution mode of privileged and non-privileged modes, wherein the processor processes certain interrupts in any process operating in the non-privileged mode. And registering an interrupt service routine (ISR) for performing the step, and suspending a previous process task and performing the registered interrupt service routine (ISR) when an interrupt corresponding to the interrupt service routine (ISR) occurs. It is characterized by.

Description

임베디드 시스템의 비특권 모드에서 인터럽트 처리를 위한 장치 및 방법{APPARATUS AND METHOD FOR HANDLING INTERRUPT IN NON-PRIVILEGED OF EMBEDDED SYSTEM} Apparatus and method for interrupt handling in non-privileged mode of embedded system {APPARATUS AND METHOD FOR HANDLING INTERRUPT IN NON-PRIVILEGED OF EMBEDDED SYSTEM}

본 발명은 임베디드 시스템(embedded system)에서 인터럽트(interrupt)를 처리하기 위한 장치 및 방법에 관한 것으로, 특히 특권 모드와 비특권 모드의 서로 다른 수행 모드를 제공하는 운영 체제를 구비한 시스템에서 인터럽트를 처리하기 위한 장치 및 방법에 관한 것이다.The present invention relates to an apparatus and method for handling interrupts in an embedded system, and more particularly to an interrupt handling in a system having an operating system that provides different modes of execution of privileged and non-privileged modes. An apparatus and method for

임베디드 시스템은 일반적으로 특별한 업무를 수행하기 위한 하드웨어와 소프트웨어를 포함하는 특정한 응용 시스템이라고 할 수 있다. 이러한 임베디드 운영 체제(OS: Operating System, 이하 'OS'라 칭하기로 한다) 개발이 최근들어 활발해지고 있다. 그 이유는 임베디드 OS가 아니고서는 새롭게 생겨나는 기능적 요구 사항이나 고품질의 창조형 서비스들을 제때에 제공할 수가 없다. 지금까지는 자체적으로 개발된 OS라고 할 수 없는 모니터 프로그램 또는 제어 프로그램을 가지고도 임베디드 시스템을 얼마든지 제어할 수 있었다. 하지만, 상기 임베디드 OS에 대한 요구가 급증하는 이유는 기존의 프로그램을 가지고는 급격한 기술 진보와 인터넷 기반의 정보화 사회 체제에서 새롭게 발생되는 기능적 요구 사항이라든가 창조형 서비스를 원하는 시간에 제공할 수 없기 때문이다.Embedded systems are generally specific application systems that include hardware and software for performing specific tasks. Development of such an embedded operating system (OS) (hereinafter, referred to as 'OS') has been actively developed in recent years. The reason is that without an embedded OS, new functional requirements or high-quality creative services cannot be delivered on time. Until now, the embedded system was able to be controlled with a monitor program or a control program, which is not an OS developed by itself. However, the demand for the embedded OS is rapidly increasing because existing programs cannot provide rapid technical advances and newly generated functional requirements or creative services in the desired time with the Internet-based information society. .

이러한 임베디드 운영 체제는 윈도우(window) OS, 자바(java) OS등이 있으며, 대표적으로 리눅스(linux) OS가 있다. 하기에서는 상기 리눅스 OS를 실시예로 들어 설명하기로 한다. 상기 OS는 모든 컴퓨터 시스템에 내장된 기본적인 프로그램 집합이며, 이 중에서 가장 중요한 프로그램을 커널(kernel)이라고 한다. 상기 커널은 시스템을 부팅할 때 램(Random Access Memory)으로 로드(load)되며 시스템이 동작하는데 필요한 여러 절차를 포함한다. 그러므로, OS와 커널은 같은 의미로 사용되도 무방할 것이다. 상기 리눅스 OS는 컴퓨터의 물리적인 구조와 관련된 세부 내용을 사용자가 실행하는 응용 프로그램에게 숨긴다. 그래서 프로그램이 하드웨어 장치를 이용하려면 반드시 OS에게 요청해야 한다. 상기 OS는 상기 요청에 대한 판단을 하고 요청을 허용하기로 결정하면 사용자 프로그램을 대신하여 관련된 하드웨어 구성 요소와 상호 작용한다. 이러한 절차를 수행하기 위해 상기 OS는 임의의 프로그램이 하드웨어 구성 요소와 직접 상호 작용을 하거나 임의의 메모리 위치에 접근하는 것을 막기 위해 사용자 프로그램을 위한 비특권 모드(non-privileged mode)와 OS를 위한 특권 모드(privileged mode)라는 서로 다른 실행 모드를 제공한다. 상기 비특권 모드는 사용자 모드라고도 하고 상기 특권 모드는 커널 모드 혹은 OS 모드라고도 지칭한다.Such embedded operating systems include a Windows OS, a Java OS, and the like, and a Linux OS. In the following description, the Linux OS will be described as an embodiment. The OS is a basic set of programs embedded in all computer systems, the most important of which is called a kernel. The kernel is loaded into random access memory (RAM) when the system is booted and contains various procedures necessary for the system to operate. Therefore, the OS and the kernel may be used in the same sense. The Linux OS hides details related to the physical structure of the computer from the application running by the user. So the program must ask the OS to use the hardware device. The OS makes a decision on the request and decides to allow the request to interact with the associated hardware component on behalf of the user program. In order to carry out this procedure, the OS may use a non-privileged mode for the user program and a privilege for the OS to prevent any program from directly interacting with hardware components or accessing any memory location. It offers a different execution mode called privileged mode. The non-privileged mode is also referred to as user mode and the privileged mode is also referred to as kernel mode or OS mode.

먼저, 특권 모드는 중요한 자료구조나 직접적인 하드웨어 접근(I/O 혹은 memory mapped), 직접적인 메모리 접근(DMA: Direct Memory Access), 인터럽트 요청(IRQ: InterRupt reQuest)등의 처리를 수행하며, 비특권 모드는 사용자가 응용 프로그램을 실행할 수 있도록 한다. 일반적으로 상기 모드간의 전환이 일어나는 경우는 하기의 2가지 경우이다. First, Privileged Mode handles critical data structures, direct hardware access (I / O or memory mapped), direct memory access (DMA), and InterRupt reQuest (IRQ). Allows the user to run the application. In general, there are two cases of switching between the modes.

1. 시스템 콜(system call)을 호출했을 때: 시스템 콜을 호출한 이후에, 프로세스는 자동적으로 특권 모드에 있는 코드를 호출한다. 1. Calling a system call: After calling a system call, the process automatically calls code in privileged mode.

2. IRQ가 발생했을 때: 인터럽트 요청(InterRupt reQuest: IRQ)이 발생한 후에, 인터럽트 핸들러가 호출되고, 인터럽트 처리가 끝나면 제어경로는 비특권 모드의 프로세스로 돌아간다. 2. When an IRQ occurs: After the InterRupt reQuest (IRQ) occurs, the interrupt handler is called, and when the interrupt processing is complete, the control path returns to the nonprivileged mode.

여기서, 상기 인터럽트(interrupt)는 컴퓨터에 장착된 장치 또는 컴퓨터 내의 프로그램으로부터 오는 신호로서 OS가 하던 일을 멈추고 다음에 무엇을 할 것인지를 결정하게 한다. 상기 OS가 임의의 신호에 대해서 상기 인터럽트 신호를 인식하는 경우는 다음과 같다.Here, the interrupt is a signal coming from a device mounted on the computer or a program in the computer that allows the OS to stop doing what it is supposed to do next. The OS recognizes the interrupt signal for any signal as follows.

1. 프로세스가 시스템 콜을 호출한 경우1. The process called a system call.

2. 프로세스를 실행하던 CPU가 예외(exception)를 발생한 경우로 이는 잘못된 명령어 실행처럼 비정상적인 상황을 의미한다. 커널은 예외가 발생한 프로세스를 대신하여 예외 핸들러를 처리한다.2. The CPU that is executing the process throws an exception, which is an abnormal situation such as incorrect instruction execution. The kernel handles the exception handler on behalf of the process that caused the exception.

3. 주변 장치(peripheral device)는 상태 변경, 입출력 동작이 완료된 것 같은 사건을 알려주기 위해 CPU에게 인터럽트 시그널을 송신한다. 상기 인트럽트 시그널은 인터럽트 핸들러(interrupt handler)라는 커널 프로그램에서 다룬다. 상기 주변 장치는 CPU와는 다르게 비동기적으로 동작하므로 예상치 못한 시기에 인터럽트가 발생한다.3. The peripheral device sends an interrupt signal to the CPU to signal an event that the state has changed, or that the I / O operation has completed. The interrupt signal is handled in a kernel program called an interrupt handler. Unlike the CPU, the peripheral device asynchronously generates an interrupt at an unexpected time.

4. 커널안의 흐름을 제어하는 경우4. Controlling Flow in the Kernel

이러한 각 경우에 해당될 때 상기 인터럽트 신호를 감지한 OS는 실행되고 있던 프로그램을 재개하거나, 또는 다른 프로그램의 실행을 시작한다. 여기서, 유니 프로세서(uniprocessor) 시스템은 한 프로세스만이 CPU를 점유하는 시스템을 의미한다. 때문에 상기 CPU는 각각의 수행 작업들에 대해 하나씩만 진행할 수 있다. 그러나, 인터럽트 신호가 있기 때문에 다른 프로그램이나 명령문을 수행할 수 있는 순서를 가질 수 있는데 이렇게 하는 것을 멀티태스킹(multitasking)이라고 한다. 상기 멀티태스킹은 사용자로 하여금 동시에 여러 개의 작업을 할 수 있도록 해준다. 상기 OS는 사용자가 효과적으로 일을 할 수 있도록 단순히 그 프로그램들이 수행될 순서를 관리한다. 물론, 컴퓨터는 사용자의 모든 작업들이 동시에 수행되는 것처럼 보이게 빠른 속도로 동작한다. 또한, 상기 OS는 대개 상기 인터럽트 관리 기능을 가지고 있다. 상기 인터럽트 관리 기능을 하는 인터럽트 관리 장치는 하나 이상의 인터럽트가 처리되어야 하는 경우에 인터럽트들 간의 우선 순위를 정하고 그들을 큐(queue)에 저장한다. 상기 큐는 데이터가 들어간 순서대로 제거되는 자료구조를 말한다. 또한, 상기 운영체제는 스케줄러(scheduler)라고 불리는 또 다른 작은 프로그램을 가지고 있어 다음 번에 수행되어야 할 프로그램에게 제어권을 넘겨준다.In each of these cases, the OS detecting the interrupt signal resumes the program being executed or starts execution of another program. Here, the uniprocessor system refers to a system in which only one process occupies the CPU. Because of this, the CPU can proceed only one for each performed task. However, because of the interrupt signal, you can have an order in which other programs or statements can be executed. This is called multitasking. The multitasking allows the user to do several tasks at the same time. The OS simply manages the order in which the programs are to be executed so that the user can work effectively. Of course, the computer runs at a high speed so that all of the user's tasks appear to be performed simultaneously. In addition, the OS usually has the interrupt management function. The interrupt management device, which serves as the interrupt management function, prioritizes interrupts and stores them in a queue when one or more interrupts are to be processed. The queue refers to a data structure that is removed in the order in which data is entered. The operating system also has another small program called a scheduler, which gives control to the next program to be executed.

상술한 바와 같이, 하드웨어 자원에서 발생하는 인터럽트가 발생할 경우 상기 특권 모드에 존재하는 인터럽트 서비스 루틴(ISR: Interrupt service routine, 이하 'ISR' 이라 칭하기로 한다)이 상기 인터럽트를 수신하여 처리한다. 또한, 비특권 모드는 특권 모드에서 실행할 수 있는 중앙 처리 장치(CPU: Central Processing Unit, 이하 'CPU'라 칭하기로 한다) 명령을 실행할 수 없다. 이하 도 1을 참조하여 종래에 인터럽트가 특권 모드와 비특권 모드에서 처리되는 과정을 설명하기로 한다.As described above, when an interrupt generated from a hardware resource occurs, an interrupt service routine (ISR), which is present in the privileged mode, receives and processes the interrupt. In addition, the non-privileged mode cannot execute a central processing unit (CPU) instruction that can be executed in the privileged mode. Hereinafter, a process in which an interrupt is processed in a privileged mode and a non-privileged mode will be described with reference to FIG. 1.

도 1은 종래의 특권 모드에서 인터럽트 처리를 도시한 도면이다.1 is a diagram illustrating interrupt processing in a conventional privileged mode.

설명에 앞서, 모든 OS는 기본적으로 추상 개념인 프로세스(process)를 활용한다. 상기 프로세스는 '실행 상태에 있는 프로그램의 인스턴스(instance)' 또는 실행하고 있는 프로그램의 '실행 컨텍스트(context)'라는 말로 정의할 수 있다. 따라서, 하나의 사용자 프로그램이 하나의 프로세스라고 혼용되어도 무방하므로 하기에서는 사용자 프로그램과 프로세스를 특별한 구분없이 프로세스로 명명한다.Prior to the discussion, all operating systems utilize a process, which is basically an abstract concept. The process may be defined as an instance of a program in an execution state or an execution context of a running program. Therefore, since one user program may be mixed with one process, the following describes a user program and a process as a process without particular distinction.

상기 도 1을 참조하면, 먼저 소프트웨어적인 측면의 비특권 모드에서 수행되는 프로세스는 제 1 프로세스(102)와 제 2 프로세스(104)가 존재하며, 특권 모드는 상기 모드에서 수행되는 ISR(108)을 포함한다. 한편 하드웨어적인 측면에서 인터럽트를 요청하는 하드웨어 장치1(126), 2(110), 3(128)이 존재한다. 상기 하드웨어 장치들은 네트워크 장치, 키보드, 마우스등의 입출력 장치가 될 수 있다.Referring to FIG. 1, first, a process performed in a non-privileged mode in terms of software includes a first process 102 and a second process 104, and a privileged mode identifies an ISR 108 performed in the mode. Include. On the other hand, there are hardware devices 1 126, 2 110, and 3 128 that request interrupts in terms of hardware. The hardware devices may be input / output devices such as a network device, a keyboard, and a mouse.

상기 제 1프로세스(102)가 하드웨어 장치 2(110)에 대한 작업을 요청하면 112와 같이 특권 모드로 모드 천이가 발생한다. 상기 특권 모드의 OS는 112에 대한 작업 요청을 대행하고 작업이 완료될 때까지 기다린다. 이 때, 상기 특권 모드의 OS는 CPU 자원을 자원을 낭비하지 않기 위해 제 2프로세스(104)가 실행될 수 있도록 114의 모드 천이를 발생한다. 상기 하드웨어 장치 2(104)가 작업을 완료하면 작업 완료 신호 116의 인터럽트를 발생시키고 동시에 118의 모드 천이를 발생시켜 ISR(108)을 수행하도록 한다. 상기 ISR(108)은 하드웨어 장치 2(110)의 작업 완료 이벤트를 제 1프로세스(102)에 알리는 처리를 한다. 만약 상기 제 2프로세스(104)가 제 1프로세스(102)보다 실행 우선 순위가 높으면 12의 모드 천이를 발생시켜 제 2프로세스(104)가 CPU를 점유하고, 상기 제 1프로세스(102)는 상기 제 2프로세스 (104)의 CPU 할당 시간이 종료되면 122, 124의 모드 천이후에 작업을 수행한다. 여기서 상기 제 1프로세스(102)가 제 2프로세스(104)보다 우선 순위가 높은 경우 상기 ISR의 수행을 완료시 124의 모드 천이를 통해 상기 제 1프로세스(102)을 수행한다.When the first process 102 requests the operation of the hardware device 2 (110), a mode transition occurs in the privileged mode as shown in 112. The OS in the privileged mode acts for the work request for 112 and waits for the work to complete. At this time, the OS in the privileged mode generates a mode transition of 114 so that the second process 104 can be executed in order not to waste CPU resources. When the hardware device 2 104 completes the task, it generates an interrupt of the task completion signal 116 and simultaneously generates a mode transition of 118 to perform the ISR 108. The ISR 108 performs a process of notifying the first process 102 of a task completion event of the hardware device 2 110. If the second process 104 has a higher execution priority than the first process 102, the second process 104 occupies the CPU, and the first process 102 occupies the CPU. When the CPU allocation time of the two processes 104 ends, the operation is performed after the mode transitions of 122 and 124. Here, when the first process 102 has a higher priority than the second process 104, the first process 102 is performed through a mode transition of 124 when the ISR is completed.

다음으로 도 2를 참조하여 상기 인터럽트를 수행하는 CPU 내부와 메모리 구조를 설명하기로 한다.Next, the internal CPU and the memory structure for performing the interrupt will be described with reference to FIG. 2.

도 2는 종래의 인터럽트 처리를 위한 CPU 및 주기억 장치의 구조를 도시한 도면이다.2 is a diagram illustrating the structure of a CPU and a main memory device for conventional interrupt processing.

먼저, 상기 CPU(200)는 CPU 명령을 메모리 또는 캐쉬에서 읽어와서 파악하는 명령 판독기(203)와, CPU의 임시 기억 장치인 레지스터(register)(206)와, 상기 레지스터를 구성하는 일반 레지스터(204) 및 가상 주소(virtual address)를 물리 주소(physical address)로 변환시 사용하는 페이지 디렉토리(page directory)(205)와, 데이터 연산을 수행하는 산술 논리 연산기(209)와, CPU 명령을 임시 저장하는명령 캐쉬(212)와, CPU 전반적 제어를 담당하는 제어기(215)와, 데이터 임시 저장 장소인 데이터 캐쉬(218) 영역으로 구성된다. 한편, 주기억 장치(250)는 프로그래밍(programming)에 의해 여러 필드(field)로 나뉘어 질 수 있으며 ISR0(253), ISR1(256) 내지 ISRn은 인터럽트 벡터를 나타낸다. 221은 인터럽트가 외부로부터 발생됨을 알리는 신호이며 메모리 버스(memory bus)(224)는 CPU와 주기억장치를 연결하는 통로이다. First, the CPU 200 includes an instruction reader 203 for reading CPU instructions from a memory or cache, a register 206 which is a temporary storage device of the CPU, and a general register 204 constituting the register. ), A page directory 205 used for converting a virtual address into a physical address, an arithmetic logic operator 209 for performing data operations, and instructions for temporarily storing CPU instructions. The cache 212, the controller 215 responsible for overall CPU control, and the data cache 218 area that is a temporary data storage area. Meanwhile, the main memory device 250 may be divided into several fields by programming, and ISR0 253, ISR1 256, and ISRn represent an interrupt vector. 221 is a signal indicating that an interrupt is generated from the outside, and a memory bus 224 is a path connecting the CPU and the main memory.

여기서, 상기 인터럽트 벡터는 ISR의 시작 주소를 인터럽트 번호에 따라 배열로 저장한 자료 구조이다. 예컨대, 인터럽트 0이 발생할 경우 CPU는 현재 수행중인 명령을 완료한 후, 일반 레지스터(204)에 현재 상태를 저장하고 ISR0(253)으로 문맥 전환(context switching)하여 ISR을 수행한다. 상기에서 문맥 전환은 스케줄링에 따라 실행 중인 프로세스를 교체할 때, 교체되는 프로세스의 상태를 기억시켜두고 새로운 프로세스의 이전 실행 상태를 재복구하여 처리기에 넘겨주는 일련의 작업이라 할 수 있다. 즉, 상기 도 1을 참조하면 상기 문맥 전환은 특권 모드와 비특권 모드간에 이루어지는 작업 수행을 문맥 전환이라 할 수 있다.Here, the interrupt vector is a data structure in which the start address of the ISR is stored in an array according to the interrupt number. For example, when an interrupt 0 occurs, the CPU completes an instruction currently being executed, stores the current state in the general register 204, and performs context switching to ISR0 253 to perform ISR. In the above context switching is a series of tasks that, when a running process is replaced according to a scheduling, memorizes the state of the replaced process, restores the previous execution state of the new process, and passes it to the processor. That is, referring to FIG. 1, the context switch may be referred to as performing a task performed between a privileged mode and a non-privileged mode.

상기 도 2에서 CPU(200)가 외부(external) 인터럽트(221) 발생을 감지하면 CPU의 인터럽트 핀(pin)으로 입력되어 제어기(215)로 전달된다. 상기 제어기(215)는 기존에 수행하고 있던 작업을 중단하고 그에 대한 정보를 일반 레지스터(204)에 저장하도록 제어한다. 이후 명령 판독기(203)는 인터럽트 요청 장치를 판별하여 인터럽트 핸들러(handler)로의 문맥 전환 후 주기억 장치내의 ISR을 수행한다. 상기 제어기(215)는 인터럽트 수행 종료를 감지하면 중단된 작업에 대한 정보를 레지스터에서 읽어와서 작업을 재개한다. 상기에서 임시 저장 영역은 레지스터와 캐쉬로 나뉘어지는데 상기 캐쉬 메모리는 기억장치 계층에 있어 주기억 장치(250)와 CPU(200)사이에 삽입된 메모리이며, CPU의 처리 속도를 개선하는 역할을 한다. 또한 캐쉬(cache)는 주기억 장치중의 데이터가 CPU에 의해 한번 사용된 후, 다시 사용될 것을 예상해서 그 사본을 캐쉬 메모리에 남겨 두는 작업을 한다. 상기 명령 캐쉬(212)와 데이터 캐쉬(218)는 CPU에 따라 상기와 같이 분리되지 않고 하나의 캐쉬로 구성될 수도 있다.In FIG. 2, when the CPU 200 detects the occurrence of an external interrupt 221, the CPU 200 is input to an interrupt pin of the CPU and transferred to the controller 215. The controller 215 interrupts the existing work and controls the information to be stored in the general register 204. The command reader 203 then determines the interrupt request device and performs ISR in the main memory device after the context switch to the interrupt handler. When the controller 215 detects the end of interrupt execution, the controller 215 reads information about the interrupted task from the register and resumes the task. The temporary storage area is divided into a register and a cache. The cache memory is a memory inserted between the main memory 250 and the CPU 200 in the storage hierarchy, and improves the processing speed of the CPU. The cache also works by leaving the copy in cache memory in anticipation that the data in the main memory will be used once by the CPU and then used again. The instruction cache 212 and the data cache 218 may be configured as one cache without being separated according to the CPU as described above.

상술한 바와 같이, 상기 임베디드 시스템(embedded system) 및 실시간 시스템(real time system)은 외부 이벤트(event)에 대해 신속하게 반응할 필요가 있기 때문에 인터럽트가 발생시 신속한 처리가 시스템 전체 성능을 좌우한다. 또한, 상기 시스템들은 외부 이벤트의 처리 방법과 필요한 자료 구조를 사용자 프로세스가 관리하는 경우가 대부분이기 때문에 OS에 내장된 ISR에서 인터럽트를 처리할 경우 ISR이 외부 이벤트를 처리하기보다 단순히 외부 이벤트를 사용자 프로세스에게 전달하는 것에 불과할 경우가 많다. 상기 경우 사용자 프로세스가 직접 인터럽트를 수신하여 처리하는 경우보다 처리 시간이 지연된다. As described above, the embedded system and the real time system need to react quickly to external events, so rapid processing in the event of an interruption determines the overall performance of the system. In addition, since the system processes the external event processing method and the required data structure, most of the systems manage the external event rather than simply processing the external event when the ISR processes the interrupt. It is often just to pass on. In this case, the processing time is delayed than when the user process directly receives and processes the interrupt.

또한, 상기 특권 모드와 비특권 모드를 나눈 시스템에서 CPU가 인터럽트 발생을 감지하면 특권 모드로 천이후에 인터럽트 벡터내의 해당 인터럽트 번호에 해당하는 ISR을 실행한다. 이렇게 상기 특권 모드와 비특권 모드로 시스템을 구분하는 이유는 사용자 프로세스가 잘못된 오작동 또는 실행으로 인한 시스템의 붕괴를 방지하기 위한 것이지만 상술한 바와 같은 외부 이벤트에 대한 신속한 처리가 필요할 경우에는 시스템 성능 저하의 원인을 초래하는 문제점이 존재한다.In addition, when the CPU detects the occurrence of an interrupt in the system that divides the privileged mode and the non-privileged mode, an ISR corresponding to the corresponding interrupt number in the interrupt vector is executed after the transition to the privileged mode. The reason for distinguishing the system into the privileged mode and the non-privileged mode is to prevent the system from collapsing due to an incorrect malfunction or execution of a user process. However, when the rapid processing of external events as described above is required, There is a problem that causes the cause.

따라서 본 발명의 목적은 임베디드 시스템(embedded system)의 비특권 모드에서 ISR을 수행하기 위한 장치 및 방법을 제공함에 있다.Accordingly, an object of the present invention is to provide an apparatus and method for performing ISR in a non-privileged mode of an embedded system.

본 발명의 다른 목적은 임베디스 시스템의 비특권 모드에서 ISR을 수행함으로써 신속하고 효율적으로 인터럽트를 처리하는 장치 및 방법을 제공함에 있다.Another object of the present invention is to provide an apparatus and method for handling interrupts quickly and efficiently by performing ISR in a non-privileged mode of an embedded system.

상기한 목적들을 달성하기 위한 본 발명의 방법은 특권 모드와 비특권 모드의 서로 다른 수행 모드를 제공하는 운영 체제를 구비한 시스템에서 인터럽트를 처리하기 위한 방법에 있어서, 상기 비특권 모드에서 동작하는 임의의 프로세스로에서 소정의 인터럽트를 처리하기 위한 인터럽트 서비스 루틴(ISR)을 등록하는 과정과, 상기 인터럽트 서비스 루틴(ISR)에 대응되는 인터럽트 발생시 이전 프로세스 작업을 일시 중지하고 상기 등록된 인터럽트 서비스 루틴(ISR)을 수행하도록 하는 과정을 포함함을 특징으로 한다.A method of the present invention for achieving the above objects is a method for handling an interrupt in a system having an operating system that provides different modes of execution of privileged and non-privileged modes, wherein any of the operating in the non-privileged mode is performed. Registering an interrupt service routine (ISR) for processing a predetermined interrupt in a process furnace, suspending a previous process operation when an interrupt corresponding to the interrupt service routine (ISR) occurs, and registering the interrupt service routine (ISR). It is characterized in that it comprises a process to perform the).

상기한 목적들을 달성하기 위한 본 발명의 장치는 특권 모드와 비특권 모드의 서로 다른 수행 모드를 제공하는 운영 체제를 구비한 시스템에서 인터럽트를 처리하기 위한 장치에 있어서, 소정의 인터럽트를 처리하기 위한 인터럽트 서비스 루틴(ISR)을 등록케하여 상기 인터럽트 서비스 루틴(ISR)에 대응되는 인터럽트 발생시 이전 프로세스 작업을 일시 중지하고 상기 등록된 인터럽트 서비스 루틴(ISR)을 수행하도록 하는 제어기와, 상기 ISR 등록 요청에 따라 인터럽트 벡터에 상기 ISR 등록 정보를 저장하는 주기억 장치와, 상기 ISR 수행시 인터럽트 처리 정보를 임시 저장하는 인터럽트용 임시 기억 장치를 포함함을 특징으로 한다. An apparatus of the present invention for achieving the above objects is an apparatus for processing an interrupt in a system having an operating system providing different modes of execution of privileged and non-privileged modes, the interrupt for processing a predetermined interrupt A controller for registering a service routine (ISR) to suspend a previous process operation and to perform the registered interrupt service routine (ISR) when an interrupt corresponding to the interrupt service routine (ISR) occurs, according to the ISR registration request; And a main memory device for storing the ISR registration information in an interrupt vector, and an interrupt temporary memory device for temporarily storing interrupt processing information when performing the ISR.

이하, 본 발명에 따른 바람직한 실시예를 첨부한 도면을 참조하여 상세히 설명한다. 하기의 설명에서는 본 발명에 따른 동작을 이해하는데 필요한 부분만이 설명되며 그 이외 부분의 설명은 본 발명의 요지를 흩트리지 않도록 생략될 것이라는 것을 유의하여야 한다.Hereinafter, exemplary embodiments of the present invention will be described in detail with reference to the accompanying drawings. It should be noted that in the following description, only parts necessary for understanding the operation according to the present invention will be described, and descriptions of other parts will be omitted so as not to distract from the gist of the present invention.

설명에 앞서, 문맥 전환(context switching) 또는 모드 천이는 하나의 프로세스에서 다른 프로세스로 수행이 전환될 때를 의미하며 운영 체제는 상기 문맥 전환 되는 프로세스가 이후에 다시 수행될 때 필요로 하는 레지스터 정보 및 메모리 사용 정보를 저장해야 된다. Prior to the description, context switching or mode transition means when execution is switched from one process to another, and the operating system is responsible for registering register information that is needed when the context switched process is subsequently performed again. Memory usage information must be stored.

도 3은 본 발명의 실시예에 따른 비특권 모드의 프로세서에서 인터럽트 처리를 도시한 도면이다.3 is a diagram illustrating interrupt processing in a processor in a non-privileged mode according to an embodiment of the present invention.

상기 도 3을 참조하면, 중앙 처리 장치(CPU: Central Processing Unit, 이하 'CPU'라 칭하기로 한다)내에서 제 1프로세서(302), 제 2프로세스(304)는 비특권 모드(non-privileged mode)에서 동작하며, 운영 체제(Operating System, 이하 'OS'라 칭하기로 한다)(308)는 특권 모드(privileged mode)에서 동작한다. 인터럽트 서비스 루틴(ISR: Interrupt Servic Routine, 이하 'ISR'이라 칭하기로 한다)(306)은 발생하는 인터럽트를 처리하는 작업을 수행하며 도 3의 경우 상기 ISR은 제 1프로세스에서 OS에 등록을 요청하고 OS의 판단 결과에 따라 등록 요청이 허가되면 상기 제 1프로세스에서 인터럽트 처리를 수행한다. 상기 제 1프로세스이 ISR 등록을 요청하는 과정은 후기될 도 5를 참조하여 상세히 설명하기로한다. 다음으로 하드웨어 장치 2(310)가 인터럽트를 발생하였을 때 CPU에서 처리하는 과정을 살펴보기로 한다.Referring to FIG. 3, the first processor 302 and the second process 304 in a central processing unit (CPU) are referred to as a non-privileged mode. The operating system (hereinafter referred to as 'OS') 308 operates in a privileged mode. Interrupt Service Routine (ISR) (hereinafter referred to as 'ISR') 306 performs an operation for processing an interrupt that occurs. In FIG. 3, the ISR requests registration with the OS in a first process. If the registration request is permitted according to the determination result of the OS, the first process performs an interrupt process. A process of requesting the ISR registration by the first process will be described in detail with reference to FIG. 5 to be described later. Next, a process of processing by the CPU when the hardware device 2 310 generates an interrupt will be described.

상기 도 3에서 제 2프로세스는 제 1프로세스보다 우선 순위가 높은 프로세스이며 상기 제 1프로세스은 ISR 등록을 완료한 상태라고 가정한다. 상기 제 2프로세스가 비특권 모드에서 실행되던 중에 상기 하드웨어 장치 2(310)가 인터럽트를 요청(316)하면 상기 ISR(306)을 실행한다. 여기서 상기 인터럽트가 발생했을 시 ISR을 실행하기까지의 절차는 후기될 도 6을 참조하여 상세히 설명하기로 한다. 314는 상기 제 2프로세스가 수행되다가 인터럽트 발생에 의해 제 1프로세스로 문맥 전환이 발생되는 것을 의미한다. 이후 상기 ISR(306)이 하드웨어 장치 2(310)의 인터럽트 요청에 대한 작업을 완료하면 후기될 도 7의 과정을 수행하여 인터럽트에 의해 중지된 제 2프로세스의 작업을 중지된 시점부터 다시 수행한다. 316은 상기 제 1프로세스이 모든 작업을 완료하고 제 2프로세스로 문맥 전환이 발생되는 것을 의미한다.In FIG. 3, it is assumed that the second process has a higher priority than the first process and the first process has completed ISR registration. If the hardware device 2 310 requests an interrupt 316 while the second process is running in the non-privileged mode, the ISR 306 is executed. Here, the procedure up to execution of the ISR when the interrupt occurs will be described in detail with reference to FIG. 6 to be described later. 314 means that the second process is performed and the context switch occurs to the first process by the occurrence of an interrupt. Thereafter, when the ISR 306 completes the interrupt request of the hardware device 2 310, the process of FIG. 7 to be described later is performed to resume the operation of the second process interrupted by the interruption. 316 means that the first process completes all work and a context switch occurs to the second process.

다음으로 도 4는 상기 비특권 모드의 프로세스에서 ISR을 수행하기 위해 본 발명의 실시예가 적용된 CPU와 주기억 장0치의 구성을 도시한 도면이다.4 is a diagram illustrating a configuration of a CPU and a main memory device to which an embodiment of the present invention is applied to perform ISR in the non-privileged mode process.

도 4는 본 발명의 실시예에 따른 CPU와 주기억 장치의 구조를 도시한 도면이다.4 is a diagram illustrating the structure of a CPU and a main memory device according to an embodiment of the present invention.

상기 도 4를 참조하여, 먼저 본 발명의 실시예에 따른 CPU(400)는 종래의 CPU(200)와 비교하여 인터럽터 레지스터 파일(408)과 인터럽트 페이지 디렉토리(409)가 레지스터(410)에 새로운 구성요소로 추가하였으며, 기존의 명령 캐쉬 영역(212)을 분할하여 새로운 인터럽트 캐쉬(425)를 추가하고, 또한 기존의 데이터 캐쉬(218)를 분할하여 새로운 인터럽트 데이터 캐쉬(435)를 추가하였다. 그리고 제어기(430)는 기존의 제어기(215)를 본 발명의 실시예에 따른 비특권 모드의 프로세스에서 ISR 수행이 가능하도록 수정하였다. 도 6 내지 7이 상기 제어기(430)에서 수행하는 처리 과정을 도시한 흐름도이다. 한편, 주기억 장치(450)는 프로세스 식별자(PID: Process IDentifier, 이하 'PID'라 칭하기로 한다)(454)와, 저장 페이지 디렉토리(saved page directory)(456)와, 플래그(flag)를 각 ISR 필드에 새롭게 추가하였다. Referring to FIG. 4, the CPU 400 according to the embodiment of the present invention has a new configuration in which the interrupt register file 408 and the interrupt page directory 409 are newly registered in the register 410 as compared with the conventional CPU 200. Element, the existing instruction cache area 212 was added to add a new interrupt cache 425, and the existing data cache 218 was added to add a new interrupt data cache 435. The controller 430 has modified the existing controller 215 to perform ISR in a non-privileged mode process according to an embodiment of the present invention. 6 to 7 are flowcharts illustrating a process performed by the controller 430. On the other hand, the main memory device 450 is a process identifier (PID) (hereinafter referred to as "PID") 454, a stored page directory (456) and a flag (flag) for each ISR New addition to the field.

그러면, 상기 새롭게 추가된 영역이 하는 기능에 대해서 살펴보기로 한다.Next, a function of the newly added region will be described.

상기 인터럽트 레지스터 파일(408)은 인터럽트가 해당되는 ISR에서 처리되는 동안 수행되는 작업에 대한 정보를 레지스터에 임시 저장한다. 상기 인터럽트 페이지 디렉토리(409)는 인터럽트 발생시 상기 저장 페이지 디렉토리(456)가 로딩(loading)되는 영역이다. 여기서 상기 페이지(page)는 정해진 길이를 가지는 메모리 공간을 의미한다. 페이지내에서의 선형주소는 물리적으로 연속적인 주소를 사용하게 되며, 커널은 페이지 단위로만 물리적인 주소와 접근 방식으로 표시한다. 또한, 상기 페이지는 물리적으로 연속된 공간을 의미하기도 하며, 그 속의 데이터도 페이지라고 표현하기도 한다. 페이지 프레임(page frame)은 물리적인 메모리인 RAM을 일정한 크기로 나눈것으로서 하나의 페이지를 가진다고 가정한다. 상기 페이지는 디스크 상에 있을 수 도 있으며, 주기억 장치의 페이지 프레임을 차지할 수도 있다. 한편, 페이지 프레임들에 대한 관리의 목적으로 페이지 테이블(page table)이 있다. 상기 페이지 테이블은 페이지 프레임들에 대한 목록을 가지는 주기억 장치상의 데이터 구조이다. 페이지 테이블에 대한 목록을 가지는 것이 페이지 디렉토리이다. 즉, 페이지 테이블의 하나의 엔트리(entry)는 페이지 테이블을 가르키는 포인터가 된다.The interrupt register file 408 temporarily stores information about a task performed while an interrupt is processed in a corresponding ISR in a register. The interrupt page directory 409 is an area where the storage page directory 456 is loaded when an interrupt occurs. Here, the page means a memory space having a predetermined length. Linear addresses within a page use physically contiguous addresses, and the kernel presents the physical address and approach only page by page. In addition, the page may mean a physically continuous space, and the data therein may also be referred to as a page. A page frame is a physical memory divided by a certain amount of RAM is assumed to have a page. The page may be on disk or may occupy a page frame of the main memory device. On the other hand, there is a page table (page table) for the purpose of managing page frames. The page table is a data structure on the main memory having a list of page frames. The page directory contains a list of page tables. That is, one entry of the page table becomes a pointer to the page table.

상기 인터럽트 캐쉬(425) 및 인터럽트 데이터 캐쉬(435)는 ISR이 수행될 동안 명령어 및 데이터가 임시 저장되는 메모리 영역으로 상기 ISR이 수행되면서 정상적인 프로세스가 수행될 때 사용하던 캐쉬 영역을 침범하는 것을 방지하기 위해 본 발명에서는 상기 캐쉬 영역을 정상 동작시의 캐쉬 영역과 인터럽트 처리시의 캐쉬 영역을 분리하였다. 여기서, 상기 캐쉬(cache)는 메모리라 볼 수 있으며, 캐쉬 메모리는 마이크로프로세서가 일반적인 RAM(Random Access Memory)에 비해 더 빨리 액세스 할 수 있는 램이다. 마이크로프로세서가 데이터를 처리할 때 제일먼저 캐쉬 메모리에 있는지를 찾고, 원하는 데이터를 찾으면 읽는데 더 많은 시간이 필요한 주기억 장치로 갈 필요가 없게된다. 상기 캐쉬 메모리는 때로 마이크로프로세서에 얼마나 가깝고, 접근하기 쉬우냐에 따라 두 단계로 나뉘어진다. 레벨-1(L1) 캐쉬는 마이크로프로세서와 같은 칩 내에 있다. 레벨-2(L2) 캐쉬는 일반적으로 별도로 분리된 SRAM(Static RAM) 칩이다. 주기억 장치는 보통 DRAM(Dynamic RAM) 칩을 사용한다. 한편, 리눅스 OS는 하드웨어적인 기술은 무시하고 상기 L1, L2 캐쉬를 별도로 구분하지 않고 하나의 캐쉬로 가정한다.The interrupt cache 425 and the interrupt data cache 435 are memory areas in which instructions and data are temporarily stored while the ISR is performed, and thus, the ISR is performed to prevent the intrusion of the cache area used when a normal process is performed. In the present invention, the cache area is divided into a cache area in normal operation and a cache area in interrupt processing. The cache may be referred to as a memory, and the cache memory may be a RAM which a microprocessor may access faster than a general random access memory (RAM). When a microprocessor processes data, it first finds it in cache memory, and when it finds the data it wants, it does not have to go to main memory, which requires more time to read. The cache memory is sometimes divided into two stages depending on how close and accessible the microprocessor is. The Level-1 (L1) cache is in the same chip as the microprocessor. Level-2 (L2) caches are typically separate RAM chips. Main memory devices usually use DRAM (Dynamic RAM) chips. On the other hand, the Linux OS ignores the hardware technology and assumes one cache without separately distinguishing the L1 and L2 caches.

상기 주기억 장치(450)의 PID(454)는 프로세스 ID를 저장하는 메모리의 일부분으로 OS에 제공되어 ISR을 수행하는 프로세스 관련 자료구조를 OS에서 억세스(access)할 때 사용한다. 상기 저장 페이지 디렉토리(saved page directory)(456)는 ISR을 수행하는 프로세스가 사용하는 페이지 디렉토리를 저장하는 주기억 장치(450)의 일부분으로 물리 주소를 가상 주소로 변환하는 정보가 포함되어 있다. 상기 플래그(flag)는 인터럽트 처리시에 상기 인터럽트 캐쉬(425) 및 인터럽트 데이터 캐쉬(435)를 사용하는가에 대한 정보가 포함되어 있다. 한편, 상기 PID(454), 저장 페이지 디렉토리(saved page directory), 플래그(flag)는 후기될 도 5의 절차를 거쳐서 ISR이 프로세스에 등록되어 주기억 장치(450)의 인터럽트 벡터의 엔트리(entry)로 포함된다.The PID 454 of the main memory device 450 is provided to the OS as a part of a memory for storing the process ID, and is used when the OS accesses a process-related data structure for performing ISR. The saved page directory 456 is a part of the main memory 450 that stores a page directory used by a process that performs ISR, and includes information for converting a physical address into a virtual address. The flag includes information on whether the interrupt cache 425 and the interrupt data cache 435 are used in interrupt processing. Meanwhile, the PID 454, a stored page directory, and a flag are registered as a process in FIG. 5 to be described later, and the ISR is registered in the process as an entry of an interrupt vector of the main memory 450. Included.

여기서, 상기 도 4에서 CPU(400)에 인터럽트를 요청(445)하였을 때 처리되는 과정을 살펴보면, 먼저 임의의 프로세스가 정상적으로 작업을 수행하다가 제어기(430)가 상기 임의의 하드웨어 장치로부터 상기 인터럽트 요청(445)을 수신하면 주기억 장치(450)내의 저장된 페이지 디렉토리(456)를 상기 CPU(400)내의 페이지 디렉토리(409)로 로딩(loading)한다. 이후 제어기(430)는 캐쉬 사용 여부를 판단하여 정상적인 프로세스 작업이 캐쉬를 사용하고 있었다면 상기 캐쉬 정보를 주기억 장치(450)에 저장한다. 상기 캐쉬 사용 여부는 플래그(flag)(458)가 저장하고 있는 정보로 판단한다. 상기 인터럽트 요청에 대해서 주기억 장치(450)의 인터럽트 벡터의 해당 ISR이 상기 인터럽트를 처리하고 종료한다. 이렇게 모든 인터럽트 처리과정이 종료되면 제어기(430)는 다시 이전의 프로세스에서 수행하던 작업에 대한 정보를 일반 레지스터(410)에서 불러오도록 제어하여 정상적인 프로세스 작업을 연속적으로 수행한다. 상기 인터럽트 벡터는 프로그래밍으로 구현하여 인터럽트가 있는 곳의 주소를 저장하는 목차라고 할 수 있다.Here, referring to FIG. 4, a process performed when an interrupt request 445 is requested to the CPU 400 is performed. First, any process performs a normal operation, and the controller 430 requests the interrupt request from the hardware device. When receiving 445, the stored page directory 456 in the main memory 450 is loaded into the page directory 409 in the CPU 400. Thereafter, the controller 430 determines whether the cache is used, and stores the cache information in the main memory 450 when the normal process job uses the cache. Whether or not the cache is used is determined by information stored by a flag 458. In response to the interrupt request, the corresponding ISR of the interrupt vector of the main memory 450 processes the interrupt and ends. When all interrupt processing processes are completed in this way, the controller 430 again controls information to be loaded from the general register 410 to perform the normal process tasks. The interrupt vector is a table of contents embodied programmatically to store the address where the interrupt is located.

그러면, 도 3의 상기 제 1프로세스(302)의 경우처럼 임의의 프로세스가 OS에 ISR을 등록 요청을 하는 과정에 대해 설명한다.Next, as described in the case of the first process 302 of FIG. 3, a process in which an arbitrary process requests an ISR to the OS will be described.

도 5는 본 발명의 실시예에 따른 OS가 프로세스로부터 ISR 등록 요청 수신시 처리하는 절차를 나타낸 흐름도이다.5 is a flowchart illustrating a procedure that an OS processes upon receiving an ISR registration request from a process according to an embodiment of the present invention.

먼저, 502단계에서 OS가 임의의 프로세스로부터 ISR 등록 요청을 수신하면 504단계로 진행한다. 상기 504단계에서 상기 OS는 상기 프로세스가 ISR 등록 요청을 할 수 있는 권한을 가지고 있는가를 판단한다. 상기 판단 근거는 프로세스의 권한 및 사용자의 권한, ISR 시작 주소의 유효성 등이 될 수 있다. 상기 504에서 ISR 등록이 가능한 프로세스이면 506단계로 진행하여 상기 OS는 인터럽트가 발생해도 상기 인터럽트 처리를 수행하지 않도록 설정하고 508단계로 진행한다. 상기 508단계에서 상기 OS는 상기 프로세스가 요청하는 ISR 정보를 인터럽트 벡터에 저장하고 510단계로 진행한다. 상기 ISR 정보는 PID(454), 저장 페이지 디렉토리(saved page directory)(456), 플래그(flag)(458)가 될 수 있다. 이후 상기 510단계에서 OS가 일 예로 임의의 하드웨어 장치로부터 인터럽트 요청을 수신하면 상기 프로세스에 등록된 ISR로 모드 천이하여 인터럽트 처리를 수행한다.First, when the OS receives an ISR registration request from an arbitrary process in step 502, it proceeds to step 504. In step 504, the OS determines whether the process has a right to make an ISR registration request. The reason for the determination may be the authority of the process, the authority of the user, the validity of the ISR start address, and the like. In step 504, if ISR registration is possible, the process proceeds to step 506. The OS sets to not perform the interrupt processing even if an interrupt occurs, and proceeds to step 508. In step 508, the OS stores the ISR information requested by the process in an interrupt vector and proceeds to step 510. The ISR information may be a PID 454, a saved page directory 456, and a flag 458. Thereafter, when the OS receives an interrupt request from an arbitrary hardware device in step 510, the OS transitions to an ISR registered in the process to perform interrupt processing.

다음으로, 도 6을 참조하여 제어기(430)가 인터럽트 요청 발생시 ISR 수행을 제어하는 과정을 설명한다.Next, a process of controlling the execution of the ISR when the interrupt request occurs by the controller 430 will be described with reference to FIG. 6.

도 6은 본 발명의 실시예에 따른 제어기가 ISR을 수행하도록 제어하는 과정을 도시한 흐름도이다.6 is a flowchart illustrating a process of controlling a controller to perform ISR according to an embodiment of the present invention.

먼저, 602단계에서 임의의 하드웨어 장치로부터 인터럽트 요청을 수신한 제어기(430)는 604단계로 진행한다. 상기 604단계에서 제어기(430)는 상기 인터럽트 요청에 해당되는 ISR 정보중 플래그(flag)(458) 정보로 상기 인터럽트가 캐쉬를 사용하도록 설정되어 있는지를 판단한다. 만약 상기 인터럽트가 캐쉬를 사용하도록 설정되어 있다고 제어기(430)가 판단하면 606단계로 진행한다. 상기 606단계에서 상기 제어기(430)는 일반 캐쉬에 기저장되어 있던 캐쉬 정보를 주기억 장치(450)에 저장하도록 한다. 여기서 상기 일반 캐쉬라 함은 명령어 캐쉬(420) 또는 데이터 캐쉬(440)를 통틀어 의미한다. 상기 604단계에서 캐쉬를 사용하지 않는다고 제어기(430)가 판단하면 608단계로 진행하여 저장된 페이지 디렉토리(456)를 인터럽트 페이지 디렉토리(409)에 로딩하고 610단계로 진행한다. 상기 610단계에서 제어기(430)는 상기 프로세스 등록된 ISR(306)의 시작 주소로 분기(jump)하여 인터럽트 처리를 수행한다. 예컨대 상기 프로세스는 가상 주소(virtual address)를 사용하고 주기억 장치는 물리 주소(physical address)를 사용한다. 따라서, 상기 프로세스가 실행되면 가상 주소를 물리 주소로 맵핑(mapping)하여 ISR을 수행한다. 상기 페이지 디렉토리(409)가 상기 주소 맵핑을 수행하는 역할을 한다. First, the controller 430 that receives the interrupt request from any hardware device in step 602 proceeds to step 604. In step 604, the controller 430 determines whether the interrupt is set to use the cache by using flag 458 information of the ISR information corresponding to the interrupt request. If the controller 430 determines that the interrupt is set to use the cache, the process proceeds to step 606. In step 606, the controller 430 stores cache information previously stored in the general cache in the main memory 450. Herein, the generic cache refers to the instruction cache 420 or the data cache 440. If the controller 430 determines that the cache is not used in step 604, the controller 430 proceeds to step 608 to load the stored page directory 456 into the interrupt page directory 409 and proceeds to step 610. In step 610, the controller 430 branches to the start address of the process registered ISR 306 to perform interrupt processing. For example, the process uses a virtual address and the main memory uses a physical address. Therefore, when the process is executed, ISR is performed by mapping a virtual address to a physical address. The page directory 409 serves to perform the address mapping.

다음으로, 도 7을 참조하여 인터럽트를 처리하고 이전 수행 모드로 동작하는 절차를 설명하기로 한다.Next, a procedure of processing an interrupt and operating in a previous execution mode will be described with reference to FIG. 7.

도 7은 본 발명의 실시예에 따른 ISR 실행 종료시 제어기가 수행하는 과정을 도시한 흐름도이다.7 is a flowchart illustrating a process performed by a controller at the end of an ISR execution according to an embodiment of the present invention.

먼저, 702단계에서 상기 제어기(430)가 ISR 실행 종료 신호를 감지하면 704단계로 진행한다. 상기 704단계에서 상기 제어기(430)는 인터럽트 벡터내의 ISR 정보중 플래그(flag)(458) 정보로 캐쉬를 사용하도록 설정되어 있는지를 판단한다. 만약 상기 제어기(430)가 캐쉬를 사용하도록 설정되어 있다고 판단하면 706단계로 진행한다. 상기 706단계에서 상기 제어기(430)는 인터럽트용 캐쉬에 기저장되어 있던 캐쉬 정보를 주기억 장치(450)에 저장하도록 한다. 여기서 상기 인터럽트용 캐쉬라 함은 인터럽트 캐쉬(425) 또는 인터럽트 데이터 캐쉬(435)를 의미한다. 상기 704단계에서 캐쉬를 사용하지 않는다고 제어기(430)가 판단하면 708단계로 진행하여 인터럽트가 발생하기 이전의 프로세스 작업을 다시 수행하도록 제어한다. 이후부터 CPU(400)는 인터럽트가 다시 발생되기 전까지 모든 작업 수행에 대해 일반 레지스터(406), 명령어 캐쉬(420) 및 데이터 캐쉬(440)를 임시 저장 장소로 이용하고 가상주소/물리주소 변환도 페이지 디렉토리(407)를 이용한다. First, when the controller 430 detects the ISR execution termination signal in step 702, the controller 430 proceeds to step 704. In step 704, the controller 430 determines whether the cache is set as flag 458 information in the ISR information in the interrupt vector. If it is determined that the controller 430 is set to use the cache, the process proceeds to step 706. In step 706, the controller 430 stores cache information previously stored in the interrupt cache in the main memory 450. In this case, the interrupt cache refers to an interrupt cache 425 or an interrupt data cache 435. If the controller 430 determines that the cache is not used in step 704, the controller 430 proceeds to step 708 to control to perform the process work before the interrupt occurs. Afterwards, the CPU 400 uses the general register 406, the instruction cache 420, and the data cache 440 as temporary storage for all operations until the interrupt is generated again, and the virtual address / physical address translation page. Directory 407 is used.

여기서 가상 메모리(virtual memory)라 함은 프로그램이 사용할 수 있는 주소 공간(address space)을 늘리기 위한 가상의 메모리로 프로세스들은 명령어나 데이터를 저장하는데 실제 물리주소(physical address)를 사용하는 것이 아니고 상기 가상주소(virtual address)를 사용한다. 상기 프로세스가 실행될때에야 비로소 가상주소가 실제 물리주소로 변환되는 것이다. In this case, the virtual memory is a virtual memory for increasing the address space that a program can use, and processes do not use the actual physical address to store instructions or data. Use a virtual address. It is only when the process is executed that the virtual address is converted to the actual physical address.

이상에서 설명한 바와 같이, 임의의 사용자 프로세스가 OS에 요청하여 자신에게 해당되는 ISR을 등록하면 비특권 모드에서도 ISR 수행이 가능해진다. 이렇게 함으로써, 상기 비특권 모드 내의 ISR은 인터럽트가 발생하였을 때 바로 처리할 수있으므로 여러번의 모드 변환간에 발생되는 시간 지연 현상을 줄일 수 있다. 또한,사용자 프로세스의 주소 공간에 존재하는 정보 및 자원을 그대로 접근할 수 있기 때문에 메모리 복사 비용을 줄일 수 있다.As described above, if any user process requests the OS and registers an ISR corresponding to the OS, the ISR can be performed even in the non-privileged mode. In this way, the ISR in the non-privileged mode can be processed immediately when an interrupt occurs, thereby reducing the time delay occurring between several mode conversions. In addition, the cost of copying memory can be reduced because the information and resources in the user process's address space can be accessed as is.

한편 본 발명의 상세한 설명에서는 구체적인 실시예에 관해 설명하였으나, 본 발명의 범위에서 벗어나지 않는 한도내에서 여러 가지 변형이 가능함은 물론이다. 그러므로 본 발명의 범위는 설명된 실시예에 국한되어 정해져서는 안되며 후술하는 특허청구의 범위뿐만 아니라 이 특허청구의 범위와 균등한 것들에 의해 정해져야 한다.Meanwhile, in the detailed description of the present invention, specific embodiments have been described, but various modifications are possible without departing from the scope of the present invention. Therefore, the scope of the present invention should not be limited to the described embodiments, but should be defined not only by the scope of the following claims, but also by the equivalents of the claims.

상술한 바와 같이 본 발명은 비특권 모드의 사용자 프로세스에 ISR을 등록케하여 인터럽트 발생시 여러번의 모드간의 천이가 발생하지 않으므로 처리 지연 시간을 줄일 수 있는 장점이 있다. 또한, 임시 기억 장소인 레지스터와 캐쉬 영역을 인터럽트 처리시와 정상 동작시의 영역으로 따로 분리함으로써 불필요한 모드 교환 또는 문맥 전환 및 레지스터 저장 동작을 제거할 수 있어 시스템의 성능을 향상시킬 수 있는 장점이 있다.As described above, the present invention has an advantage of reducing processing delay time by registering an ISR in a non-privileged user process so that no transition between multiple modes occurs when an interrupt occurs. In addition, by dividing the register and cache areas, which are temporary storage areas, into areas for interrupt processing and normal operation, unnecessary mode switching or context switching and register storage operations can be eliminated, thereby improving system performance. .

도 1은 종래의 특권 모드에서 인터럽트 처리를 도시한 도면1 illustrates interrupt processing in a conventional privileged mode.

도 2는 종래의 인터럽트 처리를 위한 CPU 및 주기억 장치의 구조를 도시한 도면2 is a diagram illustrating the structure of a CPU and a main memory device for conventional interrupt processing;

도 3은 본 발명의 실시예에 따른 비특권 모드의 프로세서에서 인터럽트 처리를 도시한 도면3 illustrates interrupt processing in a processor in a nonprivileged mode according to an embodiment of the present invention.

도 4는 본 발명의 실시예에 따른 CPU와 주기억 장치의 구조를 도시한 도면4 is a diagram illustrating the structure of a CPU and a main memory device according to an embodiment of the present invention;

도 5는 본 발명의 실시예에 따른 OS가 프로세스로부터 ISR 등록 요청 수신시 처리하는 절차를 나타낸 흐름도5 is a flowchart illustrating a procedure that an OS processes upon receiving an ISR registration request from a process according to an embodiment of the present invention.

도 6은 본 발명의 실시예에 따른 제어기가 ISR을 수행하도록 제어하는 과정을 도시한 흐름도6 is a flowchart illustrating a process of controlling a controller to perform ISR according to an embodiment of the present invention.

도 7은 본 발명의 실시예에 따른 ISR 실행 종료시 제어기가 수행하는 과정을 도시한 흐름도7 is a flowchart illustrating a process performed by a controller at the end of an ISR execution according to an embodiment of the present invention.

Claims (10)

특권 모드와 비특권 모드의 서로 다른 수행 모드를 제공하는 운영 체제를 구비한 시스템에서 인터럽트를 처리하기 위한 방법에 있어서,CLAIMS What is claimed is: 1. A method for handling interrupts in a system having an operating system that provides different modes of execution, privileged and non-privileged. 상기 비특권 모드에서 동작하는 임의의 프로세스로에서 소정의 인터럽트를 처리하기 위한 인터럽트 서비스 루틴(ISR)을 등록하는 과정과,Registering an interrupt service routine (ISR) for processing a predetermined interrupt in any process operating in the non-privileged mode; 상기 인터럽트 서비스 루틴(ISR)에 대응되는 인터럽트 발생시 이전 프로세스 작업을 일시 중지하고 상기 등록된 인터럽트 서비스 루틴(ISR)을 수행하도록 하는 과정을 포함함을 특징으로 하는 상기 방법.And suspending a previous process task and performing the registered interrupt service routine (ISR) when an interrupt corresponding to the interrupt service routine (ISR) occurs. 제 1항에 있어서,The method of claim 1, 인터럽트 서비스 루틴(ISR)을 등록하는 과정은;Registering an interrupt service routine (ISR); 상기 프로세스의 ISR 등록 허용이 가능한지를 판단하여 등록이 가능하면 주기억 장치의 상기 해당 인터럽트 벡터에 프로세스 식별자(PID)와, 저장 페이지 디렉토리와, 플래그 중 어느 하나 이상을 등록하는 과정을 포함함을 특징으로 하는 상기 방법.Determining whether the process permits ISR registration, and if the registration is possible, registering one or more of a process identifier (PID), a storage page directory, and a flag in the corresponding interrupt vector of the main memory device. Said method. 제 1항에 있어서,The method of claim 1, 상기 ISR에 해당되는 인터럽트 발생시 등록된 ISR을 수행하는 과정은;Performing a registered ISR when an interrupt corresponding to the ISR occurs; 상기 이전 프로세스 작업 수행에 대한 정보를 일반 레지스터 및 캐쉬에 저장한 후 상기 등록된 인터럽트 서비스 루틴(ISR)을 인터럽트용 레지스터 및 캐쉬로 로드(load)하여 상기 ISR을 수행함을 특징으로 하는 상기 방법.And storing the information on the previous process operation in a general register and a cache, and then loading the registered interrupt service routine (ISR) into an interrupt register and a cache to perform the ISR. 제 2항에 있어서,The method of claim 2, 상기 등록된 ISR은 비특권 모드에서 동작함을 특징으로 하는 상기 방법.Wherein the registered ISR operates in a non-privileged mode. 특권 모드와 비특권 모드의 서로 다른 수행 모드를 제공하는 운영 체제를 구비한 시스템에서 인터럽트를 처리하기 위한 장치에 있어서,An apparatus for handling interrupts in a system having an operating system that provides different modes of execution, both privileged and nonprivileged. 소정의 인터럽트를 처리하기 위한 인터럽트 서비스 루틴(ISR)을 등록케하여 상기 인터럽트 서비스 루틴(ISR)에 대응되는 인터럽트 발생시 이전 프로세스 작업을 일시 중지하고 상기 등록된 인터럽트 서비스 루틴(ISR)을 수행하도록 하는 제어기와,A controller that registers an interrupt service routine (ISR) for processing a predetermined interrupt so as to suspend a previous process operation and perform the registered interrupt service routine (ISR) when an interrupt corresponding to the interrupt service routine (ISR) occurs. Wow, 상기 ISR 등록 요청에 따라 인터럽트 벡터에 상기 ISR 등록 정보를 저장하는 주기억 장치와,A main memory device for storing the ISR registration information in an interrupt vector according to the ISR registration request; 상기 ISR 수행시 인터럽트 처리 정보를 임시 저장하는 인터럽트용 임시 기억 장치를 포함함을 특징으로 하는 상기 장치.And an interrupt temporary memory for temporarily storing interrupt processing information when performing the ISR. 제 5항에 있어서,The method of claim 5, 상기 제어기는 상기 프로세스의 인터럽트 서비스 루틴(ISR) 등록 허용이 가능한지를 판단하여 등록이 가능하면 주기억 장치에 상기 해당 인터럽트 벡터에 프로세스 식별자(PID)와, 저장 페이지 디렉토리(saved page directory)와, 플래그(flag)를 주기억 장치의 인터럽트 벡터에 등록하도록 제어함을 특징으로 하는 상기 장치.The controller determines whether to allow the Interrupt Service Routine (ISR) registration of the process, and if the registration is possible, the controller identifies a process identifier (PID), a saved page directory, and a flag in the corresponding interrupt vector. flag) to be registered in the interrupt vector of the main memory device. 제 5항에 있어서,The method of claim 5, 상기 임시 기억 장치는 인터럽트용 레지스터, 인터럽트용 캐쉬 중에서 선택된 어느 하나 이상을 포함함을 특징으로 하는 상기 장치.And the temporary memory device includes at least one selected from an interrupt register and an interrupt cache. 제 7항에 있어서,The method of claim 7, wherein 상기 인터럽트용 레지스터는 인터럽트 레지스터 파일과 인터럽트 페이지 디렉토리를 포함함을 특징으로 하는 상기 장치.And said interrupt register comprises an interrupt register file and an interrupt page directory. 제 7항에 있어서,The method of claim 7, wherein 상기 인터럽트용 캐쉬는 인터럽트 캐쉬와 인터럽트 데이터 캐쉬를 포함함을 특징으로 하는 상기 장치.And said interrupt cache comprises an interrupt cache and an interrupt data cache. 제 5항에 있어서,The method of claim 5, 상기 주기억 장치는 인터럽트 발생시 해당 인터럽트 서비스 루틴(ISR)에 프로세스 식별자(PID), 저장 페이지 디렉토리(saved page directory), 플래그(flag) 필드를 생성하여 인터럽트 벡터에 저장함을 특징으로 하는 상기 장치.The main memory device generates a process identifier (PID), a saved page directory, and a flag field in a corresponding interrupt service routine (ISR) when the interrupt occurs, and stores the interrupt field in an interrupt vector.
KR10-2003-0083060A 2003-11-21 2003-11-21 Apparatus and method for handling interrupt in non-privileged of embedded system KR100506254B1 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
KR10-2003-0083060A KR100506254B1 (en) 2003-11-21 2003-11-21 Apparatus and method for handling interrupt in non-privileged of embedded system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
KR10-2003-0083060A KR100506254B1 (en) 2003-11-21 2003-11-21 Apparatus and method for handling interrupt in non-privileged of embedded system

Publications (2)

Publication Number Publication Date
KR20050049170A KR20050049170A (en) 2005-05-25
KR100506254B1 true KR100506254B1 (en) 2005-08-10

Family

ID=37247733

Family Applications (1)

Application Number Title Priority Date Filing Date
KR10-2003-0083060A KR100506254B1 (en) 2003-11-21 2003-11-21 Apparatus and method for handling interrupt in non-privileged of embedded system

Country Status (1)

Country Link
KR (1) KR100506254B1 (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7120794B2 (en) * 2003-10-29 2006-10-10 Qualcomm Inc. System for invoking a privileged function in a device
KR101489887B1 (en) * 2014-01-23 2015-02-06 고려대학교 산학협력단 System and method for processing interrupt
KR102575773B1 (en) * 2021-03-29 2023-09-06 숭실대학교산학협력단 Processor capable of processing external service requests using a symmetrical interface

Also Published As

Publication number Publication date
KR20050049170A (en) 2005-05-25

Similar Documents

Publication Publication Date Title
US5469571A (en) Operating system architecture using multiple priority light weight kernel task based interrupt handling
EP3039540B1 (en) Virtual machine monitor configured to support latency sensitive virtual machines
US7313797B2 (en) Uniprocessor operating system design facilitating fast context switching
US5161226A (en) Microprocessor inverse processor state usage
EP1467282B1 (en) Operating systems
US5666523A (en) Method and system for distributing asynchronous input from a system input queue to reduce context switches
US6513057B1 (en) Heterogeneous symmetric multi-processing system
US5701493A (en) Exception handling method and apparatus in data processing systems
CA1182575A (en) Method and means for switching system control of cpus
US7979861B2 (en) Multi-processor system and program for causing computer to execute controlling method of multi-processor system
EP0783734B1 (en) System and method for providing cooperative interrupts in a preemptive task scheduling environment
US8140834B2 (en) System, method and computer program product for providing a programmable quiesce filtering register
US20020013892A1 (en) Emulation coprocessor
JP2004054948A (en) Synchronization of asynchronous emulated interrupt
GB2392998A (en) Handling interrupts during multiple access program instructions
US20180011735A1 (en) Instruction pre-fetching
US5893159A (en) Methods and apparatus for managing scratchpad memory in a multiprocessor data processing system
US7818558B2 (en) Method and apparatus for EFI BIOS time-slicing at OS runtime
US8010963B2 (en) Method, apparatus and program storage device for providing light weight system calls to improve user mode performance
JP5131269B2 (en) Multi-processing system
KR100506254B1 (en) Apparatus and method for handling interrupt in non-privileged of embedded system
JP2001216172A (en) Multi-os constituting method
US7702836B2 (en) Parallel processing device and exclusive control method
WO1998012635A1 (en) Method and apparatus for encapsulating a protected-mode operating system within a real-time, protected-mode operating system
US20080072009A1 (en) Apparatus and method for handling interrupt disabled section and page pinning apparatus and method

Legal Events

Date Code Title Description
A201 Request for examination
E701 Decision to grant or registration of patent right
GRNT Written decision to grant
FPAY Annual fee payment

Payment date: 20080604

Year of fee payment: 4

LAPS Lapse due to unpaid annual fee