SlideShare une entreprise Scribd logo
1  sur  43
INTERPROCESSOR
COMMUNICATION AND
PROCESS SYNCHRONIZATION
Presented By
Neena R Krishna
S8,BTECH CSE
SNGIST
CONTENTS
• INTRODUCTION
• INTERPROCESSOR COMMUNICATION
• PROCESS SYNCHRONIZATION AND
SEMAPHORE
INTRODUCTION
• Independent process cannot affect or be
affected by the execution of another process
• Cooperating process can affect or be affected by
the execution of another process
• Advantages of process cooperation
– Information sharing
– Modularity
– Convenience
Interprocessor Communication
• Exchange of data between two or more processes.
– Os provide facilities for IPC.
• IPC facility provides two operations:
send(message)and receive(message) (message size fixed or
variable).
• If P and Q wish to communicate, they need to:
–establish a communication link between them
exchange messages via send/receive
Contd..
• Multiprocessor and multiple memory modules are
connected together via some interconnection
network.
• They fall on two categories:-
1)Shared memory
2)Message passing
INTERPROCESSOR COMMUNICATION
THROUGH ADDRESS SPACE SHARING
INTERPROCESSOR COMMUNICATION
VIA KERNAL SPACE
SHARED MEMORY
• Processors exchange information through
their central shared memory system.
• Inter co-ordination through a global memory
shared by all processor.
• Server system that communicate through a
bus and cache memory controller.
• Access to shared memory is balanced
– Symmetric multiprocessor
Contd..
• Each processor has equal opportunities to
read/write to memory including equal access
speed.
PROCESSORs
Registers
Local memory
banks (additional
memory resource
Cache
Buffers
Contd..
• Basic issues in the design of shared memory
system have to be taken in consideration :-
1)Access Control
2)Synchronization
3)Protection and Security
ACCESS CONTROL
• Determines which process access are possible to
which resource.
• The latter contain flag that determine the legality
of each access attempt.
• If there are access attempt to resources then until
the desired access is completed, all disallowed
access are attempt and illegal process are blocked.
SYNCHRONIZATION
• Constraints limit the time of access from
sharing processes to shared resource.
• Appropriate synchronization ensures that the
information flows properly and ensure system
functionality.
PROTECTION AND SECURITY
• It is a system feature that prevents processes
from making arbitrary access to resource
belonging to other processes.
• Sharing and protection are incompatible:-
– Sharing allow access & protection restricts it.
FEATURES
• All communications are done using implicit
loads and stores to a global address space.
• Synchronization and communication are
distinct.
MESSAGE PASSING
• Combine the local memory and processor at
each node of the interconnection network.
• There is no global memory.
– Move data from one local memory to another by
means of message passing.
– Done by a send/reciever pair of commands and
dealing consistency issues.
– Eg: c.1990 Ncube.
Contd..
• A node in message passing system of
processor and its local memory.
• They are able to store message buffers and
able to perform send/receive operation at the
same time as processing.
• Processor do not share a global memory and
each processor has access to its own address
space.
• Basic advantage :-
– Scalable.
SYNCHRONIZATION
• Required when one process must wait for
another to complete some operation before
proceeding.
– Eg:-one process (called a writer) may be writing
data to a certain main memory area, while
another process (a reader) may be reading data
from that area and sending it to the printer. The
reader and writer must be synchronized so that
the writer does not overwrite.
IMPORTANCE OF SYNCHRONIZATION
• Prevention and elimination of race conditions,
deadlocks and starvation.
• Data integrity/consistency.
• Collaboration.
• Efficiency.
SYNCHRONIZATION PROBLEMS
• Race conditions
– the exact timing in the execution of concurrent
processes is critical
• Critical sections
– part of a program that must be protected from
interference
– usually resolved via mutual exclusion
• Mutual exclusion
– the usage of resources by processes is restricted
– usually: only one process may use one instance of a
resource
RACE CONDITION
TYPES OF SYNCHRONIZATION
• Barrier
• Lock
• Semaphore
BARRIER
• Usually implies that all tasks are involved
• Each task performs its work until it reaches
the barrier. It then stops, or "blocks".
• When the last task reaches the barrier, all
tasks are synchronized.
• What happens from here varies. Often, a
serial section of work must be done. In other
cases, the tasks are automatically released to
continue their work.
LOCK
Suppose there are 2 processes
– Write-process 1 and Read-process 2
PROCESS 1
WRITE
MEMORY LOCKED
AFTER WRITING
UNLOCK MEMORY
PROCESS 2
READ
Contd..
• 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
• The UNLOCK(x) operation may be
implemented as
UNLOCK(x): x  0;
SEMAPHORE
• It is a resource that contains an integer value
and allows process to synchronize by testing
and setting this value on a single atomic
operations.
– Process that test the value of a semaphore and
sets it to a different value,is guaranteed no other
process will interfere with the operation in the
middle.
Contd..
• Two types of operations :-
– Wait
– Signal.
FEATURES OF SEMAPHORE
• Semaphores are used to synchronize operations
when processes access a common, limited, and
possibly non-shareable resource.
• Each time a process wants to obtain the resource,
the associated semaphore is tested. A positive,
non-zero semaphore value indicates the resource
is available.
• Semaphore system calls will, by default, cause the
invoking process to block if the semaphore value
indicates the resource is not available
TYPES OF SEMPAHORE
• COUNTING SEMAPHORE
– Semaphores controlling access to N (multiple)
resources, thus assuming a range of non-negative
values, are frequently.
• BINARY SEMAPHORE
– Semaphores that control access to a single
resource, taking the value of 0 (resource is in use)
or 1 (resource is available).
SEMAPHORE IMPLEMENTATION
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
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
EXAMPLE
PRODUCER CONSUMER PROBLEM
Producer
While(true)
{
while(((in+1) % Buffer_Size)==out);
buffer[in]=item;
in=(in+1)%Buffer_Size;
}
Contd..
Consumer
While(true)
{
while(in==out);
item=buffer[out];
out=(out+1)%Buffer_Size;
return item;
}
Contd..
Solution with Semaphore
Empty=n,full=0.mutex=1
Producer
Do
{
//Produce item
wait(empty);
wait(mutex);
//add item to the buffer
signal(mutex);
signal(full);
}while(true);
Contd..
Consumer
Do
{
wait(full);
wait(mutex);
//Remove an item from buffer
signal(mutex);
signal(empty);
//consume the remove item
}while(true);
Multiprocessing -Interprocessing communication and process sunchronization,semaphore

