1 / 3

Why using mutex ?

Why using mutex ?. The Critical-Section Problem Example: P1: repeat counter= counter +1; until false register1=counter; register1=register1+1; counter=register1;.

Download Presentation

Why using mutex ?

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Why using mutex? The Critical-Section Problem Example: P1: repeat counter= counter +1; until false register1=counter; register1=register1+1; counter=register1; register1=counter; r1=5 register1=register1+1;r1=6 register2=counter; r2=5 register2=register2-1; r2=4 counter=register1;counter=6 counter=register2;counter=4 P2: repeat counter =counter -1; until false register2=counter; register2=register2-1; counter=register2; If one process is in its critical section, then no other processes can be executing in their critical section

  2. Thread Process: a program in execution. program counter stack register address space memory file resources etc Thread: (lightweight process) a basic unit of CPU utilization, and consists of a program counter a register set stack space Share with its code section, data section OS resources (files, etc) Threads need less context switch time

  3. Thread Programming You may have to pass parameters to the function when creating threads. Try: man thr_create to get on line help on this.

More Related