Inter-Process Communication (IPC)

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to Lesson

Podcast

Play an AI-generated podcast conversation about this lesson
Download our mobile app to listen on the go
Get App

Questions and Answers

Message passing is often slower because of the use of ______ calls for message transfers.

system

In message passing, processes communicate without using ______ variables.

shared

The two main operations provided by an IPC (Inter-Process Communication) facility are send(message) and ______(message).

receive

Before processes can exchange messages, they must establish a communication ______ between them.

<p>link</p> Signup and view all the answers

Message passing is suited for smaller ______ that need to be transferred across multiple systems

<p>data</p> Signup and view all the answers

With direct communication, processes must name each other ______.

<p>explicitly</p> Signup and view all the answers

In direct communication, a link is associated with exactly one pair of ______ processes.

<p>communicating</p> Signup and view all the answers

Messages are directed and received from ______ in indirect communication.

<p>mailboxes</p> Signup and view all the answers

Each mailbox in indirect communication has a unique ______.

<p>id</p> Signup and view all the answers

Processes can communicate in indirect communication only if they share a ______.

<p>mailbox</p> Signup and view all the answers

[Blank] is considered synchronous message passing.

<p>blocking</p> Signup and view all the answers

In blocking send, the sender is blocked until the message is ______.

<p>received</p> Signup and view all the answers

In non-blocking send, the sender sends the message and ______.

<p>continues</p> Signup and view all the answers

If both send and receive are blocking, we have a ______.

<p>rendezvous</p> Signup and view all the answers

Two-way communication using pipes is known as ______-duplex.

<p>full</p> Signup and view all the answers

Ordinary pipes require a ______-child relationship between communicating processes.

<p>parent</p> Signup and view all the answers

Ordinary pipes cannot be accessed from outside the process that ______ it.

<p>created</p> Signup and view all the answers

Communication via ordinary pipes is ______.

<p>unidirectional</p> Signup and view all the answers

[Blank] pipes do not require a parent-child relationship between communicating processes.

<p>named</p> Signup and view all the answers

Status data from child to parent is returned via the ______() system call.

<p>wait</p> Signup and view all the answers

Process resources are deallocated by the ______.

<p>operating system</p> Signup and view all the answers

A parent process can terminate child processes using the ______() system call.

<p>abort</p> Signup and view all the answers

If a process terminates and its children are also terminated, this is called ______ termination.

<p>cascading</p> Signup and view all the answers

The ______ process may wait for termination of a child process by using the wait() system call.

<p>parent</p> Signup and view all the answers

If a parent terminates without invoking wait(), the child process becomes an ______.

<p>orphan</p> Signup and view all the answers

Google Chrome uses a ______ architecture with different types of processes.

<p>multiprocess</p> Signup and view all the answers

The ______ process in Chrome manages the user interface, disk I/O, and network I/O.

<p>browser</p> Signup and view all the answers

A new ______ is created for each website opened in a modern web browser.

<p>renderer</p> Signup and view all the answers

Processes within a system may be either ______ or cooperating.

<p>independent</p> Signup and view all the answers

If all processes are CPU bound, the I/O waiting queue will almost always be ______.

<p>empty</p> Signup and view all the answers

A(n) ______ process can affect or be affected by the execution of another process.

<p>cooperating</p> Signup and view all the answers

The system achieves the best performance with a combination of CPU-bound and ______-bound processes.

<p>I/O</p> Signup and view all the answers

[Blank] processes need interprocess communication (IPC).

<p>cooperating</p> Signup and view all the answers

[Blank] and message passing are two models of IPC.

<p>shared memory</p> Signup and view all the answers

Time-sharing systems like UNIX and Microsoft Windows often lack a long-term ______.

<p>scheduler</p> Signup and view all the answers

In the shared memory model, processes exchange information by reading and writing data to a shared region of ______.

<p>memory</p> Signup and view all the answers

The medium-term scheduler is added to decrease the degree of multiple ______.

<p>programming</p> Signup and view all the answers

The process of removing a process from memory and storing it on disk is known as ______.

<p>swapping</p> Signup and view all the answers

[Blank] is faster than message passing because system calls are primarily needed only to establish shared-memory regions.

<p>shared memory</p> Signup and view all the answers