Contenu connexe

Tendances

Memory management in operating system | Paging | Virtual memory
Memory management in operating system | Paging | Virtual memoryMemory management in operating system | Paging | Virtual memory
Memory management in operating system | Paging | Virtual memoryShivam Mitra
 
CSMA /CD PPT ON SLIDESHARE
CSMA /CD PPT ON SLIDESHARECSMA /CD PPT ON SLIDESHARE
CSMA /CD PPT ON SLIDESHAREKhushboo Pal
 
Chapter7 Computer Networks
Chapter7 Computer NetworksChapter7 Computer Networks
Chapter7 Computer NetworksMuhammad Waqas
 
clock synchronization in Distributed System
clock synchronization in Distributed System clock synchronization in Distributed System
clock synchronization in Distributed System Harshita Ved
 
Presentation Routing algorithm
Presentation Routing algorithmPresentation Routing algorithm
Presentation Routing algorithmBasit Hussain
 
MULTILEVEL QUEUE SCHEDULING
MULTILEVEL QUEUE SCHEDULINGMULTILEVEL QUEUE SCHEDULING
MULTILEVEL QUEUE SCHEDULINGgarishma bhatia
 
2019 3 testing and verification of vlsi design_sta
2019 3 testing and verification of vlsi design_sta2019 3 testing and verification of vlsi design_sta
2019 3 testing and verification of vlsi design_staUsha Mehta
 
Operating system services 9
Operating system services 9Operating system services 9
Operating system services 9myrajendra
 
Automatic Test Pattern Generation (Testing of VLSI Design)
Automatic Test Pattern Generation (Testing of VLSI Design)Automatic Test Pattern Generation (Testing of VLSI Design)
Automatic Test Pattern Generation (Testing of VLSI Design)Usha Mehta
 
Kernel mode vs user mode in linux
Kernel mode vs user mode in linuxKernel mode vs user mode in linux
Kernel mode vs user mode in linuxSiddique Ibrahim
 
Real-Time Scheduling
Real-Time SchedulingReal-Time Scheduling
Real-Time Schedulingsathish sak
 
