Chapter 3-Processes
Chapter 3-Processes
Chapter 3-Processes
Introduction
communication takes place between processes
a process is a program in execution
from OS perspective, management and scheduling of
processes is important
other important issues arise in distributed systems
multithreading to enhance performance by overlapping
communication and local processing
how are clients and servers organized and server design
issues
process or code migration for enhancing performance,
reducing communication, to exploit parallelism, and to
dynamically configure clients and servers
software agents that perform a task through cooperation
and agent technology
2
3.1 Threads and their Implementation
how are processes and threads related?
process tables or PCBs are used to keep track of processes
there are usually many processes executing concurrently
processes should not interfere with each other; sharing
resources by processes is transparent
this concurrency transparency has a high price; allocating
resources for a new process and context switching take time
a thread also executes independently from other threads;
but no need of a high degree of concurrency transparency
thereby resulting in better performance
3
threads can be used in both distributed and nondistributed
systems
Threads in Nondistributed Systems
a process has an address space (containing program text
and data) and a single thread of control, as well as other
resources such as open files, child processes, accounting
information, etc.
Process 1 Process 2 Process 3
three processes each with one thread one process with three threads
4
each thread has its own program counter, registers, stack,
and state; but all threads of a process share address space,
global variables and other resources such as open files, etc.
5
Threads take turns in running
Threads allow multiple executions to take place in the same
process environment, called multithreading
Thread Usage – Why do we need threads?
e.g., a wordprocessor has different parts for
interacting with the user
formatting the page as soon as changes are made
timed savings (for auto recovery)
spelling and grammar checking, etc.
1. Simplifying the programming model: since many
activities are going on at once more or less independently
2. They are easier to create and destroy than processes
since they do not have any resources attached to them
3. Performance improves by overlapping activities if there is
too much I/O; i.e., to avoid blocking when waiting for
input or doing calculations, say in a spreadsheet
4. Real parallelism is possible in a multiprocessor system
6
having finer granularity in terms of multiple threads per
process rather than processes provides better performance
and makes it easier to build distributed applications
in nondistributed systems, threads can be used with shared
data instead of processes to avoid context switching
overhead in interprocess communication (IPC)
13
the basic organization of the X Window System
the window manager is a special application and is in charge
of the “look and feel” of the screen that is presented to users
for controlling the client remotely, compression may be
important to reduce bandwidth and latency; but
decompression by the client is required
14
b. Client-Side Software for Distribution Transparency
in addition to the user interface, parts of the processing
and data level in a client-server application are executed at
the client side
an example is embedded client software for ATMs, cash
registers, etc.
moreover, client software can also include components to
achieve distribution transparency
e.g., replication transparency
assume a distributed system with replicated servers; the
client proxy can send requests to each replica and a
client side software can transparently collect all
responses and passes a single return value to the client
application
15
transparent replication of a server using a client-side solution
19
Client-to-server binding using a daemon
ii. use a superserver (as in UNIX) that listens to all endpoints
and then forks a process to take care of the request; this is
instead of having a lot of servers running simultaneously and
most of them idle
22
the general organization of a three-tiered server cluster
23
Distributed Servers
the problem with a server cluster is when the logical switch
(single access point) fails making the cluster unavailable
hence, several access points can be provided where the
addresses are publicly available leading to a distributed
server
e.g., the DNS can return several addresses for the same host
name
24
3.4 Code Migration
so far, communication was concerned on passing data
we may pass programs, even while running and in
heterogeneous systems
code migration also involves moving data as well: when a
program migrates while running, its status, pending signals,
and other environment variables such as the stack and the
program counter also have to be moved
25
Reasons for Migrating Code
to improve performance; move processes from heavily-
loaded to lightly-loaded machines (load balancing)
to reduce communication: move a client application that
performs many database operations to a server if the
database resides on the server; then send only results to the
client
to exploit parallelism (for nonparallel programs): e.g., copies
of a mobile program (called a mobile agent or a crawler as is
called in search engines) moving from site to site searching
the Web
26
to have flexibility by dynamically configuring distributed
systems: instead of having a multitiered client-server
application deciding in advance which parts of a program
are to be run where
28
Weak Mobility
transfer only the code segment and may be some
initialization data; in this case a program always starts
from its initial stage, e.g. Java Applets
execution can be by
the target process (in its own address space like in
Java Applets) but the target process and local
resources must be protected (security) or
by a separate process; still local resources must be
protected (security)
in addition to security, the other issue is portability in
heterogeneous systems
29
Strong Mobility (or process migration)
transfer code and execution segments; helps to migrate a
process in execution; stop execution, move it, and then
resume execution from where it is stopped
can also be supported by remote cloning; having an
exact copy of the original process and running on a
different machine; executed in parallel to the original
process; UNIX does this by forking a child process
migration can be
sender-initiated: the machine where the code resides or
is currently running; e.g., uploading programs to a
server; may need authentication or that the client is a
registered one; e.g., crawlers to index Web pages
receiver-initiated: by the target machine; e.g., Java
Applets; easier to implement
in a client-server model, receiver-initiated (by the server)
is easier to implement since security issues are
minimized; if clients are allowed to send code (sender-
initiated), the server must know them since they may
access resources such as disk on the server; 30
Summary of models of code migration
31
Migration and Local Resources
how to migrate the resource segment
not always possible to move a resource; e.g., a reference to
TCP port held by a process to communicate with other
processes; it should get a new port at the destination
Types of Process-to-Resource Bindings
Binding by identifier (the strongest): a resource is referred
by its identifier; the process requires that resource; e.g., a
URL to refer to a Web page or an FTP server referred by its
Internet (IP) address
Binding by value (weaker): when only the value of a
resource is needed; in this case another resource can
provide the same value; e.g., standard libraries of
programming languages such as C or Java which are
normally locally available, but their location in the file
system may vary from site to site
Binding by type (weakest): a process needs a resource of a
specific type; reference to local devices, such as monitors,
printers, ... 32
in migrating code, the above bindings cannot change, but the
references to resources can
how can a reference be changed? depends on whether the
resource can be moved along with the code, i.e., resource-to-
machine binding
Types of Resource-to-Machine Bindings
Unattached Resources: can be easily moved with the
migrating program (such as data files associated with the
program)
Fastened Resources: such as local databases and complete
Web sites; moving or copying may be possible, but very
costly
Fixed Resources: intimately bound to a specific machine or
environment such as local devices and cannot be moved
 we have nine combinations to consider