When the CPU switches to another process, it saves the state of the old process and loads the saved state for the new process via a ______ ______.

<p>context switch</p> Signup and view all the answers

In message passing, communication takes place by means of ______ exchanged between the cooperating processes.

<p>messages</p> Signup and view all the answers

The context of a process is represented in the ______.

<p>PCB</p> Signup and view all the answers

______-switch time is overhead because the system does no useful work while switching.

<p>Context</p> Signup and view all the answers

The more complex the OS and the PCB -> the ______ the context switch.

<p>longer</p> Signup and view all the answers

Some hardware provides multiple sets of ______ per CPU, allowing multiple contexts to be loaded at once.

<p>registers</p> Signup and view all the answers

System must provide mechanisms for process ______, process termination, and so on.

<p>creation</p> Signup and view all the answers

Parent process create ______ processes, which, in turn create other processes, forming a tree of processes.

<p>children</p> Signup and view all the answers

Generally, process identified and managed via a process ______ (pid).

<p>identifier</p> Signup and view all the answers

The ______ process (which always has a pid of 1) serves as the root parent process for all the user processes

<p>init</p> Signup and view all the answers

The ______() system call creates new process.

<p>fork</p> Signup and view all the answers

Flashcards

Message Passing

A way for processes to communicate and synchronize without shared variables, using send and receive operations.

Message System

Systems communicate by exchanging discrete packets of data.

Send(message)

An inter-process communication action that transmits a message to another process.

Receive(message)

An inter-process communication action that retrieves a message from another process.

Signup and view all the flashcards

Communication Link

How processes connect to exchange messages, raising questions about link establishment, capacity, and direction.

Signup and view all the flashcards

Sandboxed Renderers

Each website gets its own isolated renderer, enhancing security.

Signup and view all the flashcards

Cooperating Process

A process that can be affected by or affect other processes.

Signup and view all the flashcards

Independent Process

Processes that do not affect or are not affected by other processes.

Signup and view all the flashcards

Reasons for Process Cooperation

Sharing information, computation speedup, modularity, and convenience.

Signup and view all the flashcards

Interprocess Communication (IPC)

Enables cooperating processes to communicate and synchronize.

Signup and view all the flashcards

IPC Models

Shared memory and message passing.

Signup and view all the flashcards

Shared Memory (IPC)

Processes exchange information by reading/writing to a shared memory region.

Signup and view all the flashcards

Message Passing (IPC)

Processes communicate by exchanging messages.

Signup and view all the flashcards

Child Process Return

Data from child process to parent after termination.

Signup and view all the flashcards

Process Deallocation

OS reclaims resources after process completes.

Signup and view all the flashcards

Process Abort

Parent ends child process execution.

Signup and view all the flashcards

Cascading Termination

Children processes are terminated when a parent process terminates.

Signup and view all the flashcards

wait() System Call

System call used by a parent to wait for a child process to terminate.

Signup and view all the flashcards

Zombie Process

A process that has terminated, but its status hasn't been collected.

Signup and view all the flashcards

Orphan Process

A process whose parent has terminated.

Signup and view all the flashcards

Browser Process (Chrome)

Process that handles UI, disk I/O, network I/O in Chrome.

Signup and view all the flashcards

Half or Full-Duplex with Pipes?

Two-way communication where data flows in both directions, but only one direction at a time.

Signup and view all the flashcards

Pipe Process Relationship?

Ordinary pipes require a parent-child relationship between communicating processes.

Signup and view all the flashcards

Pipes Over a Network?

Ordinary pipes cannot be accessed from outside the process that created it.

Signup and view all the flashcards

Ordinary Pipe Communication?

Communication is unidirectional, with a producer writing to one end and a consumer reading from the other.

Signup and view all the flashcards

Named Pipe Communication?

Communication is bidirectional, and no parent-child relationship is needed.

Signup and view all the flashcards

Context Switch

Occurs when CPU switches to another process, saving the state of the old and loading the saved state for the new process.

Signup and view all the flashcards

Process Context

Stored in the PCB, it represents all information needed to restart a process from where it left off.

Signup and view all the flashcards

Context-switch Time

Time spent switching processes. The system does no useful work during this time.

Signup and view all the flashcards

