SlideShare a Scribd company logo
1 of 10
Download to read offline
Inter process communication
IPC TYPES
 SHARED MEMORY
 MAPPED MEMORY
 PIPE
 FIFO
 MASSEGE QUEUE
 SOCKET
 SIGNAL
SHARED MEMORY
 Simplest and fastest form of IPC.
 All process shares same piece of memory.
 This memory is shared between some different processes
so synchronization needed.
Means, only one process should be allowed to read/write at
a time.(we can do this by using semaphore).
 First create shared memory with a specific key using
shmget.
 Attach that memory to process’s address space to make it
available for that process using shmat.
 ipcs –m. (To see the list of shared memory in our pc.)
Shmget & shmat
 shm_id = shmget( key , bytes , flag).
 Key - unrelated process can access same shared segment by
specifying same key.
 Bytes – number of bytes in segment.
 Flag – IPC_CREAT | IPC_EXCL | S_IRUSR | S_IWUSR.
 char *shm = shmat(shm_id, ptr, flag);
 shm_id – shared segment identifier returned by shmget.
 ptr – pointer that specifies where in your process’s address space you
want to map shared memory.
 flag – SHM_RND, SHM_RDONLY.
 shmdt(shm) – detach shared memory from our process address
space.
 shmctl( shm_id, flag, NULL).
flag = IPC_STAT , IPC_RMID etc.
MAPPED MEMORY
 Permit different process to communicate via a shared
file.
 Mapped memory forms an association between a file
and a process’s memory.
 Linux splits the file into page-sized chunks and then
copies them into virtual memory pages so that they
can be made available in a process’s address space.
 mmap call is used.
Mmap()
 mmap( addr, len, prot, flag, fd, offset).
o Addr – address at which you would like linux to map the
file into your process’s address space(NULL).
o Len – length of map In bytes.
o Prot – PROT_READ | PROT_WRITE | PROT_EXEC.
o Flag – MAP_FIXED, MAP_PRIVATE (store write to new
file), MAP_SHARED(store write immediately to file, do
not buffer it).
o Fd – file descriptor opened to file to be mapped.
o Offset – offset from beginning of file from which to start
the map.
PIPE & FIFO
 PIPE permits sequential communication from one process to a
related process.
 Data written to the “write end” of the pipe is read back from the
“read end.”
 Eg. ls | less : output of “ls” will be written to pipe and on other
side it becomes input for “less”.
 Int pipe( int fd[2]);
 FIFOs : fifo are similar to pipes, except that unrelated processes
can communicate.
 Write mkfifo foo (on first terminal).
 Write echo hello > foo (first terminal).
 Write cat < foo (second terminal).
MESSAGE QUEUE
 Two (or more) processes can exchange information via
access to a common system message queue.
 The sending process places via some (OS) message
passing module a message onto a queue which can be
read by another process.
 Each message is given an identification or type so that
processes can select the appropriate message.
 Before we start sending/receiving message, we have to
initialize message queue.
 Initializing msgq : int msgget( key_t key , int msgflg ).
Msgget, msgsnd, msgrcv
 msgid = msgget( key_t key, int msgflg)
 Key : processes must share common key to gain access to the queue.
 Msdflg : IPC_CREAT | IPC_EXCL | 0666;
 Int msgsnd( int msgid, void *msgp, size_t msgsz,
int msgflg ). // man msgsend.
 Int msgrcv( int msgid , void *msgp , size_t msgsz,
long msgtyp , int msgflg ).
 struct mymsg {
long mtype; /* message type */
char mtext[MSGSZ]; /* message text of length MSGSZ */
} *msgp;
SIGNAL
 Used to signal asynchronous events to one or more
processes.
 An application program can specify a function called a
signal handler to be invoked when specific signal is
received.
 Signal hander than catches the signal by using :
int (*signal(int sig , void (*func())));
 “ Kill –l ” gives list of different signals.
 Process can ignores most of signals except SIGSTOP
and SIGKILL.

More Related Content

What's hot

