Professional Documents
Culture Documents
Chapter 3: Processes
Process Concept
Process Scheduling
Operations on Processes
Cooperating Processes
Interprocess Communication
Communication in Client-Server Systems
3.2
Process Concept
An operating system executes a variety of programs:
interchangeably
A process includes:
program counter
stack
data section
3.3
Process in Memory
3.4
Process State
3.5
3.6
3.7
3.8
3.9
3.10
3.11
3.12
Schedulers
Long-term scheduler (or job scheduler) selects which
3.13
3.14
Schedulers (Cont.)
Short-term scheduler is invoked very frequently (milliseconds)
(must be fast)
3.15
Context Switch
When CPU switches to another process, the system must save the
state of the old process and load the saved state for the new
process
while switching
3.16
Process Creation
Parent process create children processes, which, in turn create
Resource sharing
Execution
3.17
UNIX examples
3.18
Process Creation
3.19
3.20
3.21
Process Termination
Process executes last statement and asks the operating system to
delete it (exit)
If parent is exiting
3.22
Cooperating Processes
Independent process cannot affect or be affected by the execution
of another process
another process
Information sharing
Computation speed-up
Modularity
Convenience
3.23
Producer-Consumer Problem
Paradigm for cooperating processes, producer process
3.24
#define BUFFER_SIZE 10
Typedef struct {
...
} item;
item buffer[BUFFER_SIZE];
int in = 0;
int out = 0;
Solution is correct, but can only use BUFFER_SIZE-1 elements
3.25
while (true) {
/* Produce an item */
while (((in = (in + 1) % BUFFER SIZE count) == out)
; /* do nothing -- no free buffers */
buffer[in] = item;
in = (in + 1) % BUFFER SIZE;
{
3.26
3.27
actions
receive(message)
3.28
Implementation Questions
How are links established?
Can a link be associated with more than two processes?
How many links can there be between every pair of communicating
processes?
variable?
3.29
Communications Models
3.30
Direct Communication
Processes must name each other explicitly:
3.31
Indirect Communication
Messages are directed and received from mailboxes (also
referred to as ports)
3.32
Indirect Communication
Operations
destroy a mailbox
3.33
Indirect Communication
Mailbox sharing
Solutions
3.34
Synchronization
3.35
Buffering
Queue of messages attached to the link; implemented in one of
three ways
3.36
Client-Server Communication
Sockets
Remote Procedure Calls
Remote Method Invocation (Java)
3.37
Sockets
A socket is defined as an endpoint for communication
Concatenation of IP address and port
The socket 161.25.19.8:1625 refers to port 1625 on host
161.25.19.8
3.38
Socket Communication
3.39
parameters.
3.40
Execution of RPC
3.41
RPCs.
a remote object.
3.42
Marshalling Parameters
3.43
End of Chapter 3