250x250
Notice
Recent Posts
Recent Comments
«   2024/10   »
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31
Archives
Today
Total
관리 메뉴

SYDev

[운영체제] Chapter 2. Operating System Structures 본문

3학년 2학기 전공/운영체제

[운영체제] Chapter 2. Operating System Structures

시데브 2024. 9. 10. 20:22
728x90
경희대학교 허선영 교수님의 운영체제 수업을 기반으로 정리한 글입니다.

 

How Operating Systems Interact with Hardware?

  • OS가 hardware와 소통하는 방식 -> Interrupts

 

 

Device Controller

  • 각각의 특정한 device type을 담당하는 device controller가 존재 -> device를 controll
  • ex) disk controller, USB controller, graphics adapter
  • 이런 device controller들은 common bus에 의해 연결되고, common bus를 통해 shared memory에 접근 가능 -> common bus를 통해 신호를 주고받음
  • OS는 각각의 device controller에 device driver 보유 -> OS에 내장된 software

 

Interrupts

  • device controller는 operation이 끝나면 CPU에 interrupt 신호를 전송
  • interrupt의 type에 따라 -> interrupt vector에 기반하여 interrupt-specific handler가 호출됨

I/O device

  • transferring data -> busy
  • idle -> 휴식 상태
  • transferring이 완료되면 다시 idle 상태로 복귀 -> CPU에 interrupt 전송

CPU

  • 평상시에는 user program을 실행
  • Interrupt 수신 시 -> interrupt type에 알맞은 interrupt handling 수행 
  • interrupt handling 완료 -> 다시 user program 작업으로 복귀

 

Interrupt Vector

  • Interrupt Vector: interrupting device에 알맞은 interrupt service routine의 주소를 가진 공간
  • Interrupt Vecotr Table: interrupt vector들이 저장되어 있는 영역
  • pc의 전원이 켜져 부팅될 때, OS는 interrupt vector table 값을 초기화

 

Interrupts - Implementation

-> maskable interrupts: 받아들일지 말지 결정 가능

-> non-maskable interrupts: 무시 불가능 -> 매우 중요한 interrupts(ex: 정전, 하드웨어 고장)

Hardware

  • Hardware Interrupts: hardware events에 대한 response -> 외부 hardware device가 보낸 신호
  • ex) IRQ
  • CPU는 보통 1~2개의 IRP(Interrupt Request Pin)을 가짐 -> 많은 I/O divice와 상호작용하기 위해 이를 중계하는 매개체가 필요
  • Programmable Interrupt Controller(PIC): interrupt-driven system에서 다른 I/O 장치들에 대한 대표성을 가지고 CPU에 연결되며, 전반적인 manager 역할 수행
  • PIC는 다수의 interrupt pin을 가짐 -> 다수의 I/O devices가 연결되고, PIC가 다시 CPU의 interrupt pin에 직접 연결됨
  • ex) intel 8259A PIC: 8개의 IRQ pin 존재 -> 8개만으로는 모든 I/O devices 커버 불가능 -> 여러 개를 직렬로 연결하여 사용

 

Software

  • Software Interrupts(exceptions): software events에 대한 response -> CPU의 software 내부에서 발생하는 interrupts
  • ex) three types of software exceptions in x86: faults, traps, aborts
  1. device driver가 interrupt를 초기화(신호를 수신하기 전), CPU는 interrupt 신호를 수시로 check
  2. I/O request가 발생하면, device driver를 통해서 해당 device controller에 명령을 전달
  3. device controller가 명령받은 동작을 수행
  4. 작업이 끝나면 interrupt 신호를 CPU에 전달(Interrupt line에 쌓음)
  5. OS가 Interrupt line에 interrupt를 수신 -> 실행 중인 process를 멈추고 interrupt handling 작업 실시

 

CPU's Interrupt Request Line(IRQ Line)

  • IRQ Line을 통해서 interrupt request 요청을 수신
  • 각각의 IRQ Line은 index를 가짐 -> index에 따라 interrupt vector 번호가 매칭됨

 

Programmable Interrupt Controller(PIC)

-> PIC의 legacy 형태

 

-> 현대의 PIC는 northbridge와 southbridge가 통합된 chipset을 포함한 형태

  • CPU와 device controller가 포함된 chipset이 연결됨
  • Chipset과 devices 연결됨

 

How Operating Systems Interact with Software?

  • program에서는 OS가 제공하는 service를 system call을 이용하여 사용 가능

 

Operating System Services

  • OS가 제공하는 services를 프로그램이 이용하려면 system call에 요청해야 함

 

System Calls

  • System Call: OS의 kernel이 제공하는 service에 대해, program의 요청에 따라 kernel에 접근하기 위한 interface
  • C나 C++같은 고급 언어로 작성된 programs -> 직접 system call 호출 불가능 -> high-level API(Application Programming Interface)를 통해 syscall에 접근

-> user는 high-level language에서 그저 함수 호출만 하면 system call이 발생

 

Example: Standard C Libarary

  • kernel modewrite() system call에, C program의 printf() function을 호출함으로써 접근

 

System Calls - Implementation

  • 각각의 system calls는 번호를 가짐
  • System-call interface -> 이런 번호를 포함한 table을 가짐
  • caller는 system call 내부에서 어떤 동작을 하는지 알 필요가 없다!! -> 무슨 기능을 하는지만 알면 됨

 

