Processes
Download
1 / 57

Processes - PowerPoint PPT Presentation


  • 121 Views
  • Uploaded on

Processes. Chapter 3. Introduction. A process is a program in execution For OS important issues are Management of processes Scheduling of processes In dist systems, issues such as Multithreading Process/code migration Software agents. Topics Covered. Threads Clients Servers

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about ' Processes' - zenia


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
Processes

Processes

Chapter 3

Chapter 3  Processes 1


Introduction
Introduction

  • A process is a program in execution

  • For OS important issues are

    • Management of processes

    • Scheduling of processes

  • In dist systems, issues such as

    • Multithreading

    • Process/code migration

    • Software agents

Chapter 3  Processes 2


Topics covered
Topics Covered

  • Threads

  • Clients

  • Servers

  • Code Migration

  • Software Agents

Chapter 3  Processes 3


Threads
Threads

  • Processes (not threads): OSs makes sure

    • Processes do not affect each other, accidentally or intentionally (separation)

    • Processes not aware of each other (concurrency transparency)

  • Costly to set up independent processes

  • Switching between processes is costly

    • Must save state of current process

    • Must restore state of new process

    • Might also have to swap to disk

Chapter 3  Processes 4


Threads1
Threads

  • Thread is like a (sub)process

  • But, OS does not provide concurrency transparency between threads

  • For example, don’t protect data from access by other threads within a process

  • Plusses?

    • Efficiency

  • Minuses?

    • More work for application developer

Chapter 3  Processes 5


Threading example
Threading Example

  • Spreadsheet program

    • Change to one cell updates many cells

    • Interface is one thread, update another

    • Gives impression both are simultaneous

    • Even better in multiprocessor system

  • Other examples?

    • Word processor

  • Distributed examples?

Chapter 3  Processes 6


Interprocess communication
Interprocess Communication

  • If separate processes, 3 context switches

  • If same process, but separate threads, more efficient

Chapter 3  Processes 7


Thread implementation
Thread Implementation

  • Two possible approaches

    • User-level threads  all in user space

    • Kernel-level threads  kernel is involved

  • User-level threads

    • Plus: cheap to create/destroy threads

    • Plus: thread context switch is cheap

    • Minus: Blocking system call will block all threads in process (e.g., blocking on I/O)

  • Kernel-level threads remove the “minus”

    • But thread context switching is more costly

Chapter 3  Processes 8


Lightweight processes
Lightweight Processes

  • User-level threads and…

  • Lightweight processes (LWPs) that act like kernel-level threads

  • LWPs take care of threads as needed

  • Plusses?

    • Thread stuff is efficient (user-level)

    • Blocking system call will not suspend all threads (provided enough LWPs)

    • Apps need not be aware of LWPs

    • LWPs can execute on different processors

Chapter 3  Processes 9


Threads and lwps
Threads and LWPs

  • A bunch of LWPs hang around

  • LWPs grab threads as needed

Chapter 3  Processes 10


Threads in dist systems
Threads in Dist Systems

  • Advantage to threads in dist system

    • Can block without stalling entire process

  • Multithreaded clients

    • Conceal communication delays

    • For example, a Web browser

  • Multithreaded servers

    • More benefit on server side than client

    • Process incoming requests and do local things

    • Without threading, could implement this as a “big finite-state machine” (saving state, etc.)

Chapter 3  Processes 11


Multithreaded servers
Multithreaded Servers

  • Multithreaded server

    • dispatcher/worker model

Chapter 3  Processes 12


Multithreaded servers1
Multithreaded Servers

  • Three ways to construct a server

    • Single thread  process stalls

    • Finite state machine  hard to program

    • Threads  totally awesome, dude

  • Threads rule!

Chapter 3  Processes 13


Threads the bottom line
Threads: The Bottom Line

  • Consider RPC with blocking system call

    • Easy to program, but…

    • Inefficient without threads since…

    • No parallelism

  • W/O threads, finite state machine

    • Then obtain parallelism

    • But very painful to program

  • Threads provide

    • Sequential programming and parallel processes

Chapter 3  Processes 14


Clients
Clients

  • Client interacts with user and server

  • UI is sometimes simple

    • Cell phone

  • Sometimes UI is not-so-simple

    • X Window System

Chapter 3  Processes 15


X window system
X Window System

  • X Window System consists of

    • X kernel  low level interface for screen, mouse, etc.

    • Xlib  to access X kernel

    • Window manager  app that can manipulate screen

    • X protocol  allows for X kernel and X app to reside on different machines

    • X terminals  client using X protocol

Chapter 3  Processes 16


X window system1
X Window System

  • Organization of X Window System

Chapter 3  Processes 17


Client side transparency
Client-Side Transparency

  • Consider ATM and TV set-top box

    • For these, UI is small part of client side

    • Lots of processing on client side, lots of communication from client side

  • Client-side transparency is possible

  • Server side transparency harder to achieve (performance issues)

    • And not so important

Chapter 3  Processes 18