Real time Scheduling in Operating System for Msc CS
Real time Scheduling in Operating System for Msc CSReal time Scheduling in Operating System for Msc CS
Real time Scheduling in Operating System for Msc CSThanveen
 
Block diagram of motherboard
Block diagram of motherboardBlock diagram of motherboard
Block diagram of motherboardShreyJagad
 
Multiprocessor architecture
Multiprocessor architectureMultiprocessor architecture
Multiprocessor architectureArpan Baishya
 

Tendances (20)

Memory management in operating system | Paging | Virtual memory
Memory management in operating system | Paging | Virtual memoryMemory management in operating system | Paging | Virtual memory
Memory management in operating system | Paging | Virtual memory
 
CSMA /CD PPT ON SLIDESHARE
CSMA /CD PPT ON SLIDESHARECSMA /CD PPT ON SLIDESHARE
CSMA /CD PPT ON SLIDESHARE
 
Sliding window protocol
Sliding window protocolSliding window protocol
Sliding window protocol
 
Chapter7 Computer Networks
Chapter7 Computer NetworksChapter7 Computer Networks
Chapter7 Computer Networks
 
clock synchronization in Distributed System
clock synchronization in Distributed System clock synchronization in Distributed System
clock synchronization in Distributed System
 
Presentation Routing algorithm
Presentation Routing algorithmPresentation Routing algorithm
Presentation Routing algorithm
 
MULTILEVEL QUEUE SCHEDULING
MULTILEVEL QUEUE SCHEDULINGMULTILEVEL QUEUE SCHEDULING
MULTILEVEL QUEUE SCHEDULING
 
Network protocals
Network protocalsNetwork protocals
Network protocals
 
Computer performance
Computer performanceComputer performance
Computer performance
 
2019 3 testing and verification of vlsi design_sta
2019 3 testing and verification of vlsi design_sta2019 3 testing and verification of vlsi design_sta
2019 3 testing and verification of vlsi design_sta
 
Operating system services 9
Operating system services 9Operating system services 9
Operating system services 9
 
Automatic Test Pattern Generation (Testing of VLSI Design)
Automatic Test Pattern Generation (Testing of VLSI Design)Automatic Test Pattern Generation (Testing of VLSI Design)
Automatic Test Pattern Generation (Testing of VLSI Design)
 
Lecture 5 inter process communication
Lecture 5 inter process communicationLecture 5 inter process communication
Lecture 5 inter process communication
 
Kernel mode vs user mode in linux
Kernel mode vs user mode in linuxKernel mode vs user mode in linux
Kernel mode vs user mode in linux
 
Scheduling algorithms
Scheduling algorithmsScheduling algorithms
Scheduling algorithms
 
Real-Time Scheduling
Real-Time SchedulingReal-Time Scheduling
Real-Time Scheduling
 
Real-Time Operating Systems
Real-Time Operating SystemsReal-Time Operating Systems
Real-Time Operating Systems
 
Real time Scheduling in Operating System for Msc CS
Real time Scheduling in Operating System for Msc CSReal time Scheduling in Operating System for Msc CS
Real time Scheduling in Operating System for Msc CS
 
Block diagram of motherboard
Block diagram of motherboardBlock diagram of motherboard
Block diagram of motherboard
 
Multiprocessor architecture
Multiprocessor architectureMultiprocessor architecture
Multiprocessor architecture
 

En vedette

En vedette (12)

Réseau sémaphore 7
Réseau sémaphore 7Réseau sémaphore 7
Réseau sémaphore 7
 
SYNCHRONIZATION IN MULTIPROCESSING
SYNCHRONIZATION IN MULTIPROCESSINGSYNCHRONIZATION IN MULTIPROCESSING
SYNCHRONIZATION IN MULTIPROCESSING
 
Multiprocessor
MultiprocessorMultiprocessor
Multiprocessor
 
Mutual exclusion and synchronization
Mutual exclusion and synchronizationMutual exclusion and synchronization
Mutual exclusion and synchronization
 
Lecture 48
Lecture 48Lecture 48
Lecture 48
 
Offshore Software Development Company
Offshore Software Development CompanyOffshore Software Development Company
Offshore Software Development Company
 
Lecture 39
Lecture 39Lecture 39
Lecture 39
 