Inter Process Communication Presentation[1]
Inter Process Communication Presentation[1]Inter Process Communication Presentation[1]
Inter Process Communication Presentation[1]Ravindra Raju Kolahalam
 
Operating system Dead lock
Operating system Dead lockOperating system Dead lock
Operating system Dead lockKaram Munir Butt
 
Operating systems system structures
Operating systems   system structuresOperating systems   system structures
Operating systems system structuresMukesh Chinta
 
IPC (Inter-Process Communication) with Shared Memory
IPC (Inter-Process Communication) with Shared MemoryIPC (Inter-Process Communication) with Shared Memory
IPC (Inter-Process Communication) with Shared MemoryHEM DUTT
 
Process scheduling (CPU Scheduling)
Process scheduling (CPU Scheduling)Process scheduling (CPU Scheduling)
Process scheduling (CPU Scheduling)Mukesh Chinta
 
RPC: Remote procedure call
RPC: Remote procedure callRPC: Remote procedure call
RPC: Remote procedure callSunita Sahu
 
Multithreading in java
Multithreading in javaMultithreading in java
Multithreading in javajunnubabu
 
Operating Systems: Process Scheduling
Operating Systems: Process SchedulingOperating Systems: Process Scheduling
Operating Systems: Process SchedulingDamian T. Gordon
 
Remote Procedure Call in Distributed System
Remote Procedure Call in Distributed SystemRemote Procedure Call in Distributed System
Remote Procedure Call in Distributed SystemPoojaBele1
 
Multithreading
MultithreadingMultithreading
MultithreadingA B Shinde
 
Memory Management in OS
Memory Management in OSMemory Management in OS
Memory Management in OSvampugani
 
Message passing ( in computer science)
Message   passing  ( in   computer  science)Message   passing  ( in   computer  science)
Message passing ( in computer science)Computer_ at_home
 
remote procedure calls
  remote procedure calls  remote procedure calls
remote procedure callsAshish Kumar
 

What's hot (20)

Inter Process Communication Presentation[1]
Inter Process Communication Presentation[1]Inter Process Communication Presentation[1]
Inter Process Communication Presentation[1]
 
Ipc
IpcIpc
Ipc
 
Inter Process Communication
Inter Process CommunicationInter Process Communication
Inter Process Communication
 
Ipc ppt
Ipc pptIpc ppt
Ipc ppt
 
operating system structure
operating system structureoperating system structure
operating system structure
 
Operating system Dead lock
Operating system Dead lockOperating system Dead lock
Operating system Dead lock
 
Operating systems system structures
Operating systems   system structuresOperating systems   system structures
Operating systems system structures
 
IPC (Inter-Process Communication) with Shared Memory
IPC (Inter-Process Communication) with Shared MemoryIPC (Inter-Process Communication) with Shared Memory
IPC (Inter-Process Communication) with Shared Memory
 
Memory management
Memory managementMemory management
Memory management
 
Process scheduling (CPU Scheduling)
Process scheduling (CPU Scheduling)Process scheduling (CPU Scheduling)
Process scheduling (CPU Scheduling)
 
RPC: Remote procedure call
RPC: Remote procedure callRPC: Remote procedure call
RPC: Remote procedure call
 
Ipc in linux
Ipc in linuxIpc in linux
Ipc in linux
 
Multithreading in java
Multithreading in javaMultithreading in java
Multithreading in java
 
Operating Systems: Process Scheduling
Operating Systems: Process SchedulingOperating Systems: Process Scheduling
Operating Systems: Process Scheduling
 
Remote Procedure Call in Distributed System
Remote Procedure Call in Distributed SystemRemote Procedure Call in Distributed System
Remote Procedure Call in Distributed System
 
Multithreading
MultithreadingMultithreading
Multithreading
 
Memory Management in OS
Memory Management in OSMemory Management in OS
Memory Management in OS
 
Concurrency control
Concurrency controlConcurrency control
Concurrency control
 
Message passing ( in computer science)
Message   passing  ( in   computer  science)Message   passing  ( in   computer  science)
Message passing ( in computer science)
 
remote procedure calls
  remote procedure calls  remote procedure calls