Example: Handling of the open() system call

  1. User application이 open() (number 2) system call 호출
  2. kernel mode에서는 system call table의 2번째 entry(sys_open) 호출
  3. 해당 함수 return value를 다시 user에게 반환

 

System Calls - Parameter Passing

  • 기본 param을 제외한 추가 parameters가 필요할 수 있음
  • OS에는 parameter를 전달하는 3가지 방법이 있음 -> Simplest, Block, Stack

Simplest

  • registers로 parameter 전달
  • register 개수가 한정적 -> register 개수보다 많은 parameter 전달 불가
  • 상대적으로 속도는 빠르나, 많은 parameter를 전달받지 못함

Block

  • in block or table 
  • in memory
  • parameter가 저장된 block의 주소를 register에 저장
  • 상대적으로 많은 param 전달 가능, but 상대적으로 속도가 떨어짐

Stack

  • stack에 parameter 위치함 -> program에 의해 pushed, os에 의해 popped off off

 

Types of System Calls

Process Control 

  • create process, terminate process
  • end, abort
  • load, execute
  • get process attributes, set process attributes
  • wait for time
  • wait event, signal event
  • allocate and free memory
  • dump memory if error
  • debugger for determining bugs, single step execution
  • locks for managing access to shared data between processes

File Management

  • create file, delete file
  • open, close file
  • read, write, reposition
  • get and set file attributes

Device Management

  • request device, release device
  • read, write, reposition
  • get device attributes, set device attributes
  • logically attach or detach devices

Information maintenance

  • get time or date, set time or date
  • get system data, set system data
  • get and set process, file, or device attributes

Communications

  • create, delete communication connection
  • send, receive message if message passing model to host name or process name
    • From client to server
  • shared-memory model create and gain access to memory regions
  • transfer status information
  • attach and detach remote devices

Protection

  • control access to resources
  • get and set permissions
  • allow and deny user access

 

Operating System Structure

  • General-purpose OS - very large program
    • Simple structure - MS-DOS
    • More Complex - UNIX
    • Layered - an abstraction
    • Microkernel - Mach

 

Monolithic Structure - Original UNIX

  • Monolithic Structure: kernel의 모든 기능을 single address space에 위치한 single, static binary file에 위치
  • Tightly Coupled System: 동일 운영체제 하에 여러 개의 프로세스가 하나의 메모리를 공유하여 사용하는 시스템
  • UNIX OS는 2가지 part로 이뤄짐
    • System Programs
    • Kernel: system-call interface & physical hardware 사이에 있는 모든 것
  • system call interface와 kernel이 하나로 합쳐져 있기 때문에 overhead가 적음

 

Unix and Linux System Structure

 

Layered Approach

  • 몇 개의 layers(levels)로 나눠진 구조
  • Bottom layer(layer 0): Hardware, Highest(layer N): User interface
  • 각각의 layer는 functions(operations)와 services 사용(오직 lower-level layers)
  • computer networks & web applications에서 성공적으로 사용됨

Advantages

  • Easy to design and implement-> layer마다 design
  • debugging and system verification을 단순화 -> layer마다

Drawbacks

  • 상대적으로 아쉬운 성능

Microkernels

  • kernel에서 가능한 한 많은 부분을 user space로 이동
  • ex) Mach
  • user modules 사이communication이 위치 -> message passing 이용

Advantages

  • microkernel을 확장하기 쉬워짐
  • os를 새로운 architectures에 적용하기 쉬워짐
  • more reliable & secure

Drawbacks

  • kernel space와 user space 사이의 통신으로 인한 overhead


참고자료

 

The interrupt timeline for a single process doing output

I'm studying the book 'Operating System Concepts' 9th edition. In the first chapter, part 1.2.1 computer system operation, I can't understand the figure 1.3: Can any one make a quick interpretatio...

unix.stackexchange.com

 

인터럽트 벡터

인터럽트 벡터란 무엇일까? ​ -> 인터럽트 벡터는 인터럽트가 발생했을 때, 그 인터럽트를 처리할 수 있는 서비스 루틴들의 주소를 가지고 있는 공간이다. ​ * 각 인터럽트에는 번호가 할당되

codingram.tistory.com

 

Interrupt, I/O Device

Interrupt and Exception 본 노이만 구조는 instruction들을 순차적으로, 동기적으로 실행한다. 그러나 실제 상황에서는 비동기적으로 발생하는, 즉 주기적으로 발생하지 않는 이벤트들을 처리해야한다.

gofo-coding.tistory.com

 

[운영체제] I/O subsystem, Interrupt

I/O device들은 device driver와 device controller를 갖고 있다.

velog.io

 

[운영체제] 인터럽트(Interrupt) 핸들링을 파보자!

📣 해당 포스트는 운영체제 공룡책과 고건 교수님의 OLC 강의 등을 참고하여 작성되었습니다. 인터럽트란 무엇일까요?? 오늘의 주제는 인터럽트가 핸들링되는 방식이기 때문에 인터럽트는 아주

hasensprung.tistory.com

 

시스템 호출 - 위키백과, 우리 모두의 백과사전

위키백과, 우리 모두의 백과사전. 리눅스 커널의 시스템 호출 인터페이스에 대한 개요. 다양한 구성 요소와 사용자공간 간의 통신을 관리한다. 시스템 호출 또는 시스템 콜(system call), 간단히 시

ko.wikipedia.org

 

728x90