Process Creation

An operation that creates a new process.

Signup and view all the flashcards

Process Identifier (PID)

A unique identifier used to manage a process.

Signup and view all the flashcards

Parent Process

The process that creates child processes.

Signup and view all the flashcards

Child Processes

Processes created by a parent process.

Signup and view all the flashcards

Resource Sharing (Processes)

Can include sharing all, a subset, or none of the parent's resources.

Signup and view all the flashcards

Process Termination

A process can execute its last statement and ask the OS to delete it.

Signup and view all the flashcards

fork() System Call

A system call that creates a new process (a duplicate of the parent).

Signup and view all the flashcards

exec() System Call

A system call used after fork() to replace the process's memory space with a new program.

Signup and view all the flashcards

init Process

Has a PID of 1 and serves as the root parent process for all user processes in Linux

Signup and view all the flashcards

Process Control Block (PCB)

A process table entry associated with each process, containing information about the process' execution state and resources

Signup and view all the flashcards

Swapping

Moving a partially executed program from main memory to secondary storage to free up memory. The program can be brought back into memory to continue execution

Signup and view all the flashcards

Direct Communication

Processes explicitly name each other to communicate.

Signup and view all the flashcards

Indirect Communication

Messages are sent to and received from shared mailboxes (ports).

Signup and view all the flashcards

Blocking Send (Synchronous)

Sender blocks until the message is received.

Signup and view all the flashcards

Blocking Receive (Synchronous)

Receiver blocks until a message is available.

Signup and view all the flashcards

Non-Blocking Send (Asynchronous)

Sender sends the message and continues without waiting.

Signup and view all the flashcards

Non-Blocking Receive (Asynchronous)

Receiver receives a valid message or a null message immediately.

Signup and view all the flashcards

Rendezvous

Both sender and receiver are blocked until the message is delivered.

Signup and view all the flashcards

Buffer (in message passing)

A data structure that holds messages temporarily.

Signup and view all the flashcards

Synchronous Communication

Sender is blocked until message is received and receiver is blocked until a message is available.

Signup and view all the flashcards

Asynchronous Communication

Sender sends the message and continue and receiver receives either valid or null message.

Signup and view all the flashcards

Study Notes

Chapter 3: Processes

  • Chapter 3 is about processes in operating systems.
  • It covers topics such as process concepts, scheduling, operations, interprocess communication (IPC), IPC system examples, and client-server communication.

Terms to remember

  • Uniprogramming means the RAM is dedicated to a single process.
  • Multiprogramming means the RAM supports multiple processes.
  • Multitasking means RAM supports multiple processes belonging to different users.
  • Multiprocessing involves multiple CPUs or microprocessors.
  • Multithreading involves having multiple threads inside a single process.

Process Concept

  • An OS executes a variety of programs, referred to as jobs in batch systems, and user programs or tasks in time-shared systems.
  • The terms "job" and "process" can be used interchangeably.
  • A process is a program in execution, progressing in a sequential manner.
  • A program is considered a passive entity stored on disk in an executable file that becomes an active process when loaded into memory.
  • Execution of a program can start via GUI or command line.
  • Multiple processes can arise from a single program, potentially with different users executing the same program.

Process in memory

  • The program code, or text section contains current activity including the program counter and processor registers.
  • A stack contains temporary data like function parameters, return addresses, and local variables.
  • A data section contains global variables.
  • A heap contains memory dynamically allocated during runtime.

Process Control Block (PCB)

  • The PCB (also called task control block) holds information associated with each process:
  • Process state such as running, waiting, etc.
  • Process identification number
  • Location of the instruction to execute determined by the program counter
  • Contents of all process-centric CPU registers
  • CPU scheduling information (priorities, queue pointers)
  • Memory-management information
  • Accounting information (CPU usage, time limits)
  • I/O status information (allocated I/O devices, open files)

Process state

  • As a process executes, it changes state:
  • New: being created
  • Running: Instructions are being executed
  • Waiting: waiting for an event to occur
  • Ready: waiting to be assigned to a processor
  • Terminated: finished execution

