SlideShare une entreprise Scribd logo
1  sur  21

          IPC
    INTERPROCESS
     COMMUNICATION

 By.Prof.Ruchi   Sharma

              02/16/13     1
   Many operating systems provide mechanisms for
    interprocess communication (IPC)
     Processesmust communicate with one another in
     multiprogrammed and networked environments
        For example, a Web browser retrieving data from a distant
         server
     Essential
              for processes that must coordinate activities to
     achieve a common goal.




                                   02/16/13            2
   Software interrupts that notify a process that an
    event has occurred
     Do not allow processes to specify data to exchange with
      other processes
     Processes may catch, ignore or mask a signal
        Catching a signal involves specifying a routine that the OS calls
         when it delivers the signal
        Ignoring a signal relies on the operating system’s default action
         to handle the signal
        Masking a signal instructs the OS to not deliver signals of that
         type until the process clears the signal mask




                                    02/16/13              3
   Message-based interprocess communication
     Messages can be passed in one direction at a time
        One process is the sender and the other is the receiver
     Message    passing can be bidirectional
        Each process can act as either a sender or a receiver
     Messages    can be blocking or nonblocking
        Blocking requires the receiver to notify the sender when the
         message is received
        Nonblocking enables the sender to continue with other processing
     Popular   implementation is a pipe
        A region of memory protected by the OS that serves as a buffer,
         allowing two or more processes to exchange data




                                      02/16/13              4
   UNIX processes
     All processes are provided with a set of memory
      addresses, called a virtual address space
     A process’s PCB is maintained by the kernel in a
      protected region of memory that user processes cannot
      access
     A UNIX PCB stores:
         The contents of the processor registers
         PID
         The program counter
         The system stack
     All   processes are listed in the process table


                                     02/16/13       5
   UNIX processes continued
     All processes interact with the OS via system calls
     A process can spawn a child process by using the fork
      system call, which creates a copy of the parent process
        Child receives a copy of the parent’s resources as well
     Process priorities are integers between -20 and 19
     (inclusive)
        A lower numerical priority value indicates a higher scheduling
         priority
     UNIXprovides IPC mechanisms, such as pipes, to allow
     unrelated processes to transfer data



                                    02/16/13             6
Figure 3.10 UNIX system calls.




             02/16/13            7
Outline
4.1       Introduction
4.2       Definition of Thread

4.3       Motivation for Threads

4.4       Thread States: Life Cycle of a Thread

4.5       Thread Operations

4.6       Threading Models

4.6.1     User-Level Threads

4.6.2     Kernel-Level Threads

4.6.3     Combining User- and Kernel-Level Threads

4.7       Thread Implementation Considerations

4.7.1     Thread Signal Delivery

4.7.2     Thread Termination

4.8       POSIX and Pthreads

4.9       Linux Threads

4.10      Windows XP Threads

4.11      Java Multithreading Case Study, Part 1: Introduction to Java Threads




                                                                                 02/16/13   8
   After reading this chapter, you should understand:
     the motivation for creating threads.
     the similarities and differences between processes and
      threads.
     the various levels of support for threads.
     the life cycle of a thread.
     thread signaling and cancellation.
     the basics of POSIX, Linux, Windows XP and Java
      threads.




                              02/16/13          9
   General-purpose languages such as Java, C#, Visual
    C++ .NET, Visual Basic .NET and Python have made
    concurrency primitives available to applications
    programmer
   Multithreading
     Programmer   specifies applications contain threads of
      execution
     Each thread designate a portion of a program that may
      execute concurrently with other threads




                               02/16/13          10
   Thread
     Lightweight  process (LWP)
     Threads of instructions or thread of control
     Shares address space and other global information with
      its process
     Registers, stack, signal masks and other thread-specific
      data are local to each thread
   Threads may be managed by the operating system
    or by a user application
   Examples: Win32 threads, C-threads, Pthreads




                              02/16/13           11
