Escolar Documentos
Profissional Documentos
Cultura Documentos
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
3.3
Process Concept
An operating system executes a variety of programs:
process is active
3.4
Process in Memory
Multiple parts
The program code, also called
text section
Current activity including
variables
Heap containing memory
3.5
Process State
As a process executes, it changes state (sample of 5
state)
3.6
3.7
3.9
3.10
Threads
So far, process has a single thread of execution
Consider having multiple program counters per
process
3.11
Example Execution
12
Trace of Processes
13
14
Process Scheduling
Maximize CPU use, quickly switch processes onto CPU for
time sharing
Process scheduler selects among available processes for
3.15
3.16
3.17
3.18
Schedulers
Long-term scheduler (or job scheduler) selects which
(must be fast)
3.19
multiprogramming
Processes can be described as either:
3.20
3.21
Context Switch
When CPU switches to another process, the
3.22
Process Creation
Parent process create children processes, which, in turn create other
Execution options
3.23
login
pid = 8415
khelper
pid = 6
bash
pid = 8416
ps
pid = 9298
sshd
pid = 3028
kthreadd
pid = 2
pdflush
pid = 200
sshd
pid = 3610
tcsch
pid = 4005
emacs
pid = 9204
3.24
UNIX examples
3.25
3.26
3.27
Process Termination
Process executes last statement and asks the operating system to
delete it (exit())
If parent is exiting
Some
3.28
3.29
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.30
Communications Models
3.31
Cooperating Processes
Independent process cannot affect or be affected by the
Information sharing
Computation speed-up
Modularity
Convenience
3.32
Producer-Consumer Problem
Paradigm for cooperating processes,
3.33
BUFFER_SIZE-1 elements
Operating System Concepts 9th Edition
3.34
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.35
3.36
actions
Message system processes communicate with each other without
receive(message)
3.37
Implementation Questions
How many links can there be between every pair of communicating processes?
Is the size of a message that the link can accommodate fixed or variable?
3.38
Direct Communication
Processes must name each other explicitly:
3.39
Indirect Communication
Messages are directed and received from mailboxes (also referred
to as ports)
3.40
Indirect Communication
Operations
destroy a mailbox
3.41
Indirect Communication
Mailbox sharing
Solutions
3.42
Synchronization
Blocking send has the sender block until the message is received
Non-blocking send has the sender send the message and continue
3.43
Synchronization (Cont.)
Different combinations possible
}
message next_consumed;
while (true) {
receive(next_consumed);
/* consume the item in next consumed */
}
Operating System Concepts 9th Edition
3.44
Buffering
Queue of messages attached to the link;
3.45
3.46
3.47
3.48
Send and receive are flexible, for example four options if mailbox full:
Wait
indefinitely
Wait
at most n milliseconds
Return
immediately
Temporarily
Operating System Concepts 9th Edition
cache a message
3.49
(LPC) facility
The
The
The
3.50
3.51
Pipes
Remote Method Invocation (Java)
3.52
Sockets
All ports below 1024 are well known, used for standard services
3.53
Socket Communication
3.54
3.55
Execution of RPC
3.56
Pipes
Acts as a conduit allowing two processes to
communicate
Issues
3.57
Ordinary Pipes
Ordinary Pipes allow communication in standard producer-
consumer style
Producer writes to one end (the write-end of the pipe)
Consumer reads from the other end (the read-end of the
pipe)
Ordinary pipes are therefore unidirectional
Require parent-child relationship between communicating
processes
3.58
Named Pipes
Named Pipes are more powerful than ordinary pipes
Communication is bidirectional
No parent-child relationship is necessary between the
communicating processes
Several processes can use the named pipe for
communication
Provided on both UNIX and Windows systems
3.59
End of Chapter 3