Client side transparency1
Client-Side Transparency

  • Access transparency

    • Client stub (middleware)

  • Location, migration, and relocation transparency

    • Naming

  • Replication transparency

    • One approach is on next slide

Chapter 3  Processes 19


Client side transparency2
Client-Side Transparency

  • Replication transparency

    • Client (stub) invokes object on all replicas

    • Collects responses and passes one result to client

Chapter 3  Processes 20


Client side transparency3
Client-Side Transparency

  • Failure transparency

    • Client middleware repeatedly attempt to connect to server

    • Client middleware tries another server

    • Client provides cached result

  • Concurrency/persistence transparency

    • ?????

Chapter 3  Processes 21


Servers
Servers

  • Server  a process implementing a service for a collection of clients

    • Server waits for incoming requests

    • Server services requests

  • Server can be iterative or concurrent

    • Iterative  handles request, response

    • Concurrent  passes request to another process/thread (fork a new process)

Chapter 3  Processes 22


Servers1
Servers

  • Requests arrive at an endpoint

    • Port

  • How does client know endpoint?

    • Well-known

    • Some service to look it up

  • Superserver serves servers

    • Listens for a bunch of “servers”

Chapter 3  Processes 23


Client to server binding
Client-to-Server Binding

  • Client-to-server binding using a daemon as in DCE

  • Client-to-server binding using a superserver as in UNIX

Chapter 3  Processes 24


Other server issues
Other Server Issues

  • How to interrupt server?

    • Break connection (common in Internet)

    • Out of band data

  • Stateless vs stateful

  • Stateless  no memory of clients and can change its state without telling clients

    • For example, a Web server (w/o cookies)

  • Stateful  remembers its clients

    • For example, file server must remember who has file at any given time

Chapter 3  Processes 25


Stateless vs stateful
Stateless vs Stateful

  • Stateless vs stateful server

  • What if server crashes…

  • Stateless?

    • No problem, just restart

  • Stateful?

    • Big problems…

  • Security of stateless vs stateful?

Chapter 3  Processes 26


Object server
Object Server

  • Server designed for dist objects

    • “a place where objects live”

    • Easy to change services on server

  • Read Section 3.3.2

Chapter 3  Processes 27


Code migration
Code Migration

  • Code migration  passing programs

    • Perhaps even while executing

  • Expensive, so why bother?

  • Consider process migration

    • Move a process to another machine

    • Move process from heavily loaded machine

    • A form of load balancing

  • When is it worthwhile?

    • Not easy to calculate in heterogeneous network

    • Minimizing communication may be good reason

Chapter 3  Processes 28


Code migration1
Code Migration

  • For example

    • Server manages a huge database

    • Spse client needs to access and process lots of data

    • May save bandwidth by shipping process to the server

  • Other examples (wrt performance)?

Chapter 3  Processes 29


Code migration2
Code Migration

  • Code migration might also increase flexibility

  • For example, it might be possible to dynamically configure the system

  • Dynamically download client software

    • No need to pre-install software

    • Other benefits?

    • What about security?

Chapter 3  Processes 30


Reason for migrating code
Reason for Migrating Code

  • Dynamically configuring client

    • Client fetches necessary software

    • Then client contacts server

Chapter 3  Processes 31


Models for code migration
Models for Code Migration

  • Process consists of 3 segments

    • Code segment  self explanatory

    • Resource segment  external resources

    • Execution segment  current state

  • Weak mobility migration of code segment and some initialization data

    • For example, Java applets

    • Simple, only requires code is portable

    • Execute in current process, or start new one

Chapter 3  Processes 32


Models for code migration1
Models for Code Migration

  • Strong mobility migrate exe segment

    • Running process stopped, moved to another machine, starts where left off

    • For example, D’Agents

    • Complex but powerful

  • Instead of moving the process, might clone the process

    • Then runs in parallel at client and server

  • Why?

    • Cloning improves transparency

Chapter 3  Processes 33


Models for code migration2
Models for Code Migration

  • Sender or receiver initiated?

  • Sender initiated

    • Initiated by machine where code resides

    • For example, uploading program to server

    • Other examples?

  • Receiver initiated

    • Initiated by target machine

    • For example, Java applets

    • Other examples?

Chapter 3  Processes 34


Models for code migration3
Models for Code Migration

  • Receiver initiated  client takes initiative

    • Code migrates to client

    • Done for performance reasons

  • Sender initiated  server takes initiative

    • Code migrates to server

    • Probably want access to server data

  • Receiver initiated is

    • Simpler (why?)

    • More secure (why?)

Chapter 3  Processes 35


Models for code migration4
Models for Code Migration

  • Alternatives for code migration

Chapter 3  Processes 36


Migration and local resources
Migration and Local Resources

  • What about resource segment?

  • Spse process is using a specific port for communication

    • This info is in resource segment

  • If process migrates, gets a new port

  • But an absolute URL will not change

    • Also in resource segment

Chapter 3  Processes 37


Migration and local resources1
Migration and Local Resources

  • 3 types of process-to-resource binding

  • Binding by identifier

    • Known locally and remotely

    • For example, URL or IP address

  • Binding by value

    • Available locally and remotely, but location might be different

    • C or Java library

  • Binding by type

    • Only available locally

    • Local devices (printers, monitors, etc.)