13. multiprocessing
13. multiprocessing13. multiprocessing
13. multiprocessing
 
Lecture 47
Lecture 47Lecture 47
Lecture 47
 
Multiprocessor system
Multiprocessor system Multiprocessor system
Multiprocessor system
 
Inter Process Communication Presentation[1]
Inter Process Communication Presentation[1]Inter Process Communication Presentation[1]
Inter Process Communication Presentation[1]
 
Feng’s classification
Feng’s classificationFeng’s classification
Feng’s classification
 

Similaire à Multiprocessing -Interprocessing communication and process sunchronization,semaphore

Operating system 27 semaphores
Operating system 27 semaphoresOperating system 27 semaphores
Operating system 27 semaphoresVaibhav Khanna
 
INTER PROCESS COMMUNICATION (IPC).pptx
INTER PROCESS COMMUNICATION (IPC).pptxINTER PROCESS COMMUNICATION (IPC).pptx
INTER PROCESS COMMUNICATION (IPC).pptxSKUP1
 
INTER PROCESS COMMUNICATION (IPC).pptx
INTER PROCESS COMMUNICATION (IPC).pptxINTER PROCESS COMMUNICATION (IPC).pptx
INTER PROCESS COMMUNICATION (IPC).pptxLECO9
 
Introduction 1
Introduction 1Introduction 1
Introduction 1Yasir Khan
 
Inter Process Communication - IPC
Inter Process Communication - IPCInter Process Communication - IPC
Inter Process Communication - IPCPravjot Singh
 
ch13 here is the ppt of this chapter included pictures
ch13 here is the ppt of this chapter included picturesch13 here is the ppt of this chapter included pictures
ch13 here is the ppt of this chapter included picturesPranjalRana4
 
Operating-System-(1-3 group) Case study on windows Mac and linux among variou...
Operating-System-(1-3 group) Case study on windows Mac and linux among variou...Operating-System-(1-3 group) Case study on windows Mac and linux among variou...
Operating-System-(1-3 group) Case study on windows Mac and linux among variou...ssuser4a97d3
 
Module 2 - PPT.pdfModule 2 - PPT.pdfModule 2 - PPT.pdfModule 2 - PPT.pdfModul...
Module 2 - PPT.pdfModule 2 - PPT.pdfModule 2 - PPT.pdfModule 2 - PPT.pdfModul...Module 2 - PPT.pdfModule 2 - PPT.pdfModule 2 - PPT.pdfModule 2 - PPT.pdfModul...
Module 2 - PPT.pdfModule 2 - PPT.pdfModule 2 - PPT.pdfModule 2 - PPT.pdfModul...morganjohn3
 
Intro Basic of OS .ppt
Intro Basic of OS .pptIntro Basic of OS .ppt
Intro Basic of OS .pptVarsha506533
 
Chapter Introductionn to distributed system .pptx
Chapter Introductionn to distributed system .pptxChapter Introductionn to distributed system .pptx
Chapter Introductionn to distributed system .pptxTekle12
 
Linux kernel development_ch9-10_20120410
Linux kernel development_ch9-10_20120410Linux kernel development_ch9-10_20120410
Linux kernel development_ch9-10_20120410huangachou
 
Linux kernel development chapter 10
Linux kernel development chapter 10Linux kernel development chapter 10
Linux kernel development chapter 10huangachou
 
Module2 MultiThreads.ppt
Module2 MultiThreads.pptModule2 MultiThreads.ppt
Module2 MultiThreads.pptshreesha16
 

Similaire à Multiprocessing -Interprocessing communication and process sunchronization,semaphore (20)

IPC
IPCIPC
IPC
 
IPC
IPCIPC
IPC
 
Operating system 27 semaphores
Operating system 27 semaphoresOperating system 27 semaphores
Operating system 27 semaphores
 
INTER PROCESS COMMUNICATION (IPC).pptx
INTER PROCESS COMMUNICATION (IPC).pptxINTER PROCESS COMMUNICATION (IPC).pptx
INTER PROCESS COMMUNICATION (IPC).pptx
 
INTER PROCESS COMMUNICATION (IPC).pptx
INTER PROCESS COMMUNICATION (IPC).pptxINTER PROCESS COMMUNICATION (IPC).pptx
INTER PROCESS COMMUNICATION (IPC).pptx
 
