Presentation is loading. Please wait.

Presentation is loading. Please wait.

“Language Mechanism for Synchronization”

Similar presentations


Presentation on theme: "“Language Mechanism for Synchronization”"— Presentation transcript:

1 “Language Mechanism for Synchronization”
Poornima Institute of Engineering & Technology, Jaipur Department of Computer Engineering A Presentation on Presented by,: Manish Bhardwaj Assistant Professor “Language Mechanism for Synchronization” Lecture No-15 Subject Code -8 CS3 Subject Name- Ds

2 Language Mechanisms for Synchronization
Concurrent programming allows for : concurrent processing with some specifications. Allows for synchronization to communicate.

3 Language Mechanisms for Synchronization
Language constructs Shared Variable Synchronization Semaphore : A shared-variable and system call approach Monitor: A Data Type Abstraction Approach Conditional Critical Region : A control Structure Approach Serializer : A combined Data Abstraction and Control Structure Approach Path Expression: A Data Abstraction and Program Structure Approach

4 Language Mechanisms for Synchronization
Message Passing Synchronization Asynchronous Message Passing Synchronous Message Passing Communicating Sequential Processes: An Input / Output Approach Remote Procedure Call : A Procedure Call and Asymmetrical Communication Approach Ada Rendezvous : A Procedure Call and Symmetrical Communication Approach

5 Difference in Sequential and Concurrent Language
Specification of concurrent activities Synchronization of processes Interprocess communication Nondeterministic execution of processes

6 Language Constructs for Procedural Languages
Program Structure Data Structures Control Structures Procedures and System Calls Input and Output Assignments

7 Program Structure How programs and subcomponents of program
(procedures. Variables. Constants. Statements, blocks , expressions ,terms, etc) are managed. Sequential execution is assumed until control statements are altered explicitly.

8 Data Structures Represent Objects , Data Type abstraction and efficient implementation ways.

9 Control Structures Regulates program execution flow.
One-in-one-out control structure mechanism is used generally. For example if-then-else, repeat-until, while-do etc. Subroutine calls. Returns and exit are also used.

10 Procedures and System calls
Responsible for flow of execution. Parameter passing Activation of special routines Activation of system services

11 Input and Output Responsible for Results of program execution.
Message Passing communication can be used for input output.

12 Assignments Responsible for Side effects for data objects.
State of program executions.

13 Shared Variable Synchronization
Responsible for Synchronization of concurrent processes in a centralized operating system. Arrangement of sharing variables. Simulation of shared variable synchronization by message passing rather than message passing or client server communication directly.

14 Shared Variable Synchronization Semaphore : A Shared- variable and System Call Approach
Semaphore is : Built in System Data Type. A variable Lock is acquired and released for synchronization. Provides most primitive locking mechanisms only. Drawback is loss of transparency.

15 Shared Variable Synchronization Semaphore : A Shared- variable and System Call Approach
Example: the Reader/Writer Problems synchronization + concurrency if DB empty, allow anyone in if reader in DB, writer not allowed in if writer in DB, nobody allowed in

16 Shared Variable Synchronization Semaphore : A Shared- variable and System Call Approach

17 Shared Variable Synchronization Semaphore : A Shared- variable and System Call Approach
Example: the Reader/Writer Problems synchronization + concurrency Variations Reader preference Allow a reader in if other readers are in Strong reader preference Allow readers in when writer leaves Weak reader preference When writer leaves, select a process at random

18 Shared Variable Synchronization Semaphore : A Shared- variable and System Call Approach
Example: the Reader/Writer Problems synchronization + concurrency Variations Weaker writer preference Allow a writer in when writer leaves Writer preference Do not allow readers in if writer is waiting

19 Shared Variable Synchronization Semaphore : A Shared- variable and System Call Approach
Semaphore solution to the weak reader preference problem

20 Semaphore solution to the weak reader preference problem
var mutex=1, db=1: semaphore; rc=0: integer reader processes writer processes do (forever) BEGIN otherStuff() P(mutex) rc := rc + 1 if rc = 1 then P(db) P(db) V(mutex) read database write database rc := rc -1 if rc = 0 then V(db) V(db) END

21 Shared Variable Synchronization Monitor: A Data Type Abstraction Approach
Loss of transparency removed Object Model Concept Consists of procedures , declarations for local variables and initialization procedures. Only one object can be active at a time. More Structured than Semaphore Wait and Signal are used for coordination.

22 Monitor solution to weak reader preference problem

23 Shared Variable Synchronization Conditional Critical Region: A Control Structure Approach
Drawback in monitor is need of procedure to be exclusive and concurrent too. Structured version of Semaphore. Critical section codes are expressed by region-begin-end. When predicate is used for testing a condition. Drawback of CCR is infeasibility of Separate compilation and common address space.

24 Shared Variable Synchronization Conditional Critical Region: A Control Structure Approach

25 Shared Variable Synchronization Serializer: A Combined Data Abstraction and Control Structure Approach Drawback in monitor is need of procedure to be exclusive and concurrent too. Serializer is the solution. It Provides 2 regions , one provides mutual exclusion and other allow concurrency (Hollow Region). Joincrowd-then-begin-end structure is used.

26 Shared Variable Synchronization Path Expression: A Data Abstraction and Program Structure Approach
Abstraction of Data type. Procedures in abstract data type donot contain any explicit reference to any synchronization. Order of execution must follow the constraints imposed by path expressions. It Specifies the way to define the operation invocation for a shared object.

27 Synchronization mechanisms and Language Facilities

28 Message Passing Synchronization
Asynchronous: non-blocking send, blocking receive Synchronous: blocking send, blocking receive

29 Message Passing Synchronization Asynchronous Message Passing

30 Message Passing Synchronization Synchronous Message Passing

31 Message Passing Synchronization Communicating Sequential Process: An Input / Output Approach

32 Message Passing Synchronization Ada Rendezvous: A Procedure Call and Symmetrical Communication Approach

33 Object Model Resource Servers
Resource manager is responsible for use of shared resources.

34 Object Model Resource Servers


Download ppt "“Language Mechanism for Synchronization”"

Similar presentations


Ads by Google