remote procedure calls
 

Viewers also liked

Inter process communication using Linux System Calls
Inter process communication using Linux System CallsInter process communication using Linux System Calls
Inter process communication using Linux System Callsjyoti9vssut
 
Sockets in unix
Sockets in unixSockets in unix
Sockets in unixswtjerin4u
 
Sun RPC (Remote Procedure Call)
Sun RPC (Remote Procedure Call)Sun RPC (Remote Procedure Call)
Sun RPC (Remote Procedure Call)Peter R. Egli
 
Remote procedure call on client server computing
Remote procedure call on client server computingRemote procedure call on client server computing
Remote procedure call on client server computingSatya P. Joshi
 
Rpc (Distributed computing)
Rpc (Distributed computing)Rpc (Distributed computing)
Rpc (Distributed computing)Sri Prasanna
 
Introduction to Remote Procedure Call
Introduction to Remote Procedure CallIntroduction to Remote Procedure Call
Introduction to Remote Procedure CallAbdelrahman Al-Ogail
 
Mobile Ad hoc Networks
Mobile Ad hoc NetworksMobile Ad hoc Networks
Mobile Ad hoc NetworksJagdeep Singh
 
Threads (operating System)
Threads (operating System)Threads (operating System)
Threads (operating System)Prakhar Maurya
 
Operating System-Threads-Galvin
Operating System-Threads-GalvinOperating System-Threads-Galvin
Operating System-Threads-GalvinSonali Chauhan
 
Interprocess Communication
Interprocess CommunicationInterprocess Communication
Interprocess CommunicationDeepak H L
 

Viewers also liked (17)

Inter process communication using Linux System Calls
Inter process communication using Linux System CallsInter process communication using Linux System Calls
Inter process communication using Linux System Calls
 
Sockets in unix
Sockets in unixSockets in unix
Sockets in unix
 
Sun RPC (Remote Procedure Call)
Sun RPC (Remote Procedure Call)Sun RPC (Remote Procedure Call)
Sun RPC (Remote Procedure Call)
 
Remote procedure call on client server computing
Remote procedure call on client server computingRemote procedure call on client server computing
Remote procedure call on client server computing
 
Rpc (Distributed computing)
Rpc (Distributed computing)Rpc (Distributed computing)
Rpc (Distributed computing)
 
Introduction to Remote Procedure Call
Introduction to Remote Procedure CallIntroduction to Remote Procedure Call
Introduction to Remote Procedure Call
 
5 Process Scheduling
5 Process Scheduling5 Process Scheduling
5 Process Scheduling
 
Process Scheduling
Process SchedulingProcess Scheduling
Process Scheduling
 
Process scheduling
Process schedulingProcess scheduling
Process scheduling
 
Os Threads
Os ThreadsOs Threads
Os Threads
 
Mobile Ad hoc Networks
Mobile Ad hoc NetworksMobile Ad hoc Networks
Mobile Ad hoc Networks
 
Threads (operating System)
Threads (operating System)Threads (operating System)
Threads (operating System)
 
RPC
RPCRPC
RPC
 
Process scheduling
Process schedulingProcess scheduling
Process scheduling
 
Operating System-Threads-Galvin
Operating System-Threads-GalvinOperating System-Threads-Galvin
Operating System-Threads-Galvin
 
Process Scheduling
Process SchedulingProcess Scheduling
Process Scheduling
 
Interprocess Communication
Interprocess CommunicationInterprocess Communication
Interprocess Communication
 

Similar to Inter process communication

Similar to Inter process communication (20)

Inter Process Communication PPT
Inter Process Communication PPTInter Process Communication PPT
Inter Process Communication PPT
 
Lab8
Lab8Lab8
Lab8
 
CS 4760 Operating SystemsAssignment 2 Due Date October 5th,.docx
CS 4760 Operating SystemsAssignment 2 Due Date October 5th,.docxCS 4760 Operating SystemsAssignment 2 Due Date October 5th,.docx
CS 4760 Operating SystemsAssignment 2 Due Date October 5th,.docx
 
