본문 바로가기
CS/Operating System

운영체제 구조(Operating System Structures) - 3

by Dr.섭도 2024. 6. 25.

문제

2.1 시스템 콜의 목적은 무엇인가?(What is the purpose of system calls?)

시스템 콜은 유저 모드에서 커널 모드로 진입하는 데 목적이 있다

하나의 인터럽트이며, 사용자 애플리케이션이 컴퓨터 자원에 직접 접근하는 것을 막아 컴퓨터 자원을 보호한다

 

Answer:
System calls allow user-level processes to request services of the operating system.

 

2.2 명령 인터프리터의 목적은 무엇인가? 통상 커널에 포함되지 않는 이유는 무엇인가?( What is the purpose of the command interpreter? Why is it usually separate from the kernel?)

명령 인터프리터는 사용자와 운영체제 사이의 인터페이스 역할을 한다. 사용자가 명령을 입력하면 명령 인터프리터는 이를 해석해 시스템 콜(System call)로 변환한다.

사용자는 명령어를 통해 프로세스 제어, 프로그램 실행 등을 진행한다.

또한 파일 관리도 진행한다.

 

명령 인터프리터는 유연성을 가지고 변경될 수 있기에 커널에 포함하지 않는다. Bash, Power Shell 등의 다양한 선택지가 주어지는데, 이 부분이 커널에 포함된다면 유연성이 사라지게 된다.

또한 사용자가 직접 입력하는 환경이 커널에 포함된다면, 사용자의 오류가 커널 전체에 영향을 미치게 되므로 커널의 안정성을 떨어뜨린다.

 

Answer:
It reads commands from the user or from a file of commands and executes them, usually by turning them into one or more system calls. It is usually not part of the kernel since the command interpreter is subject to changes.

 

2.3 UNIX 시스템에서 새 프로세스를 시작하기 위해 명령 인터프리터나 셸에서 어떤 시스템 콜이 실행되어야 하는가?(What system calls have to be executed by a command interpreter or shell
in order to start a new process on a UNIX system?)

fork와 exec가 실행된다.

fork는 현재 프로세스를 복제하여 새로운 프로세스를 생성한다. 부모 프로세스를 복사하여 자식 프로세스라 부른다. 부모 프로세스에서는 자식 프로세스의 PID가 반환되고, 자식 프로세스에서는 0이 반환된다

 

exec는 현재 프로세스의 메모리 공간을 새로운 프로그램으로 덮어쓴다(실행). 현재 프로세스를 새로운 프로세스로 변환하고 기존 데이터와 코드를 새로운 데이터와 코드로 대체한다.

 

Answer: 
In Unix systems, a fork system call followed by an exec system call need to be performed to start a new process. The fork call clones the currently executing process, while the exec call overlays a new process based on a different executable over the calling process.

 

2.4 시스템 프로그램의 목적은 무엇인가?(What is the purpose of system programs?)

시스템 프로그램은 시스템 자원 관리, 파일 관리, 프로세스 관리 등을 수행하는 소프트웨어이다. 운영 체제의 핵심 기능을 보완하고 사용자와 응용 프로그램이 시스템 자원을 효율적으로 사용할 수 있게 해 준다.

 

시스템 프로그램은 시스템 콜을 사용해 고급 기능을 구현한 사용자 수준의 프로그램이다. 여러 시스템 콜을 조합해 고수준 작업을 수행할 수 있는 도구로 보면 된다.

 

ls, cp, mv 같은 시스템 프로그램은 open, read, write, close와 같은 여러 시스템 콜을 조합하여 수행된다.

 

시스템 프로그램 = 시스템 콜의 조합을 통해 사용자가 자주 필요로 하는 기능들을 수행하는 효과적인 프로그램

정도로 이해하면 될 것 같다.

 

Answer:
System programs can be thought of as bundles of useful system calls. They provide basic functionality to users so that users do not need to write their own programs to solve common problems.

 

2.5 시스템 설계 시 계층화된 접근 방식의 주요 장점은 무엇인가? 계층화된 접근 방식의 단점은 무엇인가?( What is the main advantage of the layered approach to system design? What are the disadvantages of using the layered approach?)

Layered Approach는 각 계층이 특정 기능을 수행하고 그 위에 다음 계층이 쌓이는 구조이다.

 