Introduction 1
Introduction 1Introduction 1
Introduction 1
 
Inter Process Communication - IPC
Inter Process Communication - IPCInter Process Communication - IPC
Inter Process Communication - IPC
 
Ch03 processes
Ch03 processesCh03 processes
Ch03 processes
 
ch13 here is the ppt of this chapter included pictures
ch13 here is the ppt of this chapter included picturesch13 here is the ppt of this chapter included pictures
ch13 here is the ppt of this chapter included pictures
 
Operating-System-(1-3 group) Case study on windows Mac and linux among variou...
Operating-System-(1-3 group) Case study on windows Mac and linux among variou...Operating-System-(1-3 group) Case study on windows Mac and linux among variou...
Operating-System-(1-3 group) Case study on windows Mac and linux among variou...
 
Replication in Distributed Systems
Replication in Distributed SystemsReplication in Distributed Systems
Replication in Distributed Systems
 
unit 4.pptx
unit 4.pptxunit 4.pptx
unit 4.pptx
 
unit 4.pptx
unit 4.pptxunit 4.pptx
unit 4.pptx
 
Module 2 - PPT.pdfModule 2 - PPT.pdfModule 2 - PPT.pdfModule 2 - PPT.pdfModul...
Module 2 - PPT.pdfModule 2 - PPT.pdfModule 2 - PPT.pdfModule 2 - PPT.pdfModul...Module 2 - PPT.pdfModule 2 - PPT.pdfModule 2 - PPT.pdfModule 2 - PPT.pdfModul...
Module 2 - PPT.pdfModule 2 - PPT.pdfModule 2 - PPT.pdfModule 2 - PPT.pdfModul...
 
Intro Basic of OS .ppt
Intro Basic of OS .pptIntro Basic of OS .ppt
Intro Basic of OS .ppt
 
Chapter Introductionn to distributed system .pptx
Chapter Introductionn to distributed system .pptxChapter Introductionn to distributed system .pptx
Chapter Introductionn to distributed system .pptx
 
Linux kernel development_ch9-10_20120410
Linux kernel development_ch9-10_20120410Linux kernel development_ch9-10_20120410
Linux kernel development_ch9-10_20120410
 
Linux kernel development chapter 10
Linux kernel development chapter 10Linux kernel development chapter 10
Linux kernel development chapter 10
 
Os
OsOs
Os
 
Module2 MultiThreads.ppt
Module2 MultiThreads.pptModule2 MultiThreads.ppt
Module2 MultiThreads.ppt
 

Dernier

Danh sách HSG Bộ môn cấp trường - Cấp THPT.pdf
Danh sách HSG Bộ môn cấp trường - Cấp THPT.pdfDanh sách HSG Bộ môn cấp trường - Cấp THPT.pdf
Danh sách HSG Bộ môn cấp trường - Cấp THPT.pdfQucHHunhnh
 
ppt your views.ppt your views of your college in your eyes
ppt your views.ppt your views of your college in your eyesppt your views.ppt your views of your college in your eyes
ppt your views.ppt your views of your college in your eyesashishpaul799
 
size separation d pharm 1st year pharmaceutics
size separation d pharm 1st year pharmaceuticssize separation d pharm 1st year pharmaceutics
size separation d pharm 1st year pharmaceuticspragatimahajan3
 
MichaelStarkes_UncutGemsProjectSummary.pdf
MichaelStarkes_UncutGemsProjectSummary.pdfMichaelStarkes_UncutGemsProjectSummary.pdf
MichaelStarkes_UncutGemsProjectSummary.pdfmstarkes24
 
Morse OER Some Benefits and Challenges.pptx
Morse OER Some Benefits and Challenges.pptxMorse OER Some Benefits and Challenges.pptx
Morse OER Some Benefits and Challenges.pptxjmorse8
 
2024_Student Session 2_ Set Plan Preparation.pptx
2024_Student Session 2_ Set Plan Preparation.pptx2024_Student Session 2_ Set Plan Preparation.pptx
2024_Student Session 2_ Set Plan Preparation.pptxmansk2
 
Basic_QTL_Marker-assisted_Selection_Sourabh.ppt
Basic_QTL_Marker-assisted_Selection_Sourabh.pptBasic_QTL_Marker-assisted_Selection_Sourabh.ppt
Basic_QTL_Marker-assisted_Selection_Sourabh.pptSourabh Kumar
 
