Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

1/4

운영체제 중간시험 (2020학년도 2학기, 2020/10/29)

학과 학번 학년 이름

☆ 답안지 각 페이지 상단에 소속학과, 학번, 학년, 이름을 작성하세요.

⑴ 다음 괄호에 들어갈 용어를 아래 box에서 찾아 채우시오.


- A/An (① ) is a key way in which hardware interacts with the operating system. A hardware device
triggers a/an (① ) by sending a signal to the CPU to alert the CPU that some event requires
attention.
- The main memory is usually a/an (② ) storage device that loses its contents when power is turned off
or lost.
- To best utilize the CPU, modern operating systems employ (③ ), which allows several processes to be
in memory at the same time, thus ensuring that the CPU always has a process to execute.
- The hardware allows (④ ) instructions to be executed only in kernel mode. If an attempt is made to
execute a/an (④ ) instruction in user mode, the hardware does not execute the instruction, but rather
treats the instruction as illegal and traps it to the operating system.
- The (⑤ ) provide an interface to the services made available by an operating system. Programmers use
them for accessing operating system services.
- The fundamental idea behind a/an (⑥ ) is to abstract the HW of a single computer into several
different execution environments, thereby creating the illusion that each separate execution environment is
running its own private computer.
- Each process is represented in the operating system by a/an (⑦ ), which contains many pieces of
information associated with it, including process state, scheduling information, memory management information,
and so on.
- Giving the CPU to another process requires saving the state of the current process and loading the saved state
of the another new process. This task is known as a/an (⑧ ).
- (⑨ ) scheduling allocates the CPU to each process for a time quantum. If the process does not
relinquish the CPU before its time quantum expires, the process is preempted, and another process is scheduled
to run for a time quantum.
- The dispatcher should be as fast as possible, since it is invoked during every process switch. The time it takes
for the dispatcher to stop one process and start another running is known as the (⑩ ).
- A solution to the problem of indefinite blockage of low-priority processes is (⑪ ), which is a technique
of gradually increasing the priority of processes that wait in the system for a long time.
- Because of the high cost of invalidating and repopulating caches, most SMP systems try to avoid migration of
processes from one processor to another and instead attempt to keep a process running on the same
processor. This is known as (⑫ ).
- A situation, where several processes access and manipulate the same data concurrently and the outcome of the
execution depends on the particular order in which the access takes place, is called a/an (⑬ ).
- Multiple processes are permitted to concurrently acquire a/an (⑭ ) lock in read-mode, but only one
process may acquire the lock for writing, as exclusive access is required for writers.
- There are 4 necessary conditions for deadlock, including mutual exclusion, hold and wait, no preemption, and
(⑮ ).

[용어 box]
exception volatile privileged aging deadlock
interrupt context saving preemptive priority inversion reader-writer
PCB context switching circular wait run queue round-robin
safe process multiprogramming dispatcher latency virtualization
race condition processor affinity ticket system call response time
2/4

⑵ 아래 program code가 실행되는 경우 이를 실행하는 process를 포함하여 총 몇 개의 process가 생성되는


가? 그 이유를 함께 설명하시오.

⑶ CPU 스케줄링 기법으로 MFQ(Multi-level Feedback Queue) 기법을 사용하는 시스템이 있다. 이 시스템에서
Time 0에 3개의 프로세스 A, B, C가 A-B-C의 순서로 ready queue에 도착했다고 가정하자. (세 프로세스
모두 time 0에 ready queue에 도착하지만, 프로세스 A가 제일 먼저, 그리고 프로세스 C가 제일 마지막에
도착함.) 프로세스 A, B, C의 next burst time이 각각 120, 70, 30 이고, 이 시스템이 아래와 같은 3개의
ready queue(Q0, Q1, Q2)를 가지고 주어진 스케줄링 기법을 사용한다고 할 때 다음 물음에 답하시오. (단,
context switching에 소요되는 시간은 무시한다)

❚ Q0: Time quantum 20인 RR(Round-Robin) 스케줄링 기법 사용


❚ Q1: Time quantum 40인 RR(Round-Robin) 스케줄링 기법 사용
❚ Q2: SPN(Shortest Process Next) 스케줄링 기법 사용

❚ 모든 프로세스는 최초에 Q0으로 진입하며, Qi에서 스케줄 받아 실행하고 time quantum을 모두 소모할 경우 Qi+1로 진입
❚ Q0의 우선순위가 가장 높고, Q2의 우선순위가 가장 낮으며, 스케줄링은 항상 높은 우선순위의 queue에서부터 이루어짐