각 계층은 독립적이고 서로 다른 기능을 수행하며, 각 계층은 다른 계층에 대해 추상화된 인터페이스를 제공한다. 보통 이런 설계는 모듈 간의 의존성, 결합도를 떨어뜨리며, 책임을 나누어 어느 계층에서 문제가 생겼는지 등의 디버깅을 쉽게 해 준다. 또한 특정 계층 사이의 의존도가 낮기 때문에 유지 보수도 용이하다. 또한 상위 계층은 하위 계층의 구현을 알 필요 없고 인터페이스로 호출만 진행하면 된다.

 

계층화된  접근 방식은 전체적인 시스템의 안정성을 높이고 문제 해결을 쉽게 해준다. 또한 정보를 해당 계층에서만 사용하기 때문에 무결성과 보안을 강화한다. 해당 계층은 해당 일만 처리하는 전담

 

이는 Backend 설계의 기본 원칙이기도 하다. 의존성 역전을 통해 우리는 추상에 의존하고 구체화에 의존하지 않는 방식을 좋은 설계라고 배웠다. 구현에 의존하게 되면, 다른 계층에서 문제가 생길 경우 연관된 코드를 모두 바꿔야 하는 불상사가 생긴다. 따라서 구현 사항이 아닌 인터페이스의 추상화에 의존하는 것이 좋은 설계이다.

 

하지만 여기에도 단점이 존재한다.

다른 계층 사이의 통신은 오버헤드를 증가시켜 성능 저하의 문제가 생길 수 있다. 특히 실시간성이 중요한 시스템에선 성능 저하 문제는 치명적일 것이다.

계층 사이의 상호작용이 복잡해지고, 따라서 데이터 전달도 복잡해진다. 이로 인해 시스템 전체 오버헤드가 증가한다.

 

Answer:
As in all cases of modular design, designing an operating system in a modular way has several advantages. The system is easier to debug and modify because changes affect only limited sections of the system rather than touching all sections of the operating system. Information is kept only where it is needed and is accessible only within a defined and restricted area, so any bugs affecting that data must be limited to a specific module or layer.

 

2.6 운영체제에서 제공하는 5가지 서비스를 나열하고 각 서비스가 사용제에게 편의를 제공하는 방법을 설명하라. 사용자 수준 프로그램이 이러한 서비스를 제공할 수 없는 경우는 언제인가? 여러분의 답을 설명하라.(List five services provided by an operating system, and explain how each
creates convenience for users. In which cases would it be impossible for
user-level programs to provide these services? Explain your answer.)

1. 프로그램 실행: 프로그램을 메모리에 로드, 실행한다. 사용자는 운영체제가 처리하는 부분을 몰라도 프로그램을 쉽게 실행할 수 있다. 

 

2. 입출력 관리: 사용자는 장치와 작업만 알고 이를 수행할 수 있으며, 디스크, 테이프, 기타 입출력 장치 등은 운영체제가 관리하여 서비스를 제공한다. 사용자의 잘못된 입출력을 방지하여 작업의 안정성과 보안성을 증가시키고 효율적인 자원 관리를 돕는다.

 

3. 파일 시스템 조작: 파일 생성, 삭제, 할당 등의 작업을 운영체제가 처리한다. 위 문제의 시스템 프로그램처럼 사용자는 mkdir 등의 명령어를 통해 손쉽게 파일 시스템을 조작할 수 있다. 상세 관리 자체는 운영체제가 처리하여 효율적으로 관리한다.

 

4. 통신: 시스템 간의 메시지 전달을 관리하며, 네트워크, 패킷 처리 등을 담당한다. 네트워크 리소스의 효율적 사용을 보장하고 정확한 데이터 전달을 보장한다. 또한 프로세스 간 통신(IPC, Inter-Process Communication) 메커니즘을 통해 프로세스 사이의 정보 전달을 효율적으로 처리한다.

 

5. 오류 검출: 하드웨어 또는 소프트웨어 수준의 오류를 검출한다. 데이터 전송 등의 오류 검출을 위한 데이터 검사(패리티 비트, CRC, ECC 등)를 진행한다. 또한 소프트웨어에서는 예외 처리, 파일 시스템 일관성 검사, 로그 제공 등을 통해 오류 검출을 돕는다. 사용자는 데이터 무결성을 보장하고, 시스템을 안정적으로 사용할 수 있다.

 

메모리 오류, 디스크 오류, 네트워크 인터페이스 오류 등의 하드웨어 오류

시스템 콜 오류

디스크 공간 부족, 파일 미존재, 파일 접근 권한 문제 등의 파일 시스템 관련 오류