ipc.pptx
ipc.pptxipc.pptx
ipc.pptx
 
Usp message queues
Usp message queuesUsp message queues
Usp message queues
 
Operating System 4 1193308760782240 2
Operating System 4 1193308760782240 2Operating System 4 1193308760782240 2
Operating System 4 1193308760782240 2
 
Operating System 4
Operating System 4Operating System 4
Operating System 4
 
project_531
project_531project_531
project_531
 
Multicore
MulticoreMulticore
Multicore
 
25-MPI-OpenMP.pptx
25-MPI-OpenMP.pptx25-MPI-OpenMP.pptx
25-MPI-OpenMP.pptx
 
System Programming - Interprocess communication
System Programming - Interprocess communicationSystem Programming - Interprocess communication
System Programming - Interprocess communication
 
IPC in Microkernel Systems, Capabilities
IPC in Microkernel Systems, CapabilitiesIPC in Microkernel Systems, Capabilities
IPC in Microkernel Systems, Capabilities
 
Project Jugaad
Project JugaadProject Jugaad
Project Jugaad
 
Bab 4
Bab 4Bab 4
Bab 4
 
3rd Meet Lecturer Notes.pdf
3rd Meet Lecturer Notes.pdf3rd Meet Lecturer Notes.pdf
3rd Meet Lecturer Notes.pdf
 
ch 7 POSIX.pptx
ch 7 POSIX.pptxch 7 POSIX.pptx
ch 7 POSIX.pptx
 
Inter Process Comunication
Inter Process ComunicationInter Process Comunication
Inter Process Comunication
 
Lecture1
Lecture1Lecture1
Lecture1
 
My ppt hpc u4
My ppt hpc u4My ppt hpc u4
My ppt hpc u4
 
MPI Introduction
MPI IntroductionMPI Introduction
MPI Introduction
 

Recently uploaded

Vertical- Machining - Center - VMC -LMW-Machine-Tool-Division.pptx
Vertical- Machining - Center - VMC -LMW-Machine-Tool-Division.pptxVertical- Machining - Center - VMC -LMW-Machine-Tool-Division.pptx
Vertical- Machining - Center - VMC -LMW-Machine-Tool-Division.pptxLMW Machine Tool Division
 
Quasi-Stochastic Approximation: Algorithm Design Principles with Applications...
Quasi-Stochastic Approximation: Algorithm Design Principles with Applications...Quasi-Stochastic Approximation: Algorithm Design Principles with Applications...
Quasi-Stochastic Approximation: Algorithm Design Principles with Applications...Sean Meyn
 
Landsman converter for power factor improvement
Landsman converter for power factor improvementLandsman converter for power factor improvement
Landsman converter for power factor improvementVijayMuni2
 
Multicomponent Spiral Wound Membrane Separation Model.pdf
Multicomponent Spiral Wound Membrane Separation Model.pdfMulticomponent Spiral Wound Membrane Separation Model.pdf
Multicomponent Spiral Wound Membrane Separation Model.pdfGiovanaGhasary1
 
Modelling Guide for Timber Structures - FPInnovations
Modelling Guide for Timber Structures - FPInnovationsModelling Guide for Timber Structures - FPInnovations
Modelling Guide for Timber Structures - FPInnovationsYusuf Yıldız
 
Engineering Mechanics Chapter 5 Equilibrium of a Rigid Body
Engineering Mechanics  Chapter 5  Equilibrium of a Rigid BodyEngineering Mechanics  Chapter 5  Equilibrium of a Rigid Body
Engineering Mechanics Chapter 5 Equilibrium of a Rigid BodyAhmadHajasad2
 
Test of Significance of Large Samples for Mean = µ.pptx
Test of Significance of Large Samples for Mean = µ.pptxTest of Significance of Large Samples for Mean = µ.pptx
Test of Significance of Large Samples for Mean = µ.pptxHome
 
