Processes

Processes
Threads & OS
Threads in distributed systems
Object servers
Code migration
Software agents
CS-495 Distributed Systems
Fabián E. Bustamante, Winter 2004
Threads
Idea – we build virtual processors in software
– Processor, processes and threads
Context switch
– Process and thread context
– Observations
• Threads shared the same address space
• Process switching involves getting the OS in the loop - >$
• Creating and destroying threads is cheaper than doing so with
processes
Threads and the OS
– User or kernel threads?
– Two level threading and scheduler activations
CS-495 Distributed Systems
Threads in Distributed Systems
Multithreaded clients – to hide network latency
– Web client
– RPCs
Multithreaded servers – improve performance &
structure
–
–
–
–
–
Starting a thread is cheaper than starting a process
A single-threaded server is a problem for scalability
Move on to next request instead of waiting
Using blocking calls simplifies overall structure
Simplified flow control (?)
CS-495 Distributed Systems
Alternatives to Threaded Servers
Alternatives
Model
Characteristics
Threads
Parallelism, blocking system calls
Single-threaded process
No parallelism, blocking system calls
Finite-state machine
Parallelism, nonblocking system calls
Problems with threads?
–
–
–
–
Hard to program: synchronization & deadlocks
Hard to debug: data and timing dependencies
Hard to get good performance
Should you abandon threads? No – but avoid them if you can
CS-495 Distributed Systems
Servers – Design Issues
General organization
– Basic model & superservers (inetd)
Out-of-band communication
– Use a separate port
– Use a special message
State
– Stateless – no memory/no problem
– Stateful – faster + reliability headache
Object servers
– Objects – data/state + method
– Transient and persistent objects, thread per object or per
invocation …
– Activation policies and object adapters
CS-495 Distributed Systems
Code Migration
Why?
– Performance
– Flexibility
Models
– Process segments:
• Code: set of instructions
• Resource: external resources needed (files, printers, …)
• Execution: current execution state
– ...
CS-495 Distributed Systems
Models for Code Migration
CS-495 Distributed Systems
Migration and Local Resources
Problem: what if resources are not available at target?
Type of resources:
– Fixed: it cannot be migrated
– Fastened: it can but it will cost you a lot
– Unattached: easy to move
Resource-to machine binding
Process-toresource
binding
By identifier
By value
By type
Unattached
Fastened
Fixed
MV (or GR)
CP ( or MV, GR)
RB (or GR, CP)
GR (or MV)
GR (or CP)
RB (or GR, CP)
GR
GR
RB (or GR)
MV: just move it
GR: Establish global systemwide refer
CP: Copy the value of the resource
RB: Re-bind to a locally available resource
CS-495 Distributed Systems
Migration in Heterogeneous Systems
Main problem:
– Target machine may not be suitable to run it
– The def. of process/thread/processor context is
highly dependent on HW/OS/Runtime system
One solution: use abstract machine
Current solutions:
– Interpreted languages running on virtual machine
– State the migration points
CS-495 Distributed Systems
What’s an Agent?
Def.: Autonomous process that can react/initiate changes in its
environment, possible in collaboration
–
–
–
–
Collaborative agents
Mobile agents
Interface agents
Information agents
Property
Common to all
agents?
Description
Autonomous
Yes
Can act on its own
Reactive
Yes
Responds timely to changes in its environment
Proactive
Yes
Initiates actions that affects its environment
Communicative
Yes
Can exchange information with users and other agents
Continuous
No
Has a relatively long lifespan
Mobile
No
Can migrate from one site to another
Adaptive
No
Capable of learning
CS-495 Distributed Systems
Agent Technology
Management: Keeps track of where the agents on this platform
are
Directory: Mapping of agents names and attributes to agent IDs
ACC: Agent Communication Channel – used to communicate
with other platforms
CS-495 Distributed Systems
Agent Communication Languages
ACL is application-level protocol making distinction bet/ purpose
and content of msg.
Message purpose
Description
INFORM
Inform that a given proposition is true
QUERY-IF
Query whether a given proposition is
true
QUERY-REF
Query for a give object
CFP
Ask for a proposal
PROPOSE
Provide a proposal
ACCEPT-PROPOSAL
Tell that a given proposal is accepted
Field
Value
REJECT-PROPOSAL
Tell that a given proposal is rejected
Purpose
INFORM
REQUEST
Request that an action be performed
Sender
weather@http://www.weather.com:7239
SUBSCRIBE
Subscribe to an information source
Receiver
mafalda@http://www.cs.nwu.edu:5623
Language
Prolog
Ontology
weather
Content
weather(today,60201,sunny)
CS-495 Distributed Systems