Dementia (Alzheimer & vasular dementia).
Dementia (Alzheimer & vasular dementia).Dementia (Alzheimer & vasular dementia).
Dementia (Alzheimer & vasular dementia).Mohamed Rizk Khodair
 
Research Methods in Psychology | Cambridge AS Level | Cambridge Assessment In...
Research Methods in Psychology | Cambridge AS Level | Cambridge Assessment In...Research Methods in Psychology | Cambridge AS Level | Cambridge Assessment In...
Research Methods in Psychology | Cambridge AS Level | Cambridge Assessment In...Abhinav Gaur Kaptaan
 
Pragya Champions Chalice 2024 Prelims & Finals Q/A set, General Quiz
Pragya Champions Chalice 2024 Prelims & Finals Q/A set, General QuizPragya Champions Chalice 2024 Prelims & Finals Q/A set, General Quiz
Pragya Champions Chalice 2024 Prelims & Finals Q/A set, General QuizPragya - UEM Kolkata Quiz Club
 
Application of Matrices in real life. Presentation on application of matrices
Application of Matrices in real life. Presentation on application of matricesApplication of Matrices in real life. Presentation on application of matrices
Application of Matrices in real life. Presentation on application of matricesRased Khan
 
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文中 央社
 
The Last Leaf, a short story by O. Henry
The Last Leaf, a short story by O. HenryThe Last Leaf, a short story by O. Henry
The Last Leaf, a short story by O. HenryEugene Lysak
 
IATP How-to Foreign Travel May 2024.pdff
IATP How-to Foreign Travel May 2024.pdffIATP How-to Foreign Travel May 2024.pdff
IATP How-to Foreign Travel May 2024.pdff17thcssbs2
 
Capitol Tech Univ Doctoral Presentation -May 2024
Capitol Tech Univ Doctoral Presentation -May 2024Capitol Tech Univ Doctoral Presentation -May 2024
Capitol Tech Univ Doctoral Presentation -May 2024CapitolTechU
 
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽中 央社
 
How to Manage Notification Preferences in the Odoo 17
How to Manage Notification Preferences in the Odoo 17How to Manage Notification Preferences in the Odoo 17
How to Manage Notification Preferences in the Odoo 17Celine George
 
Features of Video Calls in the Discuss Module in Odoo 17
Features of Video Calls in the Discuss Module in Odoo 17Features of Video Calls in the Discuss Module in Odoo 17
Features of Video Calls in the Discuss Module in Odoo 17Celine George
 

Dernier (20)

Danh sách HSG Bộ môn cấp trường - Cấp THPT.pdf
Danh sách HSG Bộ môn cấp trường - Cấp THPT.pdfDanh sách HSG Bộ môn cấp trường - Cấp THPT.pdf
Danh sách HSG Bộ môn cấp trường - Cấp THPT.pdf
 
ppt your views.ppt your views of your college in your eyes
ppt your views.ppt your views of your college in your eyesppt your views.ppt your views of your college in your eyes
ppt your views.ppt your views of your college in your eyes
 
size separation d pharm 1st year pharmaceutics
size separation d pharm 1st year pharmaceuticssize separation d pharm 1st year pharmaceutics
size separation d pharm 1st year pharmaceutics
 
MichaelStarkes_UncutGemsProjectSummary.pdf
MichaelStarkes_UncutGemsProjectSummary.pdfMichaelStarkes_UncutGemsProjectSummary.pdf
MichaelStarkes_UncutGemsProjectSummary.pdf
 
Morse OER Some Benefits and Challenges.pptx
Morse OER Some Benefits and Challenges.pptxMorse OER Some Benefits and Challenges.pptx
Morse OER Some Benefits and Challenges.pptx
 
2024_Student Session 2_ Set Plan Preparation.pptx
2024_Student Session 2_ Set Plan Preparation.pptx2024_Student Session 2_ Set Plan Preparation.pptx
2024_Student Session 2_ Set Plan Preparation.pptx
 
Basic_QTL_Marker-assisted_Selection_Sourabh.ppt
Basic_QTL_Marker-assisted_Selection_Sourabh.pptBasic_QTL_Marker-assisted_Selection_Sourabh.ppt
Basic_QTL_Marker-assisted_Selection_Sourabh.ppt
 
