Why using mutex
Download
1 / 3

Why using mutex ? - PowerPoint PPT Presentation


  • 86 Views
  • Uploaded on

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

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about ' Why using mutex ?' - maxine-lester


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.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
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;

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


Thread
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


Thread programming
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.