OS-5(Context Switch/Critical Section)
포스트
취소

OS-5(Context Switch/Critical Section)

What is Context Switch

  • Context Switch : replace PCB inside the memory with other PCB.
    1. store Process A’s PCB
    2. load Process B’s PCB to memory from disk
    3. When system call is occured or interrupt, store Process B’s PCB
    4. load Process C’s PCB to memoery from disk

What is Shared resource and Critical section

Critical Section’s three features should be satisfied

  • mutual exclusion : if process A run CS(Critical Section), other can not go into
  • bounded waiting : Process should not wait indefinitely
  • progress flexibility, progress : If there is no process in the CS, any process can enter and utilize the resource.

How to satisfy CS features

  • Shared Resource : resource(Printer, specific memory location, files, data) that can be shared with other processes, threads.
  • Critical Section : Areas that depend on the order of access. To solve with this problems, mutex, semaphore exist. mutex_vs_semaphore
    • mutex : before using critical section, first lock, after use, second release.
    • semaphore : can access critical section with multiple users.

What is Deadlock

  • Deadlock : A state in which two or more processes are stopped waiting for each other’s resources
이 기사는 저작권자의 CC BY 4.0 라이센스를 따릅니다.