Dementia (Alzheimer & vasular dementia).
Dementia (Alzheimer & vasular dementia).Dementia (Alzheimer & vasular dementia).
Dementia (Alzheimer & vasular dementia).
 
Research Methods in Psychology | Cambridge AS Level | Cambridge Assessment In...
Research Methods in Psychology | Cambridge AS Level | Cambridge Assessment In...Research Methods in Psychology | Cambridge AS Level | Cambridge Assessment In...
Research Methods in Psychology | Cambridge AS Level | Cambridge Assessment In...
 
Pragya Champions Chalice 2024 Prelims & Finals Q/A set, General Quiz
Pragya Champions Chalice 2024 Prelims & Finals Q/A set, General QuizPragya Champions Chalice 2024 Prelims & Finals Q/A set, General Quiz
Pragya Champions Chalice 2024 Prelims & Finals Q/A set, General Quiz
 
“O BEIJO” EM ARTE .
“O BEIJO” EM ARTE                       .“O BEIJO” EM ARTE                       .
“O BEIJO” EM ARTE .
 
Application of Matrices in real life. Presentation on application of matrices
Application of Matrices in real life. Presentation on application of matricesApplication of Matrices in real life. Presentation on application of matrices
Application of Matrices in real life. Presentation on application of matrices
 
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
 
The Last Leaf, a short story by O. Henry
The Last Leaf, a short story by O. HenryThe Last Leaf, a short story by O. Henry
The Last Leaf, a short story by O. Henry
 
IATP How-to Foreign Travel May 2024.pdff
IATP How-to Foreign Travel May 2024.pdffIATP How-to Foreign Travel May 2024.pdff
IATP How-to Foreign Travel May 2024.pdff
 
Capitol Tech Univ Doctoral Presentation -May 2024
Capitol Tech Univ Doctoral Presentation -May 2024Capitol Tech Univ Doctoral Presentation -May 2024
Capitol Tech Univ Doctoral Presentation -May 2024
 
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
 
Word Stress rules esl .pptx
Word Stress rules esl               .pptxWord Stress rules esl               .pptx
Word Stress rules esl .pptx
 
How to Manage Notification Preferences in the Odoo 17
How to Manage Notification Preferences in the Odoo 17How to Manage Notification Preferences in the Odoo 17
How to Manage Notification Preferences in the Odoo 17
 
Features of Video Calls in the Discuss Module in Odoo 17
Features of Video Calls in the Discuss Module in Odoo 17Features of Video Calls in the Discuss Module in Odoo 17
Features of Video Calls in the Discuss Module in Odoo 17
 