Figure 4.1 Thread Relationship to Processes.




                   02/16/13                    12
   Threads have become prominent due to
    trends in
     Software   design
        More naturally expresses inherently parallel tasks
     Performance
        Scales better to multiprocessor systems
     Cooperation
        Shared address space incurs less overhead than IPC




                                   02/16/13             13
   Each thread transitions among a series of
    discrete thread states
   Threads and processes have many
    operations in common (e.g. create, exit,
    resume, and suspend)
   Thread creation does not require
    operating system to initialize resources
    that are shared between parent processes
    and its threads
     Reducesoverhead of thread creation and
     termination compared to process creation and
     termination

                            02/16/13         14
Figure 4.2 Thread life cycle.




            02/16/13            15
   User-level threads perform threading operations in user
    space
     Threads are created by runtime libraries that cannot execute
     privileged instructions or access kernel primitives directly
   User-level thread implementation
     Many-to-one thread mappings
       Operating system maps all threads in a multithreaded process to single
        execution context
       Advantages
             User-level libraries can schedule its threads to optimize performance
             Synchronization performed outside kernel, avoids context switches
             More portable
         Disadvantage
             Kernel views a multithreaded process as a single thread of control
               Can lead to suboptimal performance if a thread issues I/O
               Cannot be scheduled on multiple processors at once




                                             02/16/13               16
Figure 4.3 User-level threads.




            02/16/13             17
   Kernel-level threads attempt to address the limitations of
    user-level threads by mapping each thread to its own
    execution context
     Kernel-level   threads provide a one-to-one thread mapping
        Advantages: Increased scalability, interactivity, and throughput
        Disadvantages: Overhead due to context switching and reduced
         portability due to OS-specific APIs
   Kernel-level threads are not always the optimal solution
    for multithreaded applications




                                       02/16/13             18
Figure Kernel-level threads.




           02/16/13            19
   The combination of user- and kernel-level thread
    implementation
     Many-to-many thread mapping (m-to-n thread mapping)
       Number of user and kernel threads need not be equal
       Can reduce overhead compared to one-to-one thread mappings by
        implementing thread pooling
   Worker threads
     Persistent kernel threads that occupy the thread pool
     Improves performance in environments where threads           are
      frequently created and destroyed
     Each new thread is executed by a worker thread
   Scheduler activation
     Technique   that enables user-level library to schedule its
      threads
     Occurs when the operating system calls a user-level threading
      library that determines if any of its threads need rescheduling



                                     02/16/13            20
Figure 4.5 Hybrid threading model.




              02/16/13               21

Contenu connexe

Tendances

Chapter 4 a interprocess communication
Chapter 4 a interprocess communicationChapter 4 a interprocess communication
Chapter 4 a interprocess communicationAbDul ThaYyal
 
Multivector and multiprocessor
Multivector and multiprocessorMultivector and multiprocessor
Multivector and multiprocessorKishan Panara
 
Interprocess communication
Interprocess communicationInterprocess communication
Interprocess communicationSushil Singh
 
Lecture 6
Lecture  6Lecture  6
Lecture 6Mr SMAK
 
Inter Process Communication Presentation[1]
Inter Process Communication Presentation[1]Inter Process Communication Presentation[1]
Inter Process Communication Presentation[1]Ravindra Raju Kolahalam
 
remote procedure calls
  remote procedure calls  remote procedure calls
remote procedure callsAshish Kumar
 
Distributed Shared Memory Systems
Distributed Shared Memory SystemsDistributed Shared Memory Systems
Distributed Shared Memory SystemsArush Nagpal
 
Unit II - 3 - Operating System - Process Synchronization
Unit II - 3 - Operating System - Process SynchronizationUnit II - 3 - Operating System - Process Synchronization
Unit II - 3 - Operating System - Process Synchronizationcscarcas
 
Distributed File Systems
Distributed File Systems Distributed File Systems
Distributed File Systems Maurvi04
 