SUMMER TRAINING REPORT ON BUILDING CONSTRUCTION.docx
SUMMER TRAINING REPORT ON BUILDING CONSTRUCTION.docxSUMMER TRAINING REPORT ON BUILDING CONSTRUCTION.docx
SUMMER TRAINING REPORT ON BUILDING CONSTRUCTION.docxNaveenVerma126
 
Nodal seismic construction requirements.pptx
Nodal seismic construction requirements.pptxNodal seismic construction requirements.pptx
Nodal seismic construction requirements.pptxwendy cai
 
Technology Features of Apollo HDD Machine, Its Technical Specification with C...
Technology Features of Apollo HDD Machine, Its Technical Specification with C...Technology Features of Apollo HDD Machine, Its Technical Specification with C...
Technology Features of Apollo HDD Machine, Its Technical Specification with C...Apollo Techno Industries Pvt Ltd
 
Basic Principle of Electrochemical Sensor
Basic Principle of  Electrochemical SensorBasic Principle of  Electrochemical Sensor
Basic Principle of Electrochemical SensorTanvir Moin
 
Popular-NO1 Kala Jadu Expert Specialist In Germany Kala Jadu Expert Specialis...
Popular-NO1 Kala Jadu Expert Specialist In Germany Kala Jadu Expert Specialis...Popular-NO1 Kala Jadu Expert Specialist In Germany Kala Jadu Expert Specialis...
Popular-NO1 Kala Jadu Expert Specialist In Germany Kala Jadu Expert Specialis...Amil baba
 
Strategies of Urban Morphologyfor Improving Outdoor Thermal Comfort and Susta...
Strategies of Urban Morphologyfor Improving Outdoor Thermal Comfort and Susta...Strategies of Urban Morphologyfor Improving Outdoor Thermal Comfort and Susta...
Strategies of Urban Morphologyfor Improving Outdoor Thermal Comfort and Susta...amrabdallah9
 
SATELITE COMMUNICATION UNIT 1 CEC352 REGULATION 2021 PPT BASICS OF SATELITE ....
SATELITE COMMUNICATION UNIT 1 CEC352 REGULATION 2021 PPT BASICS OF SATELITE ....SATELITE COMMUNICATION UNIT 1 CEC352 REGULATION 2021 PPT BASICS OF SATELITE ....
SATELITE COMMUNICATION UNIT 1 CEC352 REGULATION 2021 PPT BASICS OF SATELITE ....santhyamuthu1
 
UNIT4_ESD_wfffffggggggggggggith_ARM.pptx
UNIT4_ESD_wfffffggggggggggggith_ARM.pptxUNIT4_ESD_wfffffggggggggggggith_ARM.pptx
UNIT4_ESD_wfffffggggggggggggith_ARM.pptxrealme6igamerr
 
Graphics Primitives and CG Display Devices
Graphics Primitives and CG Display DevicesGraphics Primitives and CG Display Devices
Graphics Primitives and CG Display DevicesDIPIKA83
 
The relationship between iot and communication technology
The relationship between iot and communication technologyThe relationship between iot and communication technology
The relationship between iot and communication technologyabdulkadirmukarram03
 

Recently uploaded (20)

Vertical- Machining - Center - VMC -LMW-Machine-Tool-Division.pptx
Vertical- Machining - Center - VMC -LMW-Machine-Tool-Division.pptxVertical- Machining - Center - VMC -LMW-Machine-Tool-Division.pptx
Vertical- Machining - Center - VMC -LMW-Machine-Tool-Division.pptx
 
Quasi-Stochastic Approximation: Algorithm Design Principles with Applications...
Quasi-Stochastic Approximation: Algorithm Design Principles with Applications...Quasi-Stochastic Approximation: Algorithm Design Principles with Applications...
Quasi-Stochastic Approximation: Algorithm Design Principles with Applications...
 
Landsman converter for power factor improvement
Landsman converter for power factor improvementLandsman converter for power factor improvement
Landsman converter for power factor improvement
 
Lecture 2 .pptx
Lecture 2                            .pptxLecture 2                            .pptx
Lecture 2 .pptx
 
