(운영체제 카테고리의 글은 Abraham Silberschatz의 'Operating System Concepts'를 기반으로 작성합니다.)
Race Condition 문제
: The situation where several processes access and manipulate shared data concurrently.
To prevent race condition, concurrent processese must be synchronized.
동기화 방법 1. Critical Section (임계 영역)
Each Process has critical section segment of code.
When one process in critical section, no other may be in its critical section.
Each process must ask permission to enter critical section in entry section, may follow critical section with exit section, then remainder section.
조건 ① Mutual Exclusion : 누가 들어가 있을 땐, 아무도 못 들어감
조건 ② Progress : 아무도 없을 땐, 대기시키면 안됨
조건 ③ Bounded Waiting : 누가 들어가서 안나오면 안됨, 시간 제한 필요
2개 프로세스일 때, Algorithm :
n개 프로세스일 때, Bakery Algorithm :
* Bakery Algorithm은 SW적 구현, 많은 시스템이 HW적 기능을 지원함
동기화 방법 2. Semaphore
Synchronization tool that does not require busy waiting (while loop waiting)
자원이 S개, 모두 사용중이면 S=0, 다 썼으면 S++
Implementation :
* Deadlock : two or more processes are waiting indefinitely for an event that can be caused by only one of the waiting processes.
* Starvation : indefinite blocking. a process may never be removed from the semaphore queue in which it is suspended.
동기화의 문제
① Bounded Buffer Problem
- Producer Process
- Consumer Process
② Readers and Writers Problem
- Writers
- Readers
③ Dining Philosopers Problem
'Computer Science' 카테고리의 다른 글
/작성 예정/ 7. 메모리 관리 (0) | 2023.03.16 |
---|---|
/작성예정/ 6. Deadlock (교착상태) (0) | 2023.03.16 |
OS - 4. 스케줄링 (Scheduling) (0) | 2023.03.16 |
OS - 3. Threads (쓰레드) (0) | 2023.03.16 |
OS - 2. Process (state, PCB, 스케줄링, context switching, IPC) (0) | 2023.03.16 |