Parallel programming model, language and compiler in ACA.
Parallel programming model, language and compiler in ACA.Parallel programming model, language and compiler in ACA.
Parallel programming model, language and compiler in ACA.MITS Gwalior
 
Operating System 3
Operating System 3Operating System 3
Operating System 3tech2click
 
Inter process communication
Inter process communicationInter process communication
Inter process communicationMohd Tousif
 
Computer architecture multi processor
Computer architecture multi processorComputer architecture multi processor
Computer architecture multi processorMazin Alwaaly
 

Tendances (20)

IPC
IPCIPC
IPC
 
Chapter 4 a interprocess communication
Chapter 4 a interprocess communicationChapter 4 a interprocess communication
Chapter 4 a interprocess communication
 
Multivector and multiprocessor
Multivector and multiprocessorMultivector and multiprocessor
Multivector and multiprocessor
 
Distributed Operating System_4
Distributed Operating System_4Distributed Operating System_4
Distributed Operating System_4
 
Interprocess communication
Interprocess communicationInterprocess communication
Interprocess communication
 
Distributed Operating System_1
Distributed Operating System_1Distributed Operating System_1
Distributed Operating System_1
 
Lecture 6
Lecture  6Lecture  6
Lecture 6
 
1.prallelism
1.prallelism1.prallelism
1.prallelism
 
Semaphore
SemaphoreSemaphore
Semaphore
 
Inter Process Communication Presentation[1]
Inter Process Communication Presentation[1]Inter Process Communication Presentation[1]
Inter Process Communication Presentation[1]
 
Os Threads
Os ThreadsOs Threads
Os Threads
 
remote procedure calls
  remote procedure calls  remote procedure calls
remote procedure calls
 
Distributed Shared Memory Systems
Distributed Shared Memory SystemsDistributed Shared Memory Systems
Distributed Shared Memory Systems
 
Parallel processing
Parallel processingParallel processing
Parallel processing
 
Unit II - 3 - Operating System - Process Synchronization
Unit II - 3 - Operating System - Process SynchronizationUnit II - 3 - Operating System - Process Synchronization
Unit II - 3 - Operating System - Process Synchronization
 
Distributed File Systems
Distributed File Systems Distributed File Systems
Distributed File Systems
 
Parallel programming model, language and compiler in ACA.
Parallel programming model, language and compiler in ACA.Parallel programming model, language and compiler in ACA.
Parallel programming model, language and compiler in ACA.
 
Operating System 3
Operating System 3Operating System 3
Operating System 3
 
Inter process communication
Inter process communicationInter process communication
Inter process communication
 
Computer architecture multi processor
Computer architecture multi processorComputer architecture multi processor
Computer architecture multi processor
 

En vedette

Important sections of IPC - By Abirami.G
Important sections of IPC - By Abirami.GImportant sections of IPC - By Abirami.G
Important sections of IPC - By Abirami.GSchin Dler
 
Indian Penal Code - by Alvin Jo caleb
Indian Penal Code - by Alvin Jo calebIndian Penal Code - by Alvin Jo caleb
Indian Penal Code - by Alvin Jo calebSchin Dler
 
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
 
Mobile Ad hoc Networks
Mobile Ad hoc NetworksMobile Ad hoc Networks
Mobile Ad hoc NetworksJagdeep Singh
 

En vedette (8)

Indian Penal Code in India
Indian Penal Code in IndiaIndian Penal Code in India
Indian Penal Code in India
 
The Indian Penal Code.
The Indian Penal Code.The Indian Penal Code.
The Indian Penal Code.
 
Important sections of IPC - By Abirami.G
Important sections of IPC - By Abirami.GImportant sections of IPC - By Abirami.G
Important sections of IPC - By Abirami.G
 
Indian Penal Code - by Alvin Jo caleb
Indian Penal Code - by Alvin Jo calebIndian Penal Code - by Alvin Jo caleb
Indian Penal Code - by Alvin Jo caleb
 
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
 
