Operating System
Operating System
Outline
• Process Concept
• Process Scheduling
• Operations on Processes
• Interprocess Communication
• IPC in Shared-Memory Systems
• IPC in Message-Passing Systems
• Communication in Client-Server Systems
Process Concept
• An operating system executes a variety of programs that run as a process.
• Process – a program in execution; process execution must progress in
sequential fashion. No parallel execution of instructions of a single process
• Multiple parts
• The program code, also called text section
• Current activity including program counter, processor registers
• Stack containing temporary data
• Function parameters, return addresses, local variables
• Data section containing global variables
• Heap containing memory dynamically allocated during run time
Process Concept (Cont.)
• Program is passive entity stored on disk (executable file); process is
active
• Program becomes process when an executable file is loaded into memory
• Execution of program started via GUI mouse clicks, command line
entry of its name, etc.
• One program can be several processes
• Consider multiple users executing the same program
Process in Memory
Process State
• As a process executes, it changes state
• New: The process is being created
• Ready: The process is waiting to be assigned to a processor
• Waiting: The process is waiting for some event to occur
• Running: Instructions are being executed
• Terminated: The process has finished execution
Diagram of Process State
Process Control Block (PCB)
Information associated with each process(also called task control block)
• Physical:
• Shared memory
• Hardware bus
• Network
• Logical:
• Direct or indirect
• Synchronous or asynchronous
• Automatic or explicit buffering
Direct Communication
• Producer
message next_produced;
while (true) {
/* produce an item in
next_produced */
send(next_produced);
}
• Consumer
message next_consumed;
while (true) {
receive(next_consumed)
/* consume the item in
next_consumed */
}
Buffering
• Queue of messages attached to the link.
• Implemented in one of three ways
1. Zero capacity – no messages are queued on a link.
Sender must wait for receiver (rendezvous)
2. Bounded capacity – finite length of n messages
Sender must wait if link full
3. Unbounded capacity – infinite length
Sender never waits
Communications in Client-Server Systems
• Sockets
• Remote Procedure Calls
Sockets
• A socket is defined as an endpoint for communication
• Concatenation of IP address and port – a number included at
start of message packet to differentiate network services on a
host
• The socket 161.25.19.8:1625 refers to port 1625 on host
161.25.19.8
• Communication consists between a pair of sockets
All ports below 1024 are well known, used for standard
services(e.g FTP→ 21, HTTP →80,file download →23,Email send → 25)
• Special IP address 127.0.0.1 (loopback) to refer to system on
which process is running
Socket Communication
Remote Procedure Calls
• Remote procedure call (RPC) abstracts procedure calls
between processes on networked systems
• Again uses ports for service differentiation
• Stubs – client-side proxy for the actual procedure on
the server
• The client-side stub locates the server and marshalls
the parameters
• The server-side stub receives this message, unpacks
the marshalled parameters, and performs the
procedure on the server
• On Windows, stub code compile from specification
written in Microsoft Interface Definition Language
(MIDL)
Remote Procedure Calls (Cont.)
• Data representation handled via External Data
Representation (XDL) format to account for
different architectures
• Big-endian and little-endian
• Remote communication has more failure
scenarios than local
• Messages can be delivered exactly once rather than at
most once
• OS typically provides a rendezvous (or
matchmaker) service to connect client and server
Execution of RPC