Professional Documents
Culture Documents
Chapter 3: Processes
Process Concept
Process Scheduling
Operations on Processes
Interprocess Communication
Examples of IPC Systems
Communication in Client-Server Systems
3.2
Objectives
To introduce the notion of a process -- a program in execution,
3.3
Process Concept
An operating system executes a variety of programs:
Multiple parts
3.4
process is active
3.5
Process in Memory
3.6
Process State
As a process executes, it changes state
3.7
3.8
to next execute
centric registers
Memory-management information
3.9
3.10
Threads
So far, process has a single thread of execution
Consider having multiple program counters per process
counters in PCB
3.11
3.12
Process Scheduling
Maximize CPU use, quickly switch processes onto CPU for time
sharing
execution on CPU
3.13
3.14
3.15
Schedulers
3.16
3.17
Due to screen real estate, user interface limits iOS provides for a
3.18
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 via a context switch
The more complex the OS and the PCB the longer the
context switch
3.19
Operations on Processes
System must provide mechanisms for:
process creation,
process termination,
3.20
Process Creation
Parent process create children processes, which, in turn
identifier (pid)
Execution options
3.21
l ogi n
pi d = 8415
khel per
pi d = 6
bash
pi d = 8416
ps
pi d = 9298
sshd
pi d = 3028
kt hreadd
pi d = 2
pdfl ush
pi d = 200
sshd
pi d = 3610
tcsch
pi d = 4005
emacs
pi d = 9204
3.22
UNIX examples
3.23
3.24
3.25
Process Termination
Process executes last statement and then asks the operating
3.26
Process Termination
Some operating systems do not allow child to exists if its parent has
3.27
If one web site causes trouble, entire browser can hang or crash
processes:
3.28
Interprocess Communication
Processes within a system may be independent or cooperating
Cooperating process can affect or be affected by other processes,
Information sharing
Computation speedup
Modularity
Convenience
Shared memory
Message passing
3.29
Communications Models
(a) Message passing.
3.30
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.31
Producer-Consumer Problem
Paradigm for cooperating processes, producer process
3.32
Shared data
#define BUFFER_SIZE 10
typedef struct {
. . .
} item;
item buffer[BUFFER_SIZE];
int in = 0;
int out = 0;
3.33
Bounded-Buffer Producer
item next_produced;
while (true) {
/* produce an item in next produced */
while (((in + 1) % BUFFER_SIZE) == out)
; /* do nothing */
buffer[in] = next_produced;
in = (in + 1) % BUFFER_SIZE;
}
3.34
3.35
to communicate
3.36
their actions
send(message)
receive(message)
3.37
Implementation issues:
3.38
Physical:
Shared memory
Hardware bus
Network
Logical:
Direct or indirect
Synchronous or asynchronous
3.39
Direct Communication
Processes must name each other explicitly:
3.40
Indirect Communication
Messages are directed and received from mailboxes (also referred
to as ports)
3.41
Indirect Communication
Operations
destroy a mailbox
3.42
Indirect Communication
Mailbox sharing
Solutions
3.43
Synchronization
A valid message, or
Null message
3.44
Synchronization (Cont.)
Producer-consumer becomes trivial
message next_produced;
while (true) {
/* produce an item in next produced */
send(next_produced);
}
message next_consumed;
while (true) {
receive(next_consumed);
/* consume the item in next consumed */
3.45
Buffering
Queue of messages attached to the link.
implemented in one of three ways
3.46
3.47
3.48
3.49
Send and receive are flexible, for example four options if mailbox full:
Wait indefinitely
Return immediately
3.50
(LPC) facility
3.51
3.52
3.53
Sockets
A socket is defined as an endpoint for communication
Concatenation of IP address and port a number included at
161.25.19.8
services
3.54
Socket Communication
3.55
Sockets in Java
Three types of sockets
Connection-oriented
(TCP)
Connectionless (UDP)
MulticastSocket
class data can be sent
to multiple recipients
3.56
server
parameters
3.57
3.58
Execution of RPC
3.59
Pipes
Acts as a conduit allowing two processes to communicate
Issues:
relationship.
3.60
Ordinary Pipes
Ordinary Pipes allow communication in standard producer-consumer
style
3.61
Named Pipes
Named Pipes are more powerful than ordinary pipes
Communication is bidirectional
No parent-child relationship is necessary between the
communicating processes
3.62
End of Chapter 3