Mobile Ad hoc Networks
Mobile Ad hoc NetworksMobile Ad hoc Networks
Mobile Ad hoc Networks
 
Inter Process Communication
Inter Process CommunicationInter Process Communication
Inter Process Communication
 

Similaire à Ipc ppt

Linux@assignment ppt
Linux@assignment pptLinux@assignment ppt
Linux@assignment pptRama .
 
Inter-Process-Communication (or IPC for short) are mechanisms provid.pdf
Inter-Process-Communication (or IPC for short) are mechanisms provid.pdfInter-Process-Communication (or IPC for short) are mechanisms provid.pdf
Inter-Process-Communication (or IPC for short) are mechanisms provid.pdfaesalem06
 
Networking threads
Networking threadsNetworking threads
Networking threadsNilesh Pawar
 
Chorus - Distributed Operating System [ case study ]
Chorus - Distributed Operating System [ case study ]Chorus - Distributed Operating System [ case study ]
Chorus - Distributed Operating System [ case study ]Akhil Nadh PC
 
Operating Systems - "Chapter 4: Multithreaded Programming"
Operating Systems - "Chapter 4:  Multithreaded Programming"Operating Systems - "Chapter 4:  Multithreaded Programming"
Operating Systems - "Chapter 4: Multithreaded Programming"Ra'Fat Al-Msie'deen
 
Lec+3-Introduction-to-Distributed-Systems.pdf
Lec+3-Introduction-to-Distributed-Systems.pdfLec+3-Introduction-to-Distributed-Systems.pdf
Lec+3-Introduction-to-Distributed-Systems.pdfsamaghorab
 
Lecture 3,4 operating systems
Lecture 3,4   operating systemsLecture 3,4   operating systems
Lecture 3,4 operating systemsPradeep Kumar TS
 
Lecture 3,4 operating systems
Lecture 3,4   operating systemsLecture 3,4   operating systems
Lecture 3,4 operating systemsPradeep Kumar TS
 
OS Module-2.pptx
OS Module-2.pptxOS Module-2.pptx
OS Module-2.pptxbleh23
 
Multi threaded programming
Multi threaded programmingMulti threaded programming
Multi threaded programmingAnyapuPranav
 
Parallel Processing (Part 2)
Parallel Processing (Part 2)Parallel Processing (Part 2)
Parallel Processing (Part 2)Ajeng Savitri
 
Operating System 4 1193308760782240 2
Operating System 4 1193308760782240 2Operating System 4 1193308760782240 2
Operating System 4 1193308760782240 2mona_hakmy
 

Similaire à Ipc ppt (20)

Sucet os module_2_notes
Sucet os module_2_notesSucet os module_2_notes
Sucet os module_2_notes
 
Topic 4- processes.pptx
Topic 4- processes.pptxTopic 4- processes.pptx
Topic 4- processes.pptx
 
Linux@assignment ppt
Linux@assignment pptLinux@assignment ppt
Linux@assignment ppt
 
Chapter04 new
Chapter04 newChapter04 new
Chapter04 new
 
Inter-Process-Communication (or IPC for short) are mechanisms provid.pdf
Inter-Process-Communication (or IPC for short) are mechanisms provid.pdfInter-Process-Communication (or IPC for short) are mechanisms provid.pdf
Inter-Process-Communication (or IPC for short) are mechanisms provid.pdf
 
Networking threads
Networking threadsNetworking threads
Networking threads
 
Wiki 2
Wiki 2Wiki 2
Wiki 2
 
Chorus - Distributed Operating System [ case study ]
Chorus - Distributed Operating System [ case study ]Chorus - Distributed Operating System [ case study ]
Chorus - Distributed Operating System [ case study ]
 
Threads
ThreadsThreads
Threads
 
Operating Systems - "Chapter 4: Multithreaded Programming"
Operating Systems - "Chapter 4:  Multithreaded Programming"Operating Systems - "Chapter 4:  Multithreaded Programming"
Operating Systems - "Chapter 4: Multithreaded Programming"
 
