1 / 25

Department of Computer Science Southern Illinois University Edwardsville Spring, 2010

Inter-Process Communication (IPC). CS 547/490 Network Programming. Department of Computer Science Southern Illinois University Edwardsville Spring, 2010 Dr. Hiroshi Fujinoki E-mail: hfujino@siue.edu. IPC1.PPT/001. Address Space for A. IPC. Process A. Process B. Computer.

hali
Download Presentation

Department of Computer Science Southern Illinois University Edwardsville Spring, 2010

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Inter-Process Communication (IPC) CS 547/490 Network Programming Department of Computer Science Southern Illinois University Edwardsville Spring, 2010 Dr. Hiroshi Fujinoki E-mail: hfujino@siue.edu IPC1.PPT/001

  2. Address Space for A IPC Process A Process B Computer Address Space for B CS 547/490 Network Programming Inter Process Communication: What is “IPC”? IPC is a mechanism for two processes to communicate IPC1.PPT/002

  3. CS 547/490 Network Programming Five Methods for IPC: 1. Pipes (Named Pipes) 2. Message Queue 3. Shared memory 4. Semaphore 5. Monitor IPC1.PPT/003

  4. We can use it through “system calls” CS 547/490 Network Programming What is “pipe”? A pipe is essentially a FIFO data structure (queue) created by OS. Pipe is a shared memory (or shared file) A pipe provides a unidirectional communication channel. A pipe is a communication channel through OS. A pipe provides a communication channel between two independent processes. IPC1.PPT/004

  5. Concept of pipe visualized Process 1 Process 2  Between two processes  Pipe is a FIFO queue FIFO Queue  Pipe is created by OS CS 547/490 Network Programming  Unidirectional channel IPC1.PPT/005

  6.   Process 1 Process 2       CS 547/490 Network Programming • Detailed work is taken care of by OS - The order is preserved by OS - Race condition will not happen FIFO Queue - FIFO enforced by OS (Abstraction of “queue”) IPC1.PPT/006

  7. CS 547/490 Network Programming Five application models for pipe 1. Single Process Model 2. Parallel Multi-Process Model 3. Sequential Multi-Process Model 4. Chain Multi-Process Model 5.Circular Multi-Process Model: IPC1.PPT/007

  8. Process read (pd); pd = pipe; write (pd); FIFO Queue OS CS 547/490 Network Programming (1) Single-Process Model: • External FIFO buffer • Indirect access to FIFO IPC1.PPT/008

  9. FIFO Queue FIFO Queue (Pipe) CS 547/490 Network Programming (1) Single-Process Model (continued): Process read (FIFO); • Internal FIFO buffer • Direct access to FIFO write (FIFO); OS IPC1.PPT/009

  10. Application Example File Request Thread 1 Thread 2 write (fd); read (fd); DISK FIFO Queue CS 547/490 Network Programming (1) Single-Process Model (continued): File Server OS IPC1.PPT/010

  11. Disadvantages Advantages CS 547/490 Network Programming (1) Single-Process Model (continued): • OS takes care of “race condition” problem (some operating systems) • High level of abstraction - Operations as system calls - “Create FIFO”, “Delete FIFO”, “Remove an element”, … etc. - “Fail-safe”: data will be in pipe even after a user process crashes • High overhead (each operation requires system call) • Program becomes “OS dependent” - Can not run on an OS which does not support pipe. IPC1.PPT/011

  12. Process 1 Process 2 read (pd); read (pd); folk write (pd); write (pd); FIFO Queue (Pipe) CS 547/490 Network Programming (2) Parallel Multi-Process Model: OS IPC1.PPT/012

  13. General Parallel Multi-Process Model Process 1 Process 2 Process n    Pipe CS 547/490 Network Programming (2) Parallel Multi-Process Model (continued): IPC1.PPT/013

  14. Application Example  When a request arrives, put the request in the pipe. Server 1  Remove the first job from the pipe. Disk Pipe Server 2 Disk Server n Disk CS 547/490 Network Programming (2) Parallel Multi-Process Model (continued):  Transmit the requested file IPC1.PPT/014

  15. Process 1 Process 1’ read (pd); read (pd); folk write (pd); write (pd); close close CS 547/490 Network Programming (3) Sequential Multi-Process Model: FIFO Queue (Pipe) OS IPC1.PPT/016

  16. Process 1 Process 1’ read (pd); read (pd); write (pd); write (pd); CS 547/490 Network Programming (3) Sequential Multi-Process Model (continued): FIFO Queue (Pipe) OS IPC1.PPT/017

  17. Application Example Transmit Requested File Incoming Request Authenticator File Server read (pd); write (pd); DISK FIFO Queue (Pipe) CS 547/490 Network Programming (3) Sequential Multi-Process Model (continued): OS IPC1.PPT/018

  18. Application Example Server 1 Disk Server 2 Pipe Disk CS 547/490 Network Programming (3) Sequential Multi-Process Model (continued): Authorizer 1 Authorizer 2       Authorizer n Server n Disk IPC1.PPT/019

  19. DISK J6 J5 J4 J3 J2 FIFO File Server Disadvantages Advantages Small jobs stack after a big one CS 547/490 Network Programming (3) Sequential Multi-Process Model (continued): • Better response time - “convoy effect” J1 • High running cost - Hardware/Software Cost - Maintenance Cost - Disk Mirroring IPC1.PPT/020

  20. Pipe 1 Pipe 2 Process 1 Process 2 Process 3 CS 547/490 Network Programming (4) Chain Multi-Process Model: IPC1.PPT/021

  21. Application Example CS 547/490 Network Programming (4) Chain Multi-Process Model (continued): Possible applications? 1. Compiler, assembler, Linker 2. Any processes that contain “steps” 3. Multimedia Stream Decorder/Encorder (File access, encoding, file transmission, etc) IPC1.PPT/022

  22. Process 1 Process 2 read (pd); read (pd); write (pd); write (pd); CS 547/490 Network Programming (5) Circular Multi-Process Model: OS IPC1.PPT/023

  23. Application Example Pipe 2 Client 1 Client 2 Client n Server Pipe 1 CS 547/490 Network Programming (5) Circular Multi-Process Model (continued): Computer IPC1.PPT/024

  24. Disadvantages Advantages CS 547/490 Network Programming (5) Circular Multi-Process Model (continued): • Better security - Users (requestors) can not directly access server • Flexibility (Modularity) - Server can be modified (upgraded) without changing client • High cost (hardware) • Pipe may be a performance bottleneck IPC1.PPT/025

  25. Application Example Server 2 Server 1 Server n Disk Disk Disk Pipe CS 547/490 Network Programming (2) Parallel Multi-Process Model (continued): Job Dispatcher IPC_1.PPT/001

More Related