Chapter 3  Processes 38


Migration and local resources2
Migration and Local Resources

  • 3 types of resource-to-machine bindings

  • Unattached resources

    • Easy to move from one machine to another

    • Such as data files used by programs

  • Attached resources

    • Difficult to move from on machine to another

    • Such as database or entire website

  • Fixed resources

    • Cannot be moved

    • Such as local devices

Chapter 3  Processes 39


Migration and local resources3
Migration and Local Resources

Resource-to machine binding

  • GR establish global systemwide reference

  • MV move the resource

  • CP copy the file to the resource

  • RB rebind process to locally available resource

Unattached

Attached

Fixed

Process-to-resource binding

By identifier

By value

By type

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)

Chapter 3  Processes 40


Migration in heterogeneous systems
Migration in Heterogeneous Systems

  • Code executes on different platforms

  • Each platform must be supported

  • Easier if limited to weak mobility

    • Different code segments

  • In strong mobility, difficult…

  • Restrict migration to certain points in code

    • Such as a function call

  • Maintain machine independent stack

    • Migration stack

Chapter 3  Processes 41


Migration in heterogeneous systems1
Migration in Heterogeneous Systems

  • Maintaining a migration stack to support migration of an execution segment

  • Can be done in C/C++

Chapter 3  Processes 42


Migration in heterogeneous systems2
Migration in Heterogeneous Systems

  • Migration in heterogeneous systems

    • Basic problem is similar to portability

  • What is the solution for portability?

    • Virtual machine is one solution

  • So similar solution should work here

Chapter 3  Processes 43


Code migration in d agents
Code Migration in D'Agents

  • Middleware approach

  • Supports various forms of code migration

  • Read it!

Chapter 3  Processes 44


Software agents
Software Agents

  • So far

    • Threads

    • Clients

    • Servers

    • Mobility

  • And now for something completely different…

  • Software agents

Chapter 3  Processes 45


Software agents1
Software Agents

  • Software agents  no precise definition

    • “Autonomous agents capable of performing a task in collaboration with other, possibly remote, agents”

    • “An autonomous process capable of reacting to, and initiating change in, its environment, possibly in collaboration with users and other agents”

  • Able to act on its own (autonomous)

  • Able to cooperate with other agents

  • Able to take the initiative

Chapter 3  Processes 46


Software agents2
Software Agents

  • Collaborative agents

    • Agents that work together as part of multiagent system

    • Example: agents that arrange a meeting

  • Mobile agents

    • Able to move between machines

    • May require strong mobility

    • Example: to “police” the Internet

Chapter 3  Processes 47


Software agents3
Software Agents

  • Interface agents

    • Assist users with one or more applications

    • Actively learns from its interactions

    • Example: agent that brings buyers and sellers together

  • Information agents

    • Manage info from many different sources

    • In distributed system, info is from physically distributed systems

    • Example: email agent to filter spam, others?

Chapter 3  Processes 48


Software agents4
Software Agents

  • Properties of software 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

Chapter 3  Processes 49


Intelligent agents
Intelligent Agents

  • Foundation for Intelligent Physical Agents

    • FIPA

  • Developing general model for agents

  • Agents registered at agent platform

  • Platform provides basic services

    • Create and delete agents

    • Locate agents (directory service)

    • Inter-agent communication facilities

Chapter 3  Processes 50


Fipa platform
FIPA Platform

  • FIPA model for an agent platform

  • Agent Communication Channel (ACC)

    • Sending messages between platforms

    • Uses Internet Inter-ORB Protocol (IIOP)  Chapter 9

Chapter 3  Processes 51


ACL

  • FIPA defines Agent Communication Language

    • Defines a “high level communication protocol between a collection of agents”

    • How does this differ from IIOP?

  • Separation between msg purpose and content

    • Header states the msg purpose

    • Format and language of content is left open

    • Need enough info in header to interpret content

    • Ontology: mapping of symbols to meanings

Chapter 3  Processes 52


ACL

  • Different “purposes” in FIPA ACL

Chapter 3  Processes 53


Acl example
ACL Example

  • Sender INFORMs receiver of Dutch royal genealogy

  • Ontology says that Prolog statements to be semantically interpreted as genealogy info

Chapter 3  Processes 54


Summary
Summary

  • Threads

    • Sequential programming

    • Parallel processing

  • Clients

    • User interface

    • Distribution transparency

Chapter 3  Processes 55


Summary1
Summary

  • Servers

    • Efficiency more important than transparency

    • Interactive or concurrent?

    • Stateful or stateless?

    • Object servers

  • Code migration

    • Performance and flexibility

    • Strong mobility vs weak mobility

    • Local resources?

    • Heterogeneity/virtual machines

Chapter 3  Processes 56


Summary2
Summary

  • Software agents

    • Autonomous and cooperative

    • Agent communication language (ACL)

    • Purpose vs content

Chapter 3  Processes 57


ad