Podcast
Questions and Answers
Message passing is often slower because of the use of ______ calls for message transfers.
Message passing is often slower because of the use of ______ calls for message transfers.
system
In message passing, processes communicate without using ______ variables.
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)
.
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.
Before processes can exchange messages, they must establish a communication ______ between them.
Message passing is suited for smaller ______ that need to be transferred across multiple systems
Message passing is suited for smaller ______ that need to be transferred across multiple systems
With direct communication, processes must name each other ______.
With direct communication, processes must name each other ______.
In direct communication, a link is associated with exactly one pair of ______ processes.
In direct communication, a link is associated with exactly one pair of ______ processes.
Messages are directed and received from ______ in indirect communication.
Messages are directed and received from ______ in indirect communication.
Each mailbox in indirect communication has a unique ______.
Each mailbox in indirect communication has a unique ______.
Processes can communicate in indirect communication only if they share a ______.
Processes can communicate in indirect communication only if they share a ______.
[Blank] is considered synchronous message passing.
[Blank] is considered synchronous message passing.
In blocking send, the sender is blocked until the message is ______.
In blocking send, the sender is blocked until the message is ______.
In non-blocking send, the sender sends the message and ______.
In non-blocking send, the sender sends the message and ______.
If both send and receive are blocking, we have a ______.
If both send and receive are blocking, we have a ______.
Two-way communication using pipes is known as ______-duplex.
Two-way communication using pipes is known as ______-duplex.
Ordinary pipes require a ______-child relationship between communicating processes.
Ordinary pipes require a ______-child relationship between communicating processes.
Ordinary pipes cannot be accessed from outside the process that ______ it.
Ordinary pipes cannot be accessed from outside the process that ______ it.
Communication via ordinary pipes is ______.
Communication via ordinary pipes is ______.
[Blank] pipes do not require a parent-child relationship between communicating processes.
[Blank] pipes do not require a parent-child relationship between communicating processes.
Status data from child to parent is returned via the ______()
system call.
Status data from child to parent is returned via the ______()
system call.
Process resources are deallocated by the ______.
Process resources are deallocated by the ______.
A parent process can terminate child processes using the ______()
system call.
A parent process can terminate child processes using the ______()
system call.
If a process terminates and its children are also terminated, this is called ______ termination.
If a process terminates and its children are also terminated, this is called ______ termination.
The ______ process may wait for termination of a child process by using the wait()
system call.
The ______ process may wait for termination of a child process by using the wait()
system call.
If a parent terminates without invoking wait()
, the child process becomes an ______.
If a parent terminates without invoking wait()
, the child process becomes an ______.
Google Chrome uses a ______ architecture with different types of processes.
Google Chrome uses a ______ architecture with different types of processes.
The ______ process in Chrome manages the user interface, disk I/O, and network I/O.
The ______ process in Chrome manages the user interface, disk I/O, and network I/O.
A new ______ is created for each website opened in a modern web browser.
A new ______ is created for each website opened in a modern web browser.
Processes within a system may be either ______ or cooperating.
Processes within a system may be either ______ or cooperating.
If all processes are CPU bound, the I/O waiting queue will almost always be ______.
If all processes are CPU bound, the I/O waiting queue will almost always be ______.
A(n) ______ process can affect or be affected by the execution of another process.
A(n) ______ process can affect or be affected by the execution of another process.
The system achieves the best performance with a combination of CPU-bound and ______-bound processes.
The system achieves the best performance with a combination of CPU-bound and ______-bound processes.
[Blank] processes need interprocess communication (IPC).
[Blank] processes need interprocess communication (IPC).
[Blank] and message passing are two models of IPC.
[Blank] and message passing are two models of IPC.
Time-sharing systems like UNIX and Microsoft Windows often lack a long-term ______.
Time-sharing systems like UNIX and Microsoft Windows often lack a long-term ______.
In the shared memory model, processes exchange information by reading and writing data to a shared region of ______.
In the shared memory model, processes exchange information by reading and writing data to a shared region of ______.
The medium-term scheduler is added to decrease the degree of multiple ______.
The medium-term scheduler is added to decrease the degree of multiple ______.
The process of removing a process from memory and storing it on disk is known as ______.
The process of removing a process from memory and storing it on disk is known as ______.
[Blank] is faster than message passing because system calls are primarily needed only to establish shared-memory regions.
[Blank] is faster than message passing because system calls are primarily needed only to establish shared-memory regions.
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 ______ ______.
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 ______ ______.
In message passing, communication takes place by means of ______ exchanged between the cooperating processes.
In message passing, communication takes place by means of ______ exchanged between the cooperating processes.
The context of a process is represented in the ______.
The context of a process is represented in the ______.
______-switch time is overhead because the system does no useful work while switching.
______-switch time is overhead because the system does no useful work while switching.
The more complex the OS and the PCB -> the ______ the context switch.
The more complex the OS and the PCB -> the ______ the context switch.
Some hardware provides multiple sets of ______ per CPU, allowing multiple contexts to be loaded at once.
Some hardware provides multiple sets of ______ per CPU, allowing multiple contexts to be loaded at once.
System must provide mechanisms for process ______, process termination, and so on.
System must provide mechanisms for process ______, process termination, and so on.
Parent process create ______ processes, which, in turn create other processes, forming a tree of processes.
Parent process create ______ processes, which, in turn create other processes, forming a tree of processes.
Generally, process identified and managed via a process ______ (pid).
Generally, process identified and managed via a process ______ (pid).
The ______ process (which always has a pid of 1) serves as the root parent process for all the user processes
The ______ process (which always has a pid of 1) serves as the root parent process for all the user processes
The ______() system call creates new process.
The ______() system call creates new process.
Flashcards
Message Passing
Message Passing
A way for processes to communicate and synchronize without shared variables, using send
and receive
operations.
Message System
Message System
Systems communicate by exchanging discrete packets of data.
Send(message)
Send(message)
An inter-process communication action that transmits a message to another process.
Receive(message)
Receive(message)
Signup and view all the flashcards
Communication Link
Communication Link
Signup and view all the flashcards
Sandboxed Renderers
Sandboxed Renderers
Signup and view all the flashcards
Cooperating Process
Cooperating Process
Signup and view all the flashcards
Independent Process
Independent Process
Signup and view all the flashcards
Reasons for Process Cooperation
Reasons for Process Cooperation
Signup and view all the flashcards
Interprocess Communication (IPC)
Interprocess Communication (IPC)
Signup and view all the flashcards
IPC Models
IPC Models
Signup and view all the flashcards
Shared Memory (IPC)
Shared Memory (IPC)
Signup and view all the flashcards
Message Passing (IPC)
Message Passing (IPC)
Signup and view all the flashcards
Child Process Return
Child Process Return
Signup and view all the flashcards
Process Deallocation
Process Deallocation
Signup and view all the flashcards
Process Abort
Process Abort
Signup and view all the flashcards
Cascading Termination
Cascading Termination
Signup and view all the flashcards
wait() System Call
wait() System Call
Signup and view all the flashcards
Zombie Process
Zombie Process
Signup and view all the flashcards
Orphan Process
Orphan Process
Signup and view all the flashcards
Browser Process (Chrome)
Browser Process (Chrome)
Signup and view all the flashcards
Half or Full-Duplex with Pipes?
Half or Full-Duplex with Pipes?
Signup and view all the flashcards
Pipe Process Relationship?
Pipe Process Relationship?
Signup and view all the flashcards
Pipes Over a Network?
Pipes Over a Network?
Signup and view all the flashcards
Ordinary Pipe Communication?
Ordinary Pipe Communication?
Signup and view all the flashcards
Named Pipe Communication?
Named Pipe Communication?
Signup and view all the flashcards
Context Switch
Context Switch
Signup and view all the flashcards
Process Context
Process Context
Signup and view all the flashcards
Context-switch Time
Context-switch Time
Signup and view all the flashcards
Process Creation
Process Creation
Signup and view all the flashcards
Process Identifier (PID)
Process Identifier (PID)
Signup and view all the flashcards
Parent Process
Parent Process
Signup and view all the flashcards
Child Processes
Child Processes
Signup and view all the flashcards
Resource Sharing (Processes)
Resource Sharing (Processes)
Signup and view all the flashcards
Process Termination
Process Termination
Signup and view all the flashcards
fork() System Call
fork() System Call
Signup and view all the flashcards
exec() System Call
exec() System Call
Signup and view all the flashcards
init Process
init Process
Signup and view all the flashcards
Process Control Block (PCB)
Process Control Block (PCB)
Signup and view all the flashcards
Swapping
Swapping
Signup and view all the flashcards
Direct Communication
Direct Communication
Signup and view all the flashcards
Indirect Communication
Indirect Communication
Signup and view all the flashcards
Blocking Send (Synchronous)
Blocking Send (Synchronous)
Signup and view all the flashcards
Blocking Receive (Synchronous)
Blocking Receive (Synchronous)
Signup and view all the flashcards
Non-Blocking Send (Asynchronous)
Non-Blocking Send (Asynchronous)
Signup and view all the flashcards
Non-Blocking Receive (Asynchronous)
Non-Blocking Receive (Asynchronous)
Signup and view all the flashcards
Rendezvous
Rendezvous
Signup and view all the flashcards
Buffer (in message passing)
Buffer (in message passing)
Signup and view all the flashcards
Synchronous Communication
Synchronous Communication
Signup and view all the flashcards
Asynchronous Communication
Asynchronous Communication
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 processexec()
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.