Process Representation in Linux

  • Linux represents processes using a C structure task_struct, containing, among other things...
  • Process identifier (pid_t_pid)
  • State of the process (long state)
  • Scheduling information (unsigned int time slice)
  • Pointer to parent process (struct task_struct *parent)
  • List of child processes (struct list_head children)
  • List of open files (struct files struct *files)
  • Address space of process ( struct mm struct *mm)

Threads

  • A process has a single thread of execution.
  • Multiple program counters per process allow multiple locations to execute at once.
  • Multiple threads of control are also known as "threads".
  • Storage for thread details and multiple program counters is required in the PCB.
  • Details about threads are covered in the next chapter.

Process Scheduling

  • Process scheduling maximises CPU use and quickly switches processes onto the CPU for time sharing.
  • The process scheduler selects available processes for the next execution on CPU.
  • Processes are maintained in scheduling queues:
  • Job queue: set of all processes in the system
  • Ready queue: set of processes residing in main memory, ready and waiting
  • Device queues: set of processes waiting for an I/O device
  • Processes migrate among the various queues.

Schedulers

  • Short-term scheduler (or CPU scheduler): selects the next process to be executed and allocates CPU; invoked frequently (milliseconds).
  • Long-term scheduler (or job scheduler): selects processes to be brought into the ready queue; invoked infrequently (seconds, minutes); controls the degree of multiprogramming.
  • I/O-bound process spends more time doing I/O than computations, many short CPU bursts.
  • CPU-bound process spends more time doing computations, few very long CPU bursts.
  • The Long-term scheduler strives for process mixes for both I/O and CPU bound.
  • Time-sharing systems like UNIX and Microsoft Windows often have no long-term scheduler.
  • Medium-term scheduler can be added to reduce the degree of multiple programming. It removes processes from memory, stores them on disk (swapping).
  • Context Switch
  • The system must save the state of the old process and load the saved state for the new process. The context of a process represented in the Process Control Block (PCB).
  • Context-switch time is overhead; the system does no useful work while switching.

Operations on Processes

  • The OS provides mechanisms for process creation and termination

Process Creation

  • A parent process creates children processes, forming a tree of processes.
  • Processes are identified and managed via a process identifier (pid)
  • Resource sharing: -Parent and children share all resources -Children share subset of parent's resources -Parent and child share no resources
  • Execution: -Parents and children execute concurrently -Parent waits until children terminate
  • Unix provides system calls to manage processes.
  • fork(): is the system call to create a new process
  • exec()is used after fork() to replace the process' memory space with a new program

Process Termination

  • Processes execute the last statement and uses the exit() system call to ask the OS to delete it.
  • Status data is returned from child to parent via wait()
  • The OS deallocates resources after process termination
  • Parent processes may terminate child processes via the abort() system call for reasons such as -child exceeding allocated resources -task assigned to child isn't required -parent exiting where the OS doesn't allow child to continue without its parent
  • Cascading termination occurs when some OS do not allow a child process to exists if its parents terminates. When a process terminates all children are also terminated.
  • If a parent process may wait for termination of a child process by using the wait() system call.
  • A zombie process occurs if there is no parent waiting or the invoke is did not invoke wait()
  • An orphan process is when the parent terminates without invoking wait()

Multiprocess Architecture – Chrome Browser

  • Early web browsers used a single process and if one website had issues teh entire browers could hang or crash the browser
  • Google Chrome implements Multiprocess Architecture with 3 different types of processes:
  • Browser (manages user interface, disk and network I/O)
  • Renderer (renders web pages, deals with HTML and Javascript and each website opens uses a new renderer). Runs in sandbox restricting disk and network I/O
  • Plug-in (implemented for each plugin)

Interprocess Communication

  • Processes within a system may be independent or cooperating.
  • 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.
  • Reasons for cooperating processes: -Information sharing -Computation speedup -Modularity
  • Cooperating processes need interprocess communication (IPC).
  • Shared memory and Message passing are two models of IPC.
  • Shared memory establishes a region of memory that is shared by cooperating processes where processes can exchange inforation by reading and writing data to a region.
  • Message passing means communication takes place by means of message exchanged between cooperating processes