Lec+3-Introduction-to-Distributed-Systems.pdf
Lec+3-Introduction-to-Distributed-Systems.pdfLec+3-Introduction-to-Distributed-Systems.pdf
Lec+3-Introduction-to-Distributed-Systems.pdf
 
Linux Memory Management
Linux Memory ManagementLinux Memory Management
Linux Memory Management
 
MIcrokernel
MIcrokernelMIcrokernel
MIcrokernel
 
CH04.pdf
CH04.pdfCH04.pdf
CH04.pdf
 
Lecture 3,4 operating systems
Lecture 3,4   operating systemsLecture 3,4   operating systems
Lecture 3,4 operating systems
 
Lecture 3,4 operating systems
Lecture 3,4   operating systemsLecture 3,4   operating systems
Lecture 3,4 operating systems
 
OS Module-2.pptx
OS Module-2.pptxOS Module-2.pptx
OS Module-2.pptx
 
Multi threaded programming
Multi threaded programmingMulti threaded programming
Multi threaded programming
 
Parallel Processing (Part 2)
Parallel Processing (Part 2)Parallel Processing (Part 2)
Parallel Processing (Part 2)
 
Operating System 4 1193308760782240 2
Operating System 4 1193308760782240 2Operating System 4 1193308760782240 2
Operating System 4 1193308760782240 2
 

Plus de Ruchi Sharma

Plus de Ruchi Sharma (6)

Rtos
RtosRtos
Rtos
 
Ipc feb4
Ipc feb4Ipc feb4
Ipc feb4
 
EMBEDDED SYSTEMS
EMBEDDED SYSTEMSEMBEDDED SYSTEMS
EMBEDDED SYSTEMS
 
Nn3
Nn3Nn3
Nn3
 
Nn ppt
Nn pptNn ppt
Nn ppt
 
neural networks
neural networksneural networks
neural networks
 

