Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.



Published on


Published in: Engineering, Technology, Business
  • Be the first to comment


  2. 2. MULTIPROCESSOR SYSTEM • Multiprocessor System is an interconnection of 2 or more CPU with memory and input-output equipments. • Multiprocessors are classified as MIMD system(Multiple Instruction Multiple Data Stream).
  3. 3. PROCESS • A process is program in execution. • A process can be either – Independent process – Cooperative process Independent Process: – A process is independent if it is not affected by other process executing in the system. – Process will not share data with other process.
  4. 4. Cooperative process: – A process can affect or be affected by other process executing in the system. – Process share data with other process. • Cooperative process requires interprocess communication(IPC) mechanism to exchange data and information. • 2 fundamental models: – Shared memory – Message massing
  5. 5. Shared Memory • A region of memory that is shared by cooperative process is established . • Process can exchange information by reading and writing to shared memory. • It allows maximum speed. • Processor communicates with shared address space. • The main problem in shared memory is process synchronization
  6. 6. MESSGAE PASSING • Communication takes place by means of message exchange between cooperating process. • It is useful for exchanging smaller amount of data. • It is time consuming as there is kernel intervention. • The process will be having separate address space. • Process have private memories.
  7. 7. PROCESS SYNCHRONIZATION MECHSNISMS • Mainly 2 types of synchronizations are used: – Mutual exclusion – Condition synchronization • Mutual Exclusion: If a process is executing its critical section then no other process can execute in their critical section. – A critical section is a piece of code that accesses a shared resource that must not be concurrently accessed.
  8. 8. • Condition synchronization: – When a shared data object is in a state that is inappropriate for executing a given operation. – Any process which attempt such an operation should be delayed until the state of the data object changes to the desired value as a result of other process being executed.
  9. 9. • The mutual -exclusive execution of a critical section,S,whose access is controlled by a variable gate can be enforced by : • an entry protocol denoted by MUTEXBEGIN(gate) • and an exit protocol denoted by MUTEXEND (gate).
  10. 10. • Execution of the MUTEXBEGIN statement should detect the status of the critical section. • If it is busy, the process attempting to enter the critical section must wait. • Execution of the MUTEXEND statement should reset the status of the critical section to idle and provide a mechanism to schedule the waiting process to use the critical section.
  11. 11. IMPLEMENTATION LOCK and UNLOCK operations : • consider that there is a single gate that each process must pass through to enter a CS and also leave it. • If a process attempting to enter the CS finds the gate unlocked (open) it locks (closes) it as it enters the CS so that all other processes attempting to enter the CS will find the gate locked. • On completion, the process unlocks the gate and exits from the CS.
  12. 12. • Assuming that the variable • gate =0 means that the gate is open • gate=1 means that the gate is closed, • the access to a CS controlled by the gate can be written as: LOCK (gate) execute critical section UNLOCK (gate)
  13. 13. • The LOCK(x) operation may be implemented as follows: Var x:shared integer; LOCK (x):begin var y: integer; y x; While y =1 do yx;//wait until gate is open // x1 //set gate to unavailable status // end
  14. 14. • The UNLOCK(x) operation may be implemented as UNLOCK(x): x  0; DISADVANTAGE OF LOCK MECHANISM: • two or more processes may find x=0 before one reaches the x1 statement. • processes attempting to enter critical sections are busy accessing common variables. • This is called busy –wait or spin -lock, which results in performance degradation.
  15. 15. • An important property of locks is that : • a process does not relinquish the processor on which it is executing while it is waiting for a lock held by another process. • Thus, it is able to resume execution very quickly when the lock becomes available.
  16. 16. SYNCHRONIZATION WITH SEMAPHORE • Dijkstra invented the two operations P and V, which can be shared by many processes and which implement the mutual -exclusion mechanism efficiently. • The P and V operations are called primitives . • They operate on a special common variable called a semaphore, which indicates the number of processes attempting to use the critical section.
  17. 17. • var s: semaphore • P(s): MUTEXBEGIN (s) s  s-1; If s < 0 then begin Block the process executing the P(s) and put it in a FIFO queue associated with the semaphore s; end MUTEXEND
  18. 18. • V(s): MUTEXBEGIN (s) SS + 1; If s <= 0 then begin if an inactive process associated with semaphore s exists, then wake up the highest priority blocked process associated with s and put it in a ready list. end MUTEXEND
  19. 19. • When s can take values of 0 or 1, it is called a binary semaphore. • If s takes any integer value, it is called a counting semaphore
  20. 20. • Eg.Producer Consumer Problem • consider a finite buffer BUFFER of size n arranged as a circular queue in which the slot positions are named 0, 1,…., n-1. • There are the two pointers c and p, which correspond to the "head" and "tail" of a circular queue, respectively. • The consumer consumes the message from the head c by updating c and then retrieving the message. • The producer adds a message to the buffer by updating p before the add operation.
  21. 21. • Initially, p= c = 0, which indicates that the buffer is empty. • Let the variables empty and full be used to indicate the number of empty slots and occupied slots, respectively.
  22. 22. • The empty variable is used to inform the producer of the number of available slots. • the full• variable informs the consumer of the number of messages needed to be consumed. • The producer or consumer will be suspended when empty=0 or full = 0, respectively.
  23. 23. • shared record begin var p, c: integer; var empty, full: semaphore; var BUFFER [0:n -1]: message; end initial empty = n, full = 0, p = 0, c = 0;
  24. 24. • Cobegin Producer: begin var m: message; Cycle begin Produce a message m; P(emptv); p(p+1)modn; BUFFER [p]  m; // place message in buffer// V(full) end end
  25. 25. • Consumer: begin var m: message; Cycle begin P (full); c(c+1) mod n; m  BUFFER [c]; // remove message from buffer // V (emptv); Consume message m; end end coend
  26. 26. THANK YOU