① 프로세스 A, B, C가 각자 주어진 CPU burst를 마칠 때까지의 waiting time은 각각 얼마인가?


② 프로세스 A, B, C가 모두 주어진 CPU burst를 마칠 때까지 context switching은 총 몇 번 발생하는가?
(단, time 0의 경우와 세 프로세스의 CPU burst가 모두 끝나는 순간의 context switching은 배제한다.)

⑷ 두 개의 프로세스 P1, P2가 time 0에 ready queue에 (P1, P2의 순서로) 도착해 있고 (즉, 두 프로세스의
arrival time이 모두 0임), P1의 next burst time이 90, P2의 next burst time이 10 이라 가정하자. FIFO,
SPN, RR(time-quantum=4) 등 3가지 스케줄링 기법을 사용했을 경우 각각에 대해 Gantt chart를 보이고,
또한 각 경우에 대한 turnaround time(TT), waiting time(WT), mean waiting time 
W T 을 구하시오(아래 표
와 같은 형태로 답하시오).

FCFS WT TT 
WT SPN WT TT 
WT RR(4) WT TT 
WT

P1 P1 P1

P2 P2 P2
3/4

⑸ 아래는 sleeping barber problem을 설명하고 있다. 이를 semaphore로 구현하려 할 때, 아래 주어진


semaphore 및 기타 변수들을 사용하여 만들어진 와 코드의 빈 곳을 채우시오.

A barbershop consists of a waiting room with chairs and the barber room containing a barber chair.
If there are no customers to be served, the barber goes to sleep. If a customer enters the barbershop
and all chairs are occupied, then the customer leaves the shop. If the barber is busy but chairs are
available, the customer sits in one of the free chairs. If the barber is asleep, the customer wakes up
the barber. Write a program to coordinate the barber and the customers, using semaphore.

⑹ Semaphore, Spinlock, Ticket lock 각각에 대해 어떤 기법들이 아래 특징을 갖는지 나열하시오.

Busy waiting을 한다 ①
동기화 과정에 상대적으로 context switching overhead를 갖는다 ②
Sleep 상태에서 wakeup 하는 순서가 미리 정해진다 ③
Single-CPU single-core 시스템에서는 사용하지 않는다 ④
동기화 과정에 Starvation 가능성이 있다 ⑤
4/4

⑺ 세 개의 process (P1, P2, P3)와 세 종류의 resource type (R1, R2, R3)를 갖는 시스템에서 자원 (R1, R2,
R3)의 resource unit 개수가 (2, 3, 2)라 가정하자. 현재의 시스템 상태가 아래 그림에서 보인 바와 같다고
하고 물음에 답하시오.
① 주어진 현재 상태가 deadlock 상태인지에 대해 답하시오.
② 현재 상태가 deadlock 상태라면 deadlock 상태에 놓인 프로세스들을 나열하고, 그렇지 않은 경우에는 “없음”으로 답하시오.
③ 현재 상태에서 process (P1, P2, P3)의 termination cost가 (20, 10, 15)라 할 때 deadlock을 제거하기 위해 아래 두
recovery 기법에 의해 termination 되는 프로세스들을 각각 보이시오.
대상 process가 없는 경우에는 “없음”으로 답하시오.
ⓐ Lowest-termination-cost process first
ⓑ Minimum cost recovery

⑻ 어느 시스템에 하나의 자원형(resource type)만이 존재하고 이에 r개의 단위자원(resource units)이 있으며,


이 시스템에 p개의 프로세스가 존재한다고 가정하고 다음 물음에 답하시오.
(p, r, N 등의 수식으로 답하시오)
① 각 프로세스들이 어느 순간에도 최대 2개까지의 단위자원만을 필요로 한다면 이 시스템에서 교착상태
의 발생을 근본적으로 없애기 위한 필요충분조건은?

(r ≥ )
② 각 프로세스들이 어느 순간에도 최대 3개까지의 단위자원만을 필요로 한다면 이 시스템에서 교착상태
의 발생을 근본적으로 없애기 위한 필요충분조건은?

(r ≥ )
③ 각 프로세스들이 어느 순간에도 최대 N개까지의 단위자원만을 필요로 한다면 이 시스템에서 교착상태
의 발생을 근본적으로 없애기 위한 필요충분조건은?

(r ≥ )

끝. 수고했습니다.

You might also like