Ipc ppt

  • 1. IPC INTERPROCESS COMMUNICATION  By.Prof.Ruchi Sharma 02/16/13 1
  • 2. Many operating systems provide mechanisms for interprocess communication (IPC)  Processesmust communicate with one another in multiprogrammed and networked environments  For example, a Web browser retrieving data from a distant server  Essential for processes that must coordinate activities to achieve a common goal. 02/16/13 2
  • 3. Software interrupts that notify a process that an event has occurred  Do not allow processes to specify data to exchange with other processes  Processes may catch, ignore or mask a signal  Catching a signal involves specifying a routine that the OS calls when it delivers the signal  Ignoring a signal relies on the operating system’s default action to handle the signal  Masking a signal instructs the OS to not deliver signals of that type until the process clears the signal mask 02/16/13 3
  • 4. Message-based interprocess communication  Messages can be passed in one direction at a time  One process is the sender and the other is the receiver  Message passing can be bidirectional  Each process can act as either a sender or a receiver  Messages can be blocking or nonblocking  Blocking requires the receiver to notify the sender when the message is received  Nonblocking enables the sender to continue with other processing  Popular implementation is a pipe  A region of memory protected by the OS that serves as a buffer, allowing two or more processes to exchange data 02/16/13 4
  • 5. UNIX processes  All processes are provided with a set of memory addresses, called a virtual address space  A process’s PCB is maintained by the kernel in a protected region of memory that user processes cannot access  A UNIX PCB stores:  The contents of the processor registers  PID  The program counter  The system stack  All processes are listed in the process table 02/16/13 5
  • 6. UNIX processes continued  All processes interact with the OS via system calls  A process can spawn a child process by using the fork system call, which creates a copy of the parent process  Child receives a copy of the parent’s resources as well  Process priorities are integers between -20 and 19 (inclusive)  A lower numerical priority value indicates a higher scheduling priority  UNIXprovides IPC mechanisms, such as pipes, to allow unrelated processes to transfer data 02/16/13 6
  • 7. Figure 3.10 UNIX system calls. 02/16/13 7
  • 8. Outline 4.1 Introduction 4.2 Definition of Thread 4.3 Motivation for Threads 4.4 Thread States: Life Cycle of a Thread 4.5 Thread Operations 4.6 Threading Models 4.6.1 User-Level Threads 4.6.2 Kernel-Level Threads 4.6.3 Combining User- and Kernel-Level Threads 4.7 Thread Implementation Considerations 4.7.1 Thread Signal Delivery 4.7.2 Thread Termination 4.8 POSIX and Pthreads 4.9 Linux Threads 4.10 Windows XP Threads 4.11 Java Multithreading Case Study, Part 1: Introduction to Java Threads 02/16/13 8
  • 9. After reading this chapter, you should understand:  the motivation for creating threads.  the similarities and differences between processes and threads.  the various levels of support for threads.  the life cycle of a thread.  thread signaling and cancellation.  the basics of POSIX, Linux, Windows XP and Java threads. 02/16/13 9
  • 10. General-purpose languages such as Java, C#, Visual C++ .NET, Visual Basic .NET and Python have made concurrency primitives available to applications programmer  Multithreading  Programmer specifies applications contain threads of execution  Each thread designate a portion of a program that may execute concurrently with other threads 02/16/13 10
  • 11. Thread  Lightweight process (LWP)  Threads of instructions or thread of control  Shares address space and other global information with its process  Registers, stack, signal masks and other thread-specific data are local to each thread  Threads may be managed by the operating system or by a user application  Examples: Win32 threads, C-threads, Pthreads 02/16/13 11
  • 12. Figure 4.1 Thread Relationship to Processes. 02/16/13 12
  • 13. Threads have become prominent due to trends in  Software design  More naturally expresses inherently parallel tasks  Performance  Scales better to multiprocessor systems  Cooperation  Shared address space incurs less overhead than IPC 02/16/13 13
  • 14. Each thread transitions among a series of discrete thread states  Threads and processes have many operations in common (e.g. create, exit, resume, and suspend)  Thread creation does not require operating system to initialize resources that are shared between parent processes and its threads  Reducesoverhead of thread creation and termination compared to process creation and termination 02/16/13 14
  • 15. Figure 4.2 Thread life cycle. 02/16/13 15
  • 16. User-level threads perform threading operations in user space  Threads are created by runtime libraries that cannot execute privileged instructions or access kernel primitives directly  User-level thread implementation  Many-to-one thread mappings  Operating system maps all threads in a multithreaded process to single execution context  Advantages  User-level libraries can schedule its threads to optimize performance  Synchronization performed outside kernel, avoids context switches  More portable  Disadvantage  Kernel views a multithreaded process as a single thread of control  Can lead to suboptimal performance if a thread issues I/O  Cannot be scheduled on multiple processors at once 02/16/13 16
  • 17. Figure 4.3 User-level threads. 02/16/13 17
  • 18. Kernel-level threads attempt to address the limitations of user-level threads by mapping each thread to its own execution context  Kernel-level threads provide a one-to-one thread mapping  Advantages: Increased scalability, interactivity, and throughput  Disadvantages: Overhead due to context switching and reduced portability due to OS-specific APIs  Kernel-level threads are not always the optimal solution for multithreaded applications 02/16/13 18
  • 20. The combination of user- and kernel-level thread implementation  Many-to-many thread mapping (m-to-n thread mapping)  Number of user and kernel threads need not be equal  Can reduce overhead compared to one-to-one thread mappings by implementing thread pooling  Worker threads  Persistent kernel threads that occupy the thread pool  Improves performance in environments where threads are frequently created and destroyed  Each new thread is executed by a worker thread  Scheduler activation  Technique that enables user-level library to schedule its threads  Occurs when the operating system calls a user-level threading library that determines if any of its threads need rescheduling 02/16/13 20
  • 21. Figure 4.5 Hybrid threading model. 02/16/13 21