Multicomponent Spiral Wound Membrane Separation Model.pdf
Multicomponent Spiral Wound Membrane Separation Model.pdfMulticomponent Spiral Wound Membrane Separation Model.pdf
Multicomponent Spiral Wound Membrane Separation Model.pdf
 
Modelling Guide for Timber Structures - FPInnovations
Modelling Guide for Timber Structures - FPInnovationsModelling Guide for Timber Structures - FPInnovations
Modelling Guide for Timber Structures - FPInnovations
 
Engineering Mechanics Chapter 5 Equilibrium of a Rigid Body
Engineering Mechanics  Chapter 5  Equilibrium of a Rigid BodyEngineering Mechanics  Chapter 5  Equilibrium of a Rigid Body
Engineering Mechanics Chapter 5 Equilibrium of a Rigid Body
 
Test of Significance of Large Samples for Mean = µ.pptx
Test of Significance of Large Samples for Mean = µ.pptxTest of Significance of Large Samples for Mean = µ.pptx
Test of Significance of Large Samples for Mean = µ.pptx
 
Présentation IIRB 2024 Marine Cordonnier.pdf
Présentation IIRB 2024 Marine Cordonnier.pdfPrésentation IIRB 2024 Marine Cordonnier.pdf
Présentation IIRB 2024 Marine Cordonnier.pdf
 
SUMMER TRAINING REPORT ON BUILDING CONSTRUCTION.docx
SUMMER TRAINING REPORT ON BUILDING CONSTRUCTION.docxSUMMER TRAINING REPORT ON BUILDING CONSTRUCTION.docx
SUMMER TRAINING REPORT ON BUILDING CONSTRUCTION.docx
 
Nodal seismic construction requirements.pptx
Nodal seismic construction requirements.pptxNodal seismic construction requirements.pptx
Nodal seismic construction requirements.pptx
 
Technology Features of Apollo HDD Machine, Its Technical Specification with C...
Technology Features of Apollo HDD Machine, Its Technical Specification with C...Technology Features of Apollo HDD Machine, Its Technical Specification with C...
Technology Features of Apollo HDD Machine, Its Technical Specification with C...
 
Basic Principle of Electrochemical Sensor
Basic Principle of  Electrochemical SensorBasic Principle of  Electrochemical Sensor
Basic Principle of Electrochemical Sensor
 
Popular-NO1 Kala Jadu Expert Specialist In Germany Kala Jadu Expert Specialis...
Popular-NO1 Kala Jadu Expert Specialist In Germany Kala Jadu Expert Specialis...Popular-NO1 Kala Jadu Expert Specialist In Germany Kala Jadu Expert Specialis...
Popular-NO1 Kala Jadu Expert Specialist In Germany Kala Jadu Expert Specialis...
 
Strategies of Urban Morphologyfor Improving Outdoor Thermal Comfort and Susta...
Strategies of Urban Morphologyfor Improving Outdoor Thermal Comfort and Susta...Strategies of Urban Morphologyfor Improving Outdoor Thermal Comfort and Susta...
Strategies of Urban Morphologyfor Improving Outdoor Thermal Comfort and Susta...
 
Litature Review: Research Paper work for Engineering
Litature Review: Research Paper work for EngineeringLitature Review: Research Paper work for Engineering
Litature Review: Research Paper work for Engineering
 
SATELITE COMMUNICATION UNIT 1 CEC352 REGULATION 2021 PPT BASICS OF SATELITE ....
SATELITE COMMUNICATION UNIT 1 CEC352 REGULATION 2021 PPT BASICS OF SATELITE ....SATELITE COMMUNICATION UNIT 1 CEC352 REGULATION 2021 PPT BASICS OF SATELITE ....
SATELITE COMMUNICATION UNIT 1 CEC352 REGULATION 2021 PPT BASICS OF SATELITE ....
 
UNIT4_ESD_wfffffggggggggggggith_ARM.pptx
UNIT4_ESD_wfffffggggggggggggith_ARM.pptxUNIT4_ESD_wfffffggggggggggggith_ARM.pptx
UNIT4_ESD_wfffffggggggggggggith_ARM.pptx
 