Multiprocessing -Interprocessing communication and process sunchronization,semaphore

  • 2. CONTENTS • INTRODUCTION • INTERPROCESSOR COMMUNICATION • PROCESS SYNCHRONIZATION AND SEMAPHORE
  • 3. INTRODUCTION • Independent process cannot affect or be affected by the execution of another process • Cooperating process can affect or be affected by the execution of another process • Advantages of process cooperation – Information sharing – Modularity – Convenience
  • 4. Interprocessor Communication • Exchange of data between two or more processes. – Os provide facilities for IPC. • IPC facility provides two operations: send(message)and receive(message) (message size fixed or variable). • If P and Q wish to communicate, they need to: –establish a communication link between them exchange messages via send/receive
  • 5. Contd.. • Multiprocessor and multiple memory modules are connected together via some interconnection network. • They fall on two categories:- 1)Shared memory 2)Message passing
  • 8. SHARED MEMORY • Processors exchange information through their central shared memory system. • Inter co-ordination through a global memory shared by all processor. • Server system that communicate through a bus and cache memory controller. • Access to shared memory is balanced – Symmetric multiprocessor
  • 9. Contd.. • Each processor has equal opportunities to read/write to memory including equal access speed. PROCESSORs Registers Local memory banks (additional memory resource Cache Buffers
  • 10.
  • 11.
  • 12. Contd.. • Basic issues in the design of shared memory system have to be taken in consideration :- 1)Access Control 2)Synchronization 3)Protection and Security
  • 13. ACCESS CONTROL • Determines which process access are possible to which resource. • The latter contain flag that determine the legality of each access attempt. • If there are access attempt to resources then until the desired access is completed, all disallowed access are attempt and illegal process are blocked.
  • 14. SYNCHRONIZATION • Constraints limit the time of access from sharing processes to shared resource. • Appropriate synchronization ensures that the information flows properly and ensure system functionality.
  • 15. PROTECTION AND SECURITY • It is a system feature that prevents processes from making arbitrary access to resource belonging to other processes. • Sharing and protection are incompatible:- – Sharing allow access & protection restricts it.
  • 16. FEATURES • All communications are done using implicit loads and stores to a global address space. • Synchronization and communication are distinct.
  • 17. MESSAGE PASSING • Combine the local memory and processor at each node of the interconnection network. • There is no global memory. – Move data from one local memory to another by means of message passing. – Done by a send/reciever pair of commands and dealing consistency issues. – Eg: c.1990 Ncube.
  • 18.
  • 19. Contd.. • A node in message passing system of processor and its local memory. • They are able to store message buffers and able to perform send/receive operation at the same time as processing. • Processor do not share a global memory and each processor has access to its own address space.
  • 20. • Basic advantage :- – Scalable.
  • 21. SYNCHRONIZATION • Required when one process must wait for another to complete some operation before proceeding. – Eg:-one process (called a writer) may be writing data to a certain main memory area, while another process (a reader) may be reading data from that area and sending it to the printer. The reader and writer must be synchronized so that the writer does not overwrite.
  • 22. IMPORTANCE OF SYNCHRONIZATION • Prevention and elimination of race conditions, deadlocks and starvation. • Data integrity/consistency. • Collaboration. • Efficiency.
  • 23. SYNCHRONIZATION PROBLEMS • Race conditions – the exact timing in the execution of concurrent processes is critical • Critical sections – part of a program that must be protected from interference – usually resolved via mutual exclusion • Mutual exclusion – the usage of resources by processes is restricted – usually: only one process may use one instance of a resource
  • 25. TYPES OF SYNCHRONIZATION • Barrier • Lock • Semaphore
  • 26. BARRIER • Usually implies that all tasks are involved • Each task performs its work until it reaches the barrier. It then stops, or "blocks". • When the last task reaches the barrier, all tasks are synchronized. • What happens from here varies. Often, a serial section of work must be done. In other cases, the tasks are automatically released to continue their work.
  • 27. LOCK Suppose there are 2 processes – Write-process 1 and Read-process 2 PROCESS 1 WRITE MEMORY LOCKED AFTER WRITING UNLOCK MEMORY PROCESS 2 READ
  • 28. Contd.. • 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
  • 29. • The UNLOCK(x) operation may be implemented as UNLOCK(x): x  0;
  • 30. SEMAPHORE • It is a resource that contains an integer value and allows process to synchronize by testing and setting this value on a single atomic operations. – Process that test the value of a semaphore and sets it to a different value,is guaranteed no other process will interfere with the operation in the middle.
  • 31. Contd.. • Two types of operations :- – Wait – Signal.
  • 32. FEATURES OF SEMAPHORE • Semaphores are used to synchronize operations when processes access a common, limited, and possibly non-shareable resource. • Each time a process wants to obtain the resource, the associated semaphore is tested. A positive, non-zero semaphore value indicates the resource is available. • Semaphore system calls will, by default, cause the invoking process to block if the semaphore value indicates the resource is not available
  • 33. TYPES OF SEMPAHORE • COUNTING SEMAPHORE – Semaphores controlling access to N (multiple) resources, thus assuming a range of non-negative values, are frequently. • BINARY SEMAPHORE – Semaphores that control access to a single resource, taking the value of 0 (resource is in use) or 1 (resource is available).
  • 35.
  • 36. 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
  • 37. 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
  • 38. EXAMPLE PRODUCER CONSUMER PROBLEM Producer While(true) { while(((in+1) % Buffer_Size)==out); buffer[in]=item; in=(in+1)%Buffer_Size; }
  • 41. Solution with Semaphore Empty=n,full=0.mutex=1 Producer Do { //Produce item wait(empty); wait(mutex); //add item to the buffer signal(mutex); signal(full); }while(true);
  • 42. Contd.. Consumer Do { wait(full); wait(mutex); //Remove an item from buffer signal(mutex); signal(empty); //consume the remove item }while(true);