메모리 오버플로우, CPU timeout 등의 프로세스 및 스케줄링 관련 오류

네트워크 및 통신 오류 등이 있다.

 

Answer: 
The five services are:

a. Program execution. The operating system loads the contents (or sections) of a file into memory and begins its execution. A user-level program could not be trusted to properly allocate CPU time.

b. I/O operations. Disks, tapes, serial lines, and other devices must be communicated with at a very low level. The user need only specify the device and the operation to perform on it, while the system converts that request into device- or controller-specific commands. User-level programs cannot be trusted to access only devices they Practice Exercises 7 should have access to and to access them only when they are otherwise unused.

c. File-system manipulation. There are many details in file creation, deletion, allocation, and naming that users should not have to perform. Blocks of disk space are used by files and must be tracked. Deleting a file requires removing the name file information and freeing the allocated blocks. Protections must also be checked to assure proper file access. User programs could neither ensure adherence to protection methods nor be trusted to allocate only free blocks and deallocate blocks on file deletion.

d. Communications. Message passing between systems requires messages to be turned into packets of information, sent to the network controller, transmitted across a communications medium, and reassembled by the destination system. Packet ordering and data correction must take place. Again, user programs might not coordinate access to the network device, or they might receive packets destined for other processes.

e. Error detection. Error detection occurs at both the hardware and software levels. At the hardware level, all data transfers must be inspected to ensure that data have not been corrupted in transit. All data on media must be checked to be sure they have not changed since they were written to the media. At the software level, media must be checked for data consistency; for instance, whether the number of allocated and unallocated blocks of storage match the total number on the device. There, errors are frequently processindependent (for instance, the corruption of data on a disk), so there must be a global program (the operating system) that handles all types of errors. Also, by having errors processed by the operating system, processes need not contain code to catch and correct all the errors possible on a system.

 

2.7 일부 시스템은 운영체제를 펌웨어에 저장하고 다른 시스템은 디스크에 저장하는 이유는 무엇인가?(Why do some systems store the operating system in firmware, while others store it on disk?)

일부 시스템이 운영체제를 펌웨어에 저장하는 이유만 설명하면 될 것 같다.

 

일부 임베디드 시스템 또는 장치가 펌웨어에 운영체제를 저장하여 전원 동작 시 바로 운영체제를 로드하여 시간을 단축하는 경우가 있다.

또한 전화나 PDA 등의 메모리 공간 제한으로 펌웨어에 저장하여 공간 효율을 추구한다. 그리고 이런 장치는 장치의 파일 시스템 등에 접근할 수 없어 펌웨어 운영체제 저장이 필요해진다.

 

펌웨어에 저장된 운영체제는 데이터 일관성을 유지한다.

 

Answer:
For certain devices, such as handheld PDAs and cellular telephones, a disk with a file system may be not be available for the device. In this situation, the operating system must be stored in firmware.

 

2.8 부팅할 운영체제를 선택할 수 있도록 시스템을 설계하는 방법은 무엇인가? 부트스트랩 프로그램이 해야 할 일은 무엇인가?( How could a system be designed to allow a choice of operating systems from which to boot? What would the bootstrap program need to do?)

부트 매니저를 통해 운영체제를 선택할 수 있다. 운영체제 실행 전 부트매니저를 통해 선택된 운영체제를 로드하는 것이 가능하다. 선택하지 않은 경우 기본 운영체제가 부팅된다.

 

부트스트랩 프로그램은 컴퓨터 시스템이 부팅될 때 가장 먼저 실행되는 프로그램이다.

하드웨어 초기화, 부트로더 로드, 부트로더 실행, 시스템 초기화 등의 작업을 수행한다. 부트로더 실행 시점에 운영체제를 부팅한 뒤 시스템 초기화로 시스템을 준비한다.

 

Answer:
Consider a system that would like to run both Windows XP and three different distributions of Linux (e.g., RedHat, Debian, and Mandrake). Each operating system will be stored on disk. During system boot-up, a special program (which we will call the boot manager) will determine which operating system to boot into. This means that rather initially booting to an operating system, the boot manager will first run during system startup. It is this boot manager that is responsible for determining which system to boot into. Typically boot managers must be stored at certain locations of the hard disk to be recognized during system startup. Boot managers often provide the user with a selection of systems to boot into; boot managers are also typically designed to boot into a default operating system if no choice is selected by the user.

 

잘못된 내용이나 오타 등은 댓글로 남겨주시면 감사하겠습니다!