> For the complete documentation index, see [llms.txt](https://liuyang89116.gitbook.io/operating-system/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://liuyang89116.gitbook.io/operating-system/summary_ch5.md).

# Summary ch5

1. **Race Condition:**&#x41; 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.&#x20;
2. **Critical Section:**

   ![](/files/-Lpv9P8BO6468KL8XghA)
3. **Solution to Critical Section Problem:** &#x20;

   (1)**Mutual Exclusion** - If process Pi is executing in its critical section, then no other processes can be executing in their critical sections &#x20;

   (2)**Progress** – When no process is in a critical section, any process that requests entry to its critical section must be permitted to enter without delay.  &#x20;

   (3)**Bounded Waiting** -  A bound must exist on the number of times that other processes are allowed to enter their critical sections after a process has made a request to enter its critical section and before that request is granted
4. **Mutual Exclusion: Hardware Support** &#x20;

   (1)**Interrupt Disabling:** &#x20;

   A process runs until it invokes an operating system service or until it is interrupted; &#x20;

   Disabling interrupts guarantees mutual exclusion &#x20;

   (2)**Disadvantages:** &#x20;

   Processor is limited in its ability to interleave programs; &#x20;

   Will not work in multiprocessor architecture.
5. **Mutual Exclusion Machine-Instruction:** &#x20;

   **Advantages:** &#x20;

   (1)Applicable to any number of processes on a single processor &#x20;

   (2)Processes on multiple processors(as long as processors share main memory) &#x20;

   (3)simple and therefore easy to verify &#x20;

   (4)It can be used to support multiple critical sections &#x20;

   **Disadvantages:** &#x20;

   (1)Busy-waiting consumes processor time &#x20;

   (2)Starvation is possible when a process leaves a critical section and more than one process is waiting&#x20;
6. **Semaphore** is a variable that has an integer value &#x20;

   (1)May be initialized to a nonnegative number &#x20;

   (2)Wait operation decrements the semaphore value &#x20;

   (3)Signal operation increments semaphore value
7. **Mutual Exclusion Using Semaphores:** &#x20;

   ![](/files/-Lpv9P8DP-rsMTkJYKjZ)
