본문 바로가기

Computer Science/OS

(25)
6강. 연습문제 6.1 The first known correct software solution to the critical-section problem for two processes was developed by Dekker. The two processes, P0 and P1, share the follwing variables: boolean flag[2]; / initially false / int turn; The structure of process Pi(i==0 or 1) is shown in Figure 6.27; the other process is Pj(j == 1 or 0). Prove that the algorithm satisfies all three requirements for the cr..
Process Synchronization(2) Semaphore Busy Waiting을 필요로 하지 않는 동기화 도구 🛑 Busy Waiting이란? Critical Section에 들어가기 위해 계속 while문의 조건을 검사하느라 바쁘게 기다리는 것. Semaphore는 Integer 변수의 이름을 Semaphore라고 한다. → 공유된 자원의 수를 가르키는 변수‼️ 두 표준함수 **Wait(S)와 Signal(S)**를 통해서 동작한다. Wait(S)와 Signal(S) 은 Atomic한 Operations으로 주어진 작업을 처리할 때 까지 끝까지 동작한다. Binary Semaphore : Semaphore Integer Variable이 0 or 1의 값만 가지는 것. → mutex (mutual exclusive) lock이라고도 한다...
Process Synchronization(1) Background. 공유하는 변수(ex.전역변수)에 동시에 접근할 때, 데이터 일관성(Data Inconsistency)의 문제가 발생할 수 있다! 따라서 공유하는 변수에 접근하는 작업을 순서화,동기화 시켜야 한다. → Process Synchronization Producer(Data를 제공하는 Process)와 Consumer(Data를 받는 Process) 관계에서 Counter라는 전역변수를 사용함으로써 둘 사이 버퍼공간을 모두 사용할 수 있다. Producer는 Counter++; Consumer는 Counter--; Producer와 Consumer는 Counter를 공유하므로 Counter라는 전역변수에 대한 데이터 접근에 순서화, 동기화를 해주어야 한다. → Race Condition이 ..
5강. 연습문제 5.1 Discuss how the following pairs of scheduling criteria conflict in certain settings. a. CPU Utilization and response time CPU Utilization을 높히기 위해서는 Overhead가 가장 적게 발생하도록 Context Switching이 최소화가 되고, 그렇게 되면 Response time이 최대화가 된다. b. Average turnaround time and maximum waiting time Turnaround time을 최소화 하기 위해서는 SJF 방식을 사용해야 한다. 그렇게 되면 처리기간이 긴 task는 starve하게 되고 이들의 waiting time이 길어진다. c. I/O dev..
CPU Scheduling (2) Multilevel Queue ⇒ 여러개의 Ready Queue를 사용하는 방식 Foreground Queue = Interactive한 작업을 하는 Process가 기다리는 Queue Background Queue = Batch한 작업을 하는 Process가 기다리는 Queue 각 Queue마다 적용되는 알고리즘이 다르다! Ex) Interactive한 작업을 하는 Foreground Queue = Round Robin 방식 => 반응시간이 좋아진다. Batch한 작업을 하는 Background Queue = FCFS 방식 Scheduling method between the queues Fixed Priority Scheduling : 무조건 Foreground Queue먼저 처리하고, Backgro..
CPU Scheduling (1) CPU Scheduling이란? Memory위에 여러 Process들이 올라가 있는 Multiprogramming 환경에서 CPU Utilization(CPU 이용률)을 최대화 하는 것! CPU-Burst와 I/O-Burst가 순환하는 구조를 가진다. CPU Scheduler : 메모리 위의 여러 ready상태의 프로세스 중 하나를 선택하여 CPU에게 넘겨주는 것. CPU Scheduling을 다음과 같은 상황에서 실행된다. Process가 Running → Waiting 일 때 ( I/O 작업이 시작되었을 때) Process가 Terminated 상태일 때 Process가 Running → Ready 일 때 ( Interrupt가 발생했을 때 → Ready Queue안에 변경사항이 생겼을 때) Proc..
4강. 연습문제 4강. 연습문제 4.1 Provide two programming examples in which Multithreading does not provide better performance than a single-threaded solution. (1) Sequential Program은 Multithread에 불리하다. 순차 계산 프로그램 . ex. 개인 세금 계산 프로그램. (2) 환경변수, 작업 디렉토리, 파일을 계속 monitor 해야하는 프로그램. ex. C-shell, korn shell 4.3 Which of the following components of program state are shared a cross threads in a multithread process? a. Regi..
Threads Threads( Light Weight Process ) ⇒ CPU 이용의 가장 작은 단위. Thread ID Program Counter Register Stack Space 등으로 구성되어있다. Peer Threads 와는 Code Section (명령어) Data Section (명령어 실행에 필요한 정보) OS Resources 등을 공유한다. 🛑 하나의 Process에 하나의 Thread만 존재할 때 Heavy Weight Process라고 한다. Multithread에서는 한 Thread가 Blocked 되어도 다른 Thread가 Run할 수 있다. → 처리량과 성능이 증가한다. ⬆️ ⬆️ ⬆️ ⬆️ ⬆️ ⬆️ ⬆️ ⬆️ Thread의 장점 Responsiveness : 반응시간이 좋아진다. ..