본문 바로가기
CS/Operating System

운영체제(Operating System)란? - 2

by Dr.섭도 2024. 5. 29.

운영체제(Operating System)란 - 1?

 

운영체제(Operating System)란? - 1

1. 운영체제 개요운영체제란?컴퓨터 하드웨어 바로 위에 설치되어 사용자 및 다른 모든 소프트웨어와 하드웨어를 연결하는 소프트웨어 계층운영체제가 할 일(What Operating Systems Do?)하드웨어: 계

seopdo.tistory.com

<이어서>

운영체제 개요


보안과 보호(Security and Protection)

보호(Protection): 컴퓨터 시스템이 정의한 자원에 대해 프로그램, 프로세스, 또는 사용자들의 접근을 제어하는 기법

Protection, then, is any mechanism for controlling the access of processes or users to the resources defined by a computer system

사용자의 인증 정보가 도난당한다면?

파일과 메모리 보호 기능이 작동하더라도 사용자 데이터는 공격받을 수 있다

 

보안(Security): 외부 또는 내부의 공격을 방어하는 것

It is the job of security to defend a system from external and internal attacks

 

할당된 사용자 식별자(user IDs) 또는 보안 식별자(SID, Security ID), 그룹 식별자(사용자의 집합)를 스레드나 프로세스에 연관해 활용한다

 

가상화(Virtualization)

단일 컴퓨터의 하드웨어를 여러 실행 환경으로 추상화하여, 개별 환경이 자신만의 전용 컴퓨터에서 실행된다는 환상을 만들어 준다

e.g.) Virtual Box 등을 활용하면 Window 환경에서도 Linux Ubuntu를 실행할 수 있다

 

분산 시스템(Distributed Systems)

분산 시스템의 컴퓨터들은 분산 환경 내의 시스템에 접근할 수 있도록 네트워크로 연결되어 있다

  • 네트워크: 두 개 이상 시스템 사이의 통신 경로

네트워크 운영체제?

다른 컴퓨터의 다른 프로세스가 메시지를 교환할 수 있도록 하는 통신 체계 +

네트워크를 통한 파일 공유와 같은 기능을 제공하는 운영체제

 

다른 컴퓨터와는 자율적으로 작동

 

커널 자료구조(Kernel Data Structures)

운영체제 구현의 중심이자, 데이터가 구조화되는 방식

 

  • 리스트, 스택, 큐
  • 트리
  • 해시 함수와 맵
  • 비트맵

 

컴퓨팅 환경(Computing Environments) - 계산 환경

계산 환경보다는 컴퓨팅 환경으로 읽는 것이 더 와닿을 것 같다

 

  • 전통적인 컴퓨팅
  • 모바일 컴퓨팅
  • 클라이언트-서버 컴퓨팅
  • Peer-to-Peer 컴퓨팅
  • 클라우드 컴퓨팅
  • 임베디드 시스템

과 같은 다양한 컴퓨팅 환경이 존재한다(필요한 부분은 추가적으로 작성할 예정)

 

무료 및 오픈 소스 운영체제(Free and Open-Source Operating Systems)