33
Resource-to machine binding
Unattached Fastened Fixed
By identifier MV (or GR) GR (or MV) GR
Process-to-
resource binding By value CP (or MV, GR) GR (or CP) GR
By type RB (or GR, CP) RB (or GR, CP) RB (or GR)
35
3.5 Software Agents and Agent Technology
a software agent is an autonomous unit (process) capable of
performing a task in collaboration (i.e., it communicates)
with other, possibly remote, agents
it is capable of reacting to, and initiating changes (proactive)
in its environment, possibly with users and other agents
a collaborative agent is an agent that forms part of a
multiagent system, in which agents seek to achieve some
common goal through collaboration; e.g., in arranging
meetings
a mobile agent is an agent having the capability to move
between different machines; e.g., to retrieve information
distributed across a large heterogeneous network such as
the Internet
an interface agent is an agent that assists an end user in the
use of one or more applications and has learning
capabilities (it is adaptive); e.g., those that bring buyers and
sellers together
36
an information agent is an agent that manages information
from different sources such as ordering and filtering; e.g. an
e-mail agent filtering unwanted mail from its owner’s
mailbox, or automatically distributing incoming mail into
appropriate subject-specific mailboxes
Common to
Property Description
all agents?
Autonomous Yes Can act on its own
Responds timely to changes in its
Reactive Yes
environment
Proactive Yes Initiates actions that affects its environment
Can exchange information with users and
Communicative Yes
other agents
Continuous No Has a relatively long lifespan
Mobile No Can migrate from one site to another
Adaptive No Capable of learning
39
Agent Communication Languages (ACL)
ACL: an application-level protocol where communication
between agents takes place
a message has a purpose and content
purpose
to request a specific service
to respond to a request
to inform about an event
to propose during negotiation
40
Message purpose Description Message Content
INFORM Inform that a given proposition is true Proposition
Query whether a given proposition is
QUERY-IF Proposition
true
QUERY-REF Query for a given object Expression
CFP Ask for a proposal Proposal specifics
PROPOSE Provide a proposal Proposal
ACCEPT-
Tell that a given proposal is accepted Proposal ID
PROPOSAL
REJECT-
Tell that a given proposal is rejected Proposal ID
PROPOSAL
Action
REQUEST Request that an action be performed
specification
Reference to
SUBSCRIBE Subscribe to an information source
source
examples of different message types in the FIPA ACL, giving the purpose
of a message, along with the description of the actual message content
41
ACL messages consist of a header and the actual content
the header has different fields:
a field to identify the purpose of the message,
fields to identify the sender and the receiver,
a field to identify the language or encoding scheme for
the content (since an ACL does not prescribe the format
or language in which the message content is expressed),
a field to identify a standardized mapping of symbols to
their meaning called ontology (if no common
understanding of interpreting data)
42
e.g., to inform an agent about Dutch royalty relationships
Field Value
Purpose INFORM
Sender max@http://fanclub-beatrix.royalty-spotters.nl:7239
Header
Receiver elke@iiop://royalty-watcher.uk:5623
Language Prolog
Ontology genealogy
Content female(beatrix), parent(beatrix, juliana, bernhard)
43