IPC Message Passing

  • IPC provides 2 facilities:
  • send(message)
  • receive(message)
  • The message size is either fixed or variable.
  • To communicate, processes P and Q need to: -Establish a communication link between them. -Exchange messages via send/receive.
  • Implementation Issues -How links are established? -Can a link be associated with more than two processes? -How many links can there be between every pair of communicating processes? -What is the capacity of a link? -Is the size of a message that the link can accommodate fixed or variable? -Is a link unidirectional or bi-directional?
  • Methods for logically implementing a link and the send/receive operations include... -Direct or indirect communication -Synchronous or asynchronous -Automatic or explicit buffering

Communication methods

  • Direct Communication -Processes must name each other explicitly (know each other): -send (P, message) is sending a message to name/known process P -receive (Q, message)is receiving a message from process Q
  • Properties of the communication link are: Link established automatically -A link is associated with exactly one pair of communicating processes -Between each pair there exists exactly one link -The link may be unidirectional, but is usually bi-directional
  • Indirect Communication -Messages are directed/received from mailboxes (also ports) -Each mailbox has a unique ID -Processes can only communicate if they share a mailbox -Properties of the communication link are: -Links established if processes share a common mailbox -A link may be associated with many processes -Each pair of processes may share several communication links -Link may be unidirectional, but is usually bi-directional
  • Primitives are defined as: -send(A, message) is sending a message to mailbox A -receive(A, message) receive a message from mailbox A

Synchronization

  • Modes: -Message passing may be either blocking or non-blocking
  • Blocking (synchronous) --Blocking send means the sender is blocked until the message is received --Blocking receive means the receiver is blocked until a message is available -Non-blocking (asynchronous) --Non-blocking send means the sender sends the message and continues --Non-blocking receive means the receiver receives either a valid message or a null message
  • When both send/receive are blocking, it is called a rendezvous

Buffering

  • Queue of messages attached to the link.
  • Implements in one of three ways: Zero capacity: no messages are queued on a link where the sender must wait for the receiver (rendezvous) Bounded capacity: finite length of n messages meaning the sender must wait if the link is full Unbounded capacity: infinite length meaning the sender never waits

Producer-Consumer Problem

  • This is a paradigm for cooperating processes where the producer process produces information that is consumed by a consumer process -When the buffer is limited, it is "unbound-buffer" since there is no limit on size -When there is a fixed buffer size, it is called "bound-buffer"

Communications in Client-Server Systems

  • These are methods for inter-process communication where processes are on different computers: -Sockets -Remote Procedure Calls -Pipes -Remote Method Invocation (Java)

Sockets

  • A socket is defined as an endpoint for communication.
  • A concatenation of the IP address and a port.
  • All ports below 1024 are well known and used for standard services.
  • Special IP address 127.0.0.1 (loopback) to refer to the system which process is running

Remote Procedure Calls

  • Remote procedure call (RPC) abstracts procedure calls between processes on networked systems.
  • Stubs are client proxies for the actual procedure on the server.
  • The client-side stub finds the server and marshalls the parameters.
  • The server-side stub receives the message and unpacks parameters and performs the procedure on the server.
  • It uses external data representation, Big-endian and little-endian.
  • Typically has a rendezvous/matchmaker service to connect client and server.

Pipes

  • Acts as a conduit allowing two processes to communicate.
  • Issues to consider: -Is communication unidirectional/bidirectional? -In the case of two-way communication; half/full-duplex? -Must a parent/child relationship exist betw. comm processes? -Can the pipes be used over a network?
  • Ordinary pipes: cannot be accessed from outside the process that created it where a parent creates a pipe and connects it with a child.
  • Named pipes: can be accessed without a parent-child relationship. Ordinary Pipes
  • Allow communication in standard producer-consumer style.
  • Producers write to one end, called the Write-end.
  • Consumers read from the other end, called the Read-end.
  • Pipes are unidirectional and require parent-child relationship between communicating processes.
  • Windows calls these anonymous pipes.

Named Pipes

  • Named Pipes are more powerful than ordinary pipes.
  • Communcation is bidirectional.
  • No parent-child relationship is necessary between communicating processes.
  • Several processes can use the named pipe for communication.
  • Provided on both UNIX and Linux systems.

Studying That Suits You

Use AI to generate personalized quizzes and flashcards to suit your learning preferences.

Quiz Team

Related Documents

More Like This

Use Quizgecko on...
Browser
Browser