CH 3
CH 3
CH 3
School of Computing
Department of Computer Science
1
Chapter 3
Processes and Processors in
Distributed Systems
2
Processes and Processors in
Distributed Systems
3.1 Processes and Threads
3.2 Remote Procedure Call (RPC)
• Remote Method Invocation (RMI) with Java
3.3 System Models
• Centralized model
• Client-server model
• Peer-to-peer model
• Multi-tier client-server architectures
• Processor-pool model
3.4 Processor Allocation
3.5 Scheduling in Distributed Systems 3
Processes
• To introduce the notion of a process – a
program in execution, which forms the basis of
all computation.
• Components of process are :
• Data
• Resources
• Status of the process
• Only one process can be running on any
processor at any instant and many processes
may be ready and waiting state.
4
Threads
• A thread is a flow of execution through the
process code, with its own program counter,
system registers and stack.
• If there is only a single thread of control,
computation cannot proceed while the
program is waiting for input.
• The easy solution is to have at least two
threads of control – Multithreading
• That exploit parallelism to attain high
performance 5
6
Example Multithreading
• Spread Sheet Program
• one for handling interaction with the user and
• one for updating the spreadsheet.
• In the mean time, a third thread could be used
for backing up the spreadsheet to disk while the
other two are doing their work.
• Word Processor
• Editor
• Spelling Checker
• Auto Saving
7
Remote Procedure Call (RPC)
• Many distributed systems have been based on
explicit message exchange between processes.
• Programs to call procedures located on other
machines.
• When a process on machine A calls a procedure on
machine B, the calling process on A is suspended,
and execution of the called procedure takes place
on B.
• Major Issue: access transparency
8
Client and Server Stubs
• The idea behind RPC is to make a remote
procedure call look as much as possible like a local
one.
• The calling procedure should not be aware that the
called procedure is executing on a different
machine.
• Client stub packs the parameters (parameter
marshaling) into a message and requests that
message to be sent to the server
• Server stub unpacks the parameters from the
message and then calls the server procedure in the
usual way 9
Client and Server Stubs
11
Passing Value Parameters
2-8
2-14
2-15
Client-to-server binding
15
System Models
• Computers can perform various functions
and each unit in a distributed system may
be responsible for number of functions
• System models
• Centralized model
• Client-server model
• Peer-to-peer model
• Multi-tier client-server architectures
• Processor-pool model
16
Centralized model
• All aspects of the application are hosted on one machine and users directly connect to that
machine.
• The main problem with the centralized model is that it is not easily scalable.
17
Client-server model
• The client-server model is a popular networked
model consisting of three components:
• Service
• Server
• Client
18
Peer-to-peer model
• A peer-to-peer model assumes that each machine has somewhat
equivalent capabilities, that no machine is dedicated to serving others.
19
Multi-tier client-server
architectures
• For certain services, it may make sense to have a
hierarchy of connectivity
• This leads us to examine multitier architectures
• Middle tier is added between the client providing the
user interface and the application server.
20
Processor-pool model
• Use all available computing resources for running jobs
• An operating system can automatically start processes on idle machines and even migrate processes to machines with the most available
CPU cycles
• We maintain a collection of CPUs that can be dynamically assigned to processes on demand.
21
Processor allocation and scheduling
• Determine which process is assigned to which processor, also called load distribution.
• Two categories:
• Nonmigratory: once allocated, can not move, no matter how overloaded the machine is.
• Migratory: can move even if the execution started.
22
The goals of allocation
• Maximize CPU utilization
• Minimize mean response time
23
Response Ratio
• Minimize response ratio
Response ratio-the amount of time it takes to run a process on some machine, divided by how long it would take on some unloaded benchmark processor.
E.g. 1. a 1-sec job that takes 5 sec. The ratio is 5/1.
2. a 1-min job that takes 70 sec. The ratio 7/6
24
Design issues for processor
allocation algorithms
Deterministic versus heuristic algorithms
Deterministic - appropriate when everything about the process is known
Heuristic – load is completely unpredictable
Centralized versus distributed algorithms
Centralized- collecting all information on a single machine
Distributed- information is decentralized
Optimal versus suboptimal algorithms
Optimal- best allocation
Suboptimal- an acceptable
25
• Local versus global algorithms
Local – makes decision based on local transfer policy
Global- based on information gathered from elsewhere about the load
• Sender-initiated versus receiver-initiated algorithms
Sender-initiated- overloaded machine sends out re
requests for help to other machines
Receiver-initiated-idle machines announces to other machines that it has little work
26
Scheduling in Distributed Systems
• Each processor can do its local scheduling without regard to what the other processors are doing.
• So what is an issue here?
• When a group of interacting processes are running on different processors
• Independent scheduling becomes ineffective
27
Example
• Timesharing processing with the slice of 100-msec
• Q. Assume that A sends many messages to D how long it takes to complete one message exchange-
A. 200msec
• Solution: processes that communicate frequently run simultaneously.
29