GNU/Linux(GNU's Not Unix!")와 같은 오픈 소스 운영체제는 일부 배포판만 무료이다

모든 오픈 소스가 무료는 아니다(스톨만의 무료라는 의미는 사용의 자유를 의미한다)

 

Microsoft의 Windows는 비공개 소스이며 독점적이다

 

오픈 소스 운영체제의 장점으로는

프로그래머들의 공동체를 통한 코드 발전

많은 사람들의 검토로 인한 보안성 안정성의 증가

버그의 빠른 수정

등이 있다

 

Red Hat과 같은 회사는 소스 코드를 공개하면서 이익을 낼 수 있음을 보여준다


아래의 정리와 문제 해답은 교재 학습 내용을 토대로 개인적으로 정리한 것이므로

혹시 잘못된 점, 오류 등이 있는 경우 댓글로 알려주시면 감사하겠습니다

 

정리

운영체제는 하드웨어와 가장 밀접한 소프트웨어의 한 종류이다

운영체제는 컴퓨터 부팅 시 부트스트랩에 의해 가장 먼저 메모리로 올라와 실행된다

 

메모리로 올라온 운영체제는 CPU의 할당, 메모리의 관리, 디스크로부터 정보 가져오기 등 다양한 활동을 수행한다

이러한 하드웨어와의 상호작용은 인터럽트를 통해 이루어진다

 

운영체제는 이중화 모드로 구성되어 있는데, 사용자 모드 - 커널 모드를 왔다 갔다 하며 상호작용한다

시스템 콜이라는 하나의 인터럽트를 통해 커널모드로 이동하여 하드웨어를 제어한다

전기 신호를 통해 커널 모드에서 할 일을 마치면 비트를 바꾸어 사용자 모드를 호출하는 방식으로 작동한다

 

운영체제 내부에는 인터럽트 벡터라는 정보가 존재하여 하드웨어에서 인터럽트가 발생하면 다음과 같은 작동을 수행한다

1. 입출력 장치 등이 신호를 보내 인터럽트를 발생

2. CPU가 이를 감지하고 인터럽트 핸들러로 디스패치

3. 인터럽트 핸들러는 현재까지의 정보를 저장하고 인터럽트 벡터 내의 주솟값과 일치하는 작업을 수행한다

4. 수행이 완료되면 인터럽트를 해제하고 기존 수행하던 정보를 불러와 아무 일도 없었던 것처럼 다시 할 일을 한다

 

키보드 입력, 마우스 이동 등과 같은 움직임도 모두 이러한 방식을 통해 작동하고 있다

 

오늘날 다양한 운영체제가 있으며 독점형과 공개형 오픈소스 등으로 구성되어 있다

 


문제

운영체제의 세 가지 주요 목적은?

1. 사용자 관점에서 컴퓨터를 사용할 때 편리하게 사용할 수 있도록 한다

2. 컴퓨터 관점에서 CPU, 메모리 등 자원을 효율적으로 할당하고 관리한다

3. 제어 프로그램으로서 사용자 프로그램의 수행을 제어하고, 입출력 장치 제어와 작동에 관여한다

 

Answer:
The three main puropses are:
   • To provide an environment for a computer user to execute programs
     on computer hardware in a convenient and efficient manner.
   • To allocate the separate resources of the computer as needed to
     solve the problem given. The allocation process should be as fair
     and efficient as possible.
   • As a control program it serves two major functions: (1) supervision
     of the execution of user programs to prevent errors and improper use
     of the computer, and (2) management of the operation and control
     of I/O devices.

컴퓨팅 하드웨어를 효율적으로 사용하려면 운영체제가 필요하다고 강조하였다. 운영체제가 이 원칙을 버리고 자원을 낭비하는 것이 적절한 때는 언제인가? 그러한 시스템이 실제로 낭비하는 것이 아닌 이유는 무엇인가?

사용자의 요청이 많은 자원을 잡아먹는 경우, 이 작업에 많은 자원을 쓰는 것이 적절하다

사용자 관점에서의 운영체제의 목적을 수행하고 있으므로 이는 낭비라고 볼 수 없다

 

Answer:
Single-user systems should maximize use of the system for the user. A
GUI might “waste”CPU cycles, but it optimizes the user’s interaction
with the system.

 

실시간 환경을 위해 운영체제를 작성할 때 프로그래머가 극복해야 하는 주요 어려움은 무엇인가?

실시간 환경에서는 많은 작업이 동시에 일어난다. 마우스도 움직이고, 키보드도 치면서 음악도 듣고...

하지만 CPU는 메모리에 올라온 내용 중 하나의 프로세스만 가져와 수행한다

실시간 작업이 끊김 없이 돌아가기 위해선 효율적으로 CPU 스케줄링을 진행하고 메모리 적재도 해야 하므로

최적 알고리즘을 찾아 CPU가 수행하도록 운영체제에 일을 시켜야 한다

 

주어진 작업을 시간 내에 해결해야 하기 때문에 효율적 프로세스 관리가 필요하다

 

* 실시간 운영체제(Real-Time Operating System)는 CPU 시간 관리에 초점을 맞추어 작성되었다고 한다

 

Answer:
The main difficulty is keeping the operating system within the fixed time
constraints of a real-time system. If the system does not complete a task
in a certain time frame, it may cause a breakdown of the entire system it
is running. Therefore when writing an operating system for a real-time
system, the writer must be sure that his scheduling schemes don’t allow
response time to exceed the time constraint.

 

운영체제의 다양한 정의를 염두에 두고 운영체제에 웹 브라우저 및 메일 프로그램과 같은 응용 프로그램이 포함되어야 하는지 생각해 보라. 포함시킨다와 포함시키지 않는다는 주장 모두의 입장에서 논증하라

1. 포함시키지 않는다

웹 브라우저, 메일 프로그램 등의 프로그램은 사용자가 이용하는 응용 프로그램의 일종이므로 운영체제에 포함해서는 안된다

또한 운영체제는 하드웨어의 작동을 제어하는 역할을 맡는 중요한 소프트웨어인데, 네트워크 연결을 통해 커널 모드로 진입해 하드웨어를 건드린다면 보안상의 문제가 생길 수 있다

응용 프로그램은 운영체제의 일부가 아니며, 이것도 포함할 경우 운영체제의 범위가 너무 넓어진다

 

2. 포함시킨다

ChromeOS와 같은 운영체제도 존재한다. 웹 소켓 테스트용 프로그램이 있었는데, 이 프로그램은 ChromeOS 환경에서 사용이 가능했다. 따라서 웹 브라우저도 커널 활용 및 사용자의 편의를 증가시키는 운영체제의 일종으로 포함해야 한다

 

Answer:
An argument in favor of including popular applications with the
operating system is that if the application is embedded within the
operating system, it is likely to be better able to take advantage of
features in the kernel and therefore have performance advantages
over an application that runs outside of the kernel. Arguments against
embedding applications within the operating system typically dominate
however: (1) the applications are applications - and not part of an
operating system, (2) any performance benefits of running within the
kernel are offset by security vulnerabilities, (3) it leads to a bloated
operating system.

커널 모드와 사용자 모드의 구별은 기본적인 형태의 보호(보안)로서 어떤 기능을 하는가?

커널의 특권 명령을 통해, 사용자가 잘못된 명령을 내려도 하드웨어를 보호한다

커널모드에서는 서로 다른 명령들의 충돌을 제어한다

결국 컴퓨터의 자원들을 보호하기 위해 커널 모드가 작동한다고 생각한다

 

Answer:
The distinction between kernel mode and user mode provides a rudi-
mentary form of protection in the following manner. Certain instructions
could be executed only when the CPU is in kernel mode. Similarly, hard-
ware devices could be accessed only when the program is executing in
kernel mode. Control over when interrupts could be enabled or disabled
is also possible only when the CPU is in kernel mode. Consequently, the
CPU has very limited capability when executing in user mode, thereby
enforcing protection of critical resources

 

다음 중 특권 명령이어야 하는 명령어는 무엇인가?

a. 타이머 설정 (O)

b. 클록 읽기

c. 메모리 내용 삭제 (O)

d. 트랩 명령의 실행

e. 인터럽트 끄기 (O)

f. 장치 상태 테이블의 항목 수정 (O)

g. 사용자에서 커널 모드로 전환 (?)

h. I/O 장치 액세스 (O)

 

a 타이머는 시스템 타이밍과 관련된 작업이기 때문에 커널 모드에서만 허용되어야 한다

b는 일반적으로 안전한 작업으로 분류되어 특권 명령일 필요가 없다고 한다

c 메모리 내용 삭제는 잘못 실행되면 시스템 문제를 일으킬 수 있기에 커널 모드에서 실행해야 한다

d 트랩 명령은 애플리케이션이 시스템 콜을 하는 것. 자체가 특권 명령어는 아니며, 요청된 작업은 종종 특권 명령어가 된다

e 인터럽트 자체는 시스템 상 중요한 명령이므로 커널 모드에서만 실행되어야 한다

f 장치 상태 테이블 항목을 수정하는 작업은 I/O 장치 상태를 변경하는 작업이므로 커널에서 실행되어야 한다

g 사용자 모드 -> 커널 모드 전환은 시스템 특권 레벨을 변경하는 작업이므로 커널 모드에서만 실행되어야 한다

h I/O 장치 엑세스는 하드웨어와 직접 통신하는 것이기 때문에 커널 모드에서 실행되어야 한다

 

커널 모드는 특권 명령을 실행하는 운영체제 모드이다

특권 명령은 커널 모드에서만 실행되어야 하며, 시스템 자원을 관리하고 제어하는 데 사용한다

 

-> 이 문제는 답이 여기저기서 갈린다

b는 확실히 특권 명령일 이유는 없다

그러나 d, g가 논란이 좀 있어보인다

사용자 모드 -> 커널 모드 이동이 특권 명령일 필요는 없는 이유는, 응용 프로그램 단에서 수행할 수 있기 때문이다

 

특권 명령에는 기본적으로

타이머, 인터럽트, I/O 제어 등이 있다

따라서 g는 시스템 콜 자체가 하나의 인터럽트이므로 특권 명령으로 보는 것이 맞지 않나 생각한다

 

d는 자체로는 특권 명령으로 볼 수 없기 때문에 제외했다(사용자 모드에서 트랩 명령을 호출하면, 인터럽트가 발생하여 커널 모드로 전환되기 때문이라 생각했다)

 

그런데, g는 제외하는 것으로 저자는 보고있는 듯 하다

 

Answer:
The following operations need to be privileged: Set value of timer, clear
memory, turn off interrupts, modify entries in device-status table, access
I/O device. The rest can be performed in user mode

일부 초기 컴퓨터는 운영체제를 사용자 작업이나 운영체제 자체에서 수정할 수 없는 메모리 파티션에 배치하여 운영체제를 보호하였다. 이러한 기법에서 발생할 수 있다고 생각되는 두 가지 어려움을 설명하라.

1. 운영체제가 건드릴 수 없는 메모리 영역에 배치되므로 운영체제 유지 보수가 어려워진다

2. 운영체제가 관리하는 정보가 운영체제가 관리하지 않는 메모리에 존재하면, 보안 측면에서 어려움이 생긴다

Answer:
The data required by the operating system (passwords, access controls,accounting information, and so on) would have to be stored in or passedthrough unprotected memory and thus be accessible to unauthorizedusers

 

일부 CPU는 세 개 이상의 작동 모드를 제공한다. 이 중 다중 모드를 사용할 수 있는 두 가지 경우는 무엇인가?

1. 사용자 모드 + 커널 모드에 다른 유형의 사용자 모드를 구별하는 하나의 모드가 더 있음

2. 커널 코드 내에서 다른 구분을 제공

Answer:
Although most systems only distinguish between user and kernel
modes, some CPUs have supported multiple modes. Multiple modes
could be used to provide a finer-grained security policy. For example,
rather than distinguishing between just user and kernel mode, you
could distinguish between different types of user mode. Perhaps users
belonging to the same group could execute each other’s code. The
machine would go into a specified mode when one of these users was
running code. When the machine was in this mode, a member of the
group could run code belonging to anyone else in the group.
Another possibility would be to provide different distinctions within
kernel code. For example, a specific mode could allow USB device drivers
to run. This would mean that USB devices could be serviced without
having to switch to kernel mode, thereby essentially allowing USB device
drivers to run in a quasi-user/kernel mode

 

타이머는 현재 시간을 계산하는 데 사용될 수 있다. 어떻게 계산이 가능한지 간단하게 설명하라

타이머 인터럽트를 통해 타이머 설정을 해놓고, 활성화 될 때 인터럽트 수를 추적해 시간을 계산한다

Answer:
A program could use the following approach to compute the current
time using timer interrupts. The program could set a timer for some
time in the future and go to sleep. When it is awakened by the interrupt,
it could update its local state, which it is using to keep track of the
number of interrupts it has received thus far. It could then repeat this
process of continually setting timer interrupts and updating its local
state when the interrupts are actually raised.

 

캐시가 유용한 두 가지 이유를 제시하라. 어떤 문제를 해결할 수 있는가? 어떤 문제를 야기하는가? 캐시의 크기를 캐싱하는 장치만큼 크게 만들 수 있다면(예: 디스크의 크기와 같은 캐시) 캐시의 용량을 늘린 후 원래 장치를 제거하지 않는 이유는 무엇인가?

1. 두 개 이상의 요소가 서로 데이터를 전송할 때 속도가 다른 경우 유용하다

2. 캐시에 저장하는 경우 가져오는 속도가 빨라 유용하다

 

읽기의 갭을 해결할 수 있다

 

그러나 멀티 프로세싱 환경에서 동시성 문제가 생긴다

캐시에 있는 데이터를 여기저기서 가져다 쓸 때, A가 내용을 바꿔서 아직 메모리에 넣기 전인 경우 B가

똑같이 캐시에서 데이터를 가져오면 A가 쓴 정보가 사라져 데이터가 손실된다

 

빠른 저장장치는 비싸다

아마 1TB HDD와 캐시의 가격은 엄청난 차이가 날 것이다

(캐시 메모리는 메모리 소자 중 가장 비싸다고 한다)

Answer:
Caches are useful when two or more components need to exchangedata, and the components perform transfers at differing speeds. Cachessolve the transfer problem by providing a buffer of intermediate speedbetween the components. If the fast device finds the data it needs in thecache, it need not wait for the slower device. The data in the cache mustbe kept consistent with the data in the components. If a component hasa data value change, and the datum is also in the cache, the cache mustalso be updated. This is especially a problem on multiprocessor systemswhere more than one process may be accessing a datum. A componentmay be eliminated by an equal-sized cache, but only if: (a) the cacheand the component have equivalent state-saving capacity (that is, if thecomponent retains its data when electricity is removed, the cache must
retain data as well), and (b) the cache is affordable, because faster storagetends to be more expensive.

 

분산 시스템의 클라이언트-서버 시스템과 피어 간 모델의 차이를 설명하라

클라이언트-서버 모델은 서버 역할이 확실하다

클라이언트는 요청하고 서버는 서비스를 제공한다

 

그러나 Peer-To-Peer에서는 명확한 구분이 없다(토렌트 옛날에 쓰던거 생각하면 될듯?)

누구나 서버가 되고, 클라이언트가 된다

 

Answer:
The client-server model firmly distinguishes the roles of the client and
server. Under this model, the client requests services that are provided
by the server. The peer-to-peer model doesn’t have such strict roles. In
fact, all nodes in the system are considered peers and thus may act as
either clients or servers—or both. A node may request a service from
another peer, or the node may in fact provide such a service to other
peers in the system.
For example, let’s consider a system of nodes that share cooking
recipes. Under the client-server model, all recipes are stored with the
server. If a client wishes to access a recipe, it must request the recipe from
the specified server. Using the peer-to-peer model, a peer node could ask
other peer nodes for the specified recipe. The node (or perhaps nodes)
with the requested recipe could provide it to the requesting node. Notice
how each peer may act as both a client (it may request recipes) and as a
server (it may provide recipes).

참고

https://os.ecci.ucr.ac.cr/slides/Abraham-Silberschatz-Operating-System-Concepts-10th-2018.pdf

 

https://www.studocu.com/row/document/national-university-of-computer-and-emerging-sciences/operating-systems/operating-system-concepts-chapter-1-exercise-solution-part-1/8319570

 

https://engineeringcode.tistory.com/138