Graphics Primitives and CG Display Devices
Graphics Primitives and CG Display DevicesGraphics Primitives and CG Display Devices
Graphics Primitives and CG Display Devices
 
The relationship between iot and communication technology
The relationship between iot and communication technologyThe relationship between iot and communication technology
The relationship between iot and communication technology
 

Inter process communication

  • 2. IPC TYPES  SHARED MEMORY  MAPPED MEMORY  PIPE  FIFO  MASSEGE QUEUE  SOCKET  SIGNAL
  • 3. SHARED MEMORY  Simplest and fastest form of IPC.  All process shares same piece of memory.  This memory is shared between some different processes so synchronization needed. Means, only one process should be allowed to read/write at a time.(we can do this by using semaphore).  First create shared memory with a specific key using shmget.  Attach that memory to process’s address space to make it available for that process using shmat.  ipcs –m. (To see the list of shared memory in our pc.)
  • 4. Shmget & shmat  shm_id = shmget( key , bytes , flag).  Key - unrelated process can access same shared segment by specifying same key.  Bytes – number of bytes in segment.  Flag – IPC_CREAT | IPC_EXCL | S_IRUSR | S_IWUSR.  char *shm = shmat(shm_id, ptr, flag);  shm_id – shared segment identifier returned by shmget.  ptr – pointer that specifies where in your process’s address space you want to map shared memory.  flag – SHM_RND, SHM_RDONLY.  shmdt(shm) – detach shared memory from our process address space.  shmctl( shm_id, flag, NULL). flag = IPC_STAT , IPC_RMID etc.
  • 5. MAPPED MEMORY  Permit different process to communicate via a shared file.  Mapped memory forms an association between a file and a process’s memory.  Linux splits the file into page-sized chunks and then copies them into virtual memory pages so that they can be made available in a process’s address space.  mmap call is used.
  • 6. Mmap()  mmap( addr, len, prot, flag, fd, offset). o Addr – address at which you would like linux to map the file into your process’s address space(NULL). o Len – length of map In bytes. o Prot – PROT_READ | PROT_WRITE | PROT_EXEC. o Flag – MAP_FIXED, MAP_PRIVATE (store write to new file), MAP_SHARED(store write immediately to file, do not buffer it). o Fd – file descriptor opened to file to be mapped. o Offset – offset from beginning of file from which to start the map.
  • 7. PIPE & FIFO  PIPE permits sequential communication from one process to a related process.  Data written to the “write end” of the pipe is read back from the “read end.”  Eg. ls | less : output of “ls” will be written to pipe and on other side it becomes input for “less”.  Int pipe( int fd[2]);  FIFOs : fifo are similar to pipes, except that unrelated processes can communicate.  Write mkfifo foo (on first terminal).  Write echo hello > foo (first terminal).  Write cat < foo (second terminal).
  • 8. MESSAGE QUEUE  Two (or more) processes can exchange information via access to a common system message queue.  The sending process places via some (OS) message passing module a message onto a queue which can be read by another process.  Each message is given an identification or type so that processes can select the appropriate message.  Before we start sending/receiving message, we have to initialize message queue.  Initializing msgq : int msgget( key_t key , int msgflg ).
  • 9. Msgget, msgsnd, msgrcv  msgid = msgget( key_t key, int msgflg)  Key : processes must share common key to gain access to the queue.  Msdflg : IPC_CREAT | IPC_EXCL | 0666;  Int msgsnd( int msgid, void *msgp, size_t msgsz, int msgflg ). // man msgsend.  Int msgrcv( int msgid , void *msgp , size_t msgsz, long msgtyp , int msgflg ).  struct mymsg { long mtype; /* message type */ char mtext[MSGSZ]; /* message text of length MSGSZ */ } *msgp;
  • 10. SIGNAL  Used to signal asynchronous events to one or more processes.  An application program can specify a function called a signal handler to be invoked when specific signal is received.  Signal hander than catches the signal by using : int (*signal(int sig , void (*func())));  “ Kill –l ” gives list of different signals.  Process can ignores most of signals except SIGSTOP and SIGKILL.