Processes Chapter 3. Thread Usage in Nondistributed Systems Context switching as the result of IPC –Process: a running program (mgmt. unit of OS) –Thread:

Slides:



Advertisements
Similar presentations
CS-495 Distributed Systems Fabián E. Bustamante, Winter 2004 Processes Threads & OS Threads in distributed systems Object servers Code migration Software.
Advertisements

Processes: Code Migration Chapter 3 Will Cameron CSC 8530 Dr. Schragger.
1 Chapter 5 Threads 2 Contents  Overview  Benefits  User and Kernel Threads  Multithreading Models  Solaris 2 Threads  Java Threads.
Threads, SMP, and Microkernels Chapter 4. Process Resource ownership - process is allocated a virtual address space to hold the process image Scheduling/execution-
Chapter 4 Threads, SMP, and Microkernels Patricia Roy Manatee Community College, Venice, FL ©2008, Prentice Hall Operating Systems: Internals and Design.
Chapter 5 Threads os5.
Describe the concept of lightweight process (LWP) and the advantages to using LWPs Lightweight process (LWP) lies in a hybrid form of user-level & kernel-level.
1 DISTRIBUTED SYSTEMS Principles and Paradigms Second Edition ANDREW S. TANENBAUM MAARTEN VAN STEEN Chapter 3 Processes Skip
Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved DISTRIBUTED SYSTEMS.
Threads Clients Servers Code Migration Software Agents Summary
EECS122 - UCB 1 CS 194: Distributed Systems Processes, Threads, Code Migration Computer Science Division Department of Electrical Engineering and Computer.
Computer Science Lecture 8, page 1 CS677: Distributed OS Code and Process Migration Motivation How does migration occur? Resource migration Agent-based.
Processes After today’s lecture, you are asked to know The basic concept of thread and process. What are the advantages of using multi-threaded client.
Processes After today’s lecture, you are asked to know
EEC-681/781 Distributed Computing Systems Lecture 8 Wenbing Zhao Cleveland State University.
CS 603 Threads, Processes, and Agents March 18, 2002.
Processes. Communication takes place between processes. But, what’s a process? “A program in execution” Traditional operating systems: concerned with.
Processes After today’s lecture, you are asked to know The basic concept of thread and process. What are the advantages of using multi-threaded client.
Processes After today’s lecture, you are asked to know The basic concept of thread and process. What are the advantages of using multi-threaded client.
16: Distributed Systems1 DISTRIBUTED SYSTEM STRUCTURES NETWORK OPERATING SYSTEMS The users are aware of the physical structure of the network. Each site.
Processes Chapter 3.
Chapter 3  Processes 1 Processes Chapter 3 Chapter 3  Processes 2 Introduction  A process is a program in execution  For OS important issues are.
1 Processes and Distributed Computing Issues: moving processes around design of server and client processes migration of processes/programs agent programs.
Give an example to show the advantages to using multithreaded Clients See page 142 of the core book (Tanebaum 2002).
Processes.
Chapter 51 Threads Chapter 5. 2 Process Characteristics  Concept of Process has two facets.  A Process is: A Unit of resource ownership:  a virtual.
Processes Part I Processes & Threads* *Referred to slides by Dr. Sanjeev Setia at George Mason University Chapter 3.
Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved DISTRIBUTED.
Processes, Threads and Virtualization
Chapter 6 Operating System Support. This chapter describes how middleware is supported by the operating system facilities at the nodes of a distributed.
1 Processes Chapter 3. 2 Processes  Communication takes place between processes. But, what ’ s a process?  “ A program in execution ”  Traditional.
Kyung Hee University 1/57 Communication Chapter 3.
Threads, Thread management & Resource Management.
1 Distributed Systems Processes Chapter 3. 2 Course/Slides Credits Note: all course presentations are based on those developed by Andrew S. Tanenbaum.
Computer Science Lecture 8, page 1 CS677: Distributed OS Last Class Threads –User-level, kernel-level, LWPs Multiprocessor Scheduling –Cache affinity –Preemption.
Processes Chapter 3. Table of Contents Multithreading Clients and Servers Code Migration Software Agents (special topic)
Processes Chapter 3. Thread Usage in Nondistributed Systems Context switching as the result of IPC.
Univ. of TehranDistributed Operating Systems1 Advanced Operating Systems University of Tehran Dept. of EE and Computer Engineering By: Dr. Nasser Yazdani.
Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved DISTRIBUTED SYSTEMS.
CE Operating Systems Lecture 3 Overview of OS functions and structure.
DISTRIBUTED SYSTEMS Principles and Paradigms Second Edition ANDREW S
Processes Chapter 3. Processes  OS provides concurrency transparency of multiple processes (sharing CPU, memory)  High price  Process creation  Context.
OPERATING SYSTEM SUPPORT DISTRIBUTED SYSTEMS CHAPTER 6 Lawrence Heyman July 8, 2002.
Processes. Processes and threads Process forms a building block in distributed systems Processes granularity is not sufficient for distributed systems.
Code Migration Russell T. Potee, III. Overview Why Code Migration? Code Migration Models Migration and Handling Resources Heterogeneous Systems Migration.
Distributed Systems Principles and Paradigms Chapter 03 Processes 00 – 1.
Computer Science Lecture 7, page 1 CS677: Distributed OS Multiprocessor Scheduling Will consider only shared memory multiprocessor Salient features: –One.
Hwajung Lee.  Interprocess Communication (IPC) is at the heart of distributed computing.  Processes and Threads  Process is the execution of a program.
Processes Chapter 3. Processes Process: Program in execution. In DSs, more concepts come into consideration, eg. Multi-treading, process migration, code.
1 Threads, SMP, and Microkernels Chapter Multithreading Operating system supports multiple threads of execution within a single process MS-DOS.
Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved DISTRIBUTED SYSTEMS.
1 Reasons for Migrating Code The principle of dynamically configuring a client to communicate to a server. The client first fetches the necessary software,
Processes Chapter 3. Processes Topics discussed in this chapter: –Threads improve performance. In distributed systems threads allow clients can servers.
GLOBAL EDGE SOFTWERE LTD1 R EMOTE F ILE S HARING - Ardhanareesh Aradhyamath.
1 Chapter 3 Processes Dowon Cho (RTMM Lab) & Jongwon Lee (SE Lab)
Threads-Process Interaction. CONTENTS  Threads  Process interaction.
Operating Systems Unit 2: – Process Context switch Interrupt Interprocess communication – Thread Thread models Operating Systems.
Processes, Threads and Virtualization Chapter The role of processes in distributed systems.
Threads, SMP, and Microkernels Chapter 4. Processes and Threads Operating systems use processes for two purposes - Resource allocation and resource ownership.
1 Chapter 2: Operating-System Structures Services Interface provided to users & programmers –System calls (programmer access) –User level access to system.
Processes Chapter 3. Processes in Distributed Systems Processes and threads –Introduction to threads –Distinction between threads and processes Threads.
Processes Chapter 3. Processes  Process is a program in running state  PROCESSES ARE THE BUILDING BLOCKS OF DISTRIBUTED SYSTEMS, ESPECIALLY IN unix.
Processes and Threads Chapter 3 and 4 Operating Systems: Internals and Design Principles, 6/E William Stallings Patricia Roy Manatee Community College,
DISTRIBUTED SYSTEMS Principles and Paradigms Second Edition ANDREW S
Processes Chapter 3.
WWW and HTTP King Fahd University of Petroleum & Minerals
Distributed Systems - Comp 655
Processes Chapter 3.
Processes Chapter 3.
Processes Chapter 3.
Presentation transcript:

Processes Chapter 3

Thread Usage in Nondistributed Systems Context switching as the result of IPC –Process: a running program (mgmt. unit of OS) –Thread: execution unit within a process –Switching: Processes: expensive (CPU context, MMU, TLB, …) Threads: cheap (almost only CPU context)

Thread Design Issues –User-level threads: +: create, destroy, switching very cheap, because without OS. -: blocking system calls (e.g. communication) would block all threads.  parallelism is restricted –Kernel-level threads: +: kernel can do context switching when blocking system calls are used.  more parallelism -: create, destroy, switching are expensive (switches to kernel mode necessary). –Hybrid solution: Seems to be the best one. Use of user-level threads (thread package). Use of kernel-level threads so-called light-weight processes (LWPs).

Thread Implementation Combining kernel-level lightweight processes and user-level threads.

Multithreaded Clients (1) –Example: WWW Browser Thread 1: get text Thread 2: get image Thread 3: get banner …  Better responsiveness, but user may notice parallelism. –Multiple connections to server: If server is replicated (i.e. horizontal distribution), different connections correspond to different server instances.  more parallelism

Multithreaded Servers (1) A multithreaded server organized in a dispatcher/worker model.

Multithreaded Servers (2) Three ways to construct a server. Finite-state machine (rather intricate): –Only one thread (that simulates multiple ones) –Loop: Get next message. Do some computation if needed. Send asynchronous message(s) to device(s) (e.g. disk) – no blocking on I/O. Go to first step (and receive next message, which may be from disk or from client). ModelCharacteristics Threads (multi-threaded process)Parallelism, blocking system calls Single-threaded processNo parallelism, blocking system calls Finite-state machineParallelism, nonblocking system calls

Clients: User Interface The X-Window System The basic organization of the X Window System

Client-Side Software for Distribution Transparency –Access transparency: IDL-based stubs –Relocation/migration transparency: rebind within middleware (stub/proxy) –Replication transparency: see below –Failure transparency: time redundancy, use of caches as in browsers, … –Concurrency/persistence transparency: rather at server or intermediate server (transaction monitors manage concurrent transactions)

Servers: General Design Issues (1) a)Client-to-server binding using a daemon as in DCE b)Client-to-server binding using a superserver as in UNIX (Inetd server) 3.7 listens to all relevant ports name to port mapping

Servers: General Design Issues (2) –Handling interrupts: –Out-of-band data: highest priority (supported in TCP) – Server is interrupted (e.g. Unix signal) –Stateful/stateless server: –Stateful: Server holds information about clients. For example, which client has currently opened a file for writing.  Recovery is needed after crash  May enhance performance –Stateless: no information about clients is held  No recovery after crashes  Less performance –Sometimes servers keep information about client behavior  Cookies (web server information on user’s favorite pages kept at client side)  Problem: privacy

Object Servers: Object Invocation –Object server: –Server that invokes local objects on behalf of client requests –It does not implement a service, objects implement services –Only a room where objects live –Issues: –Transient objects:  In-memory ones that live as long as server lives (or shorter)  Create object at first invocation and delete it when no clients are bound to it : +: minimizes resources, -: some invocations may be slow  Create all transient objects at once –Code/data sharing:  All objects are separated (e.g. different segments) +: promotes security  But code sharing may be very useful for persistent objects (e.g. code of class in memory and data of different objects on disk) –Threading:  On demand / pool  Per invocation (sync needed) / per object (no sync needed)

Object Adapter (1) Object adapter (also called object wrapper): Software (part of middleware) that implements a specific activation policy. Activation policy: e.g. per object / per invocation thread. Main idea: objects should be kept simple and should no know how they are invoked (+: reliability). Object adapters are generic (independent from object) They communicate rather with the skeleton/stub of the object and not with the object itself. Objects are rather passive until invocated by adapter. Multiple object adapters on same machine with different activation policies possible and desirable for reasons of flexibility.

Object Adapter (2) Organization of an object server supporting different activation policies. Object 1.1 Object 2.1 Object 2.2 Policy 1 Policy 2

Object Adapter (3) The header.h file used by the adapter and any program that calls an adapter. /* Definitions needed by caller of adapter and adapter */ #define TRUE #define MAX_DATA /* Definition of general message format: adapter/client*/ struct message { long source/* senders identity */ long object_id;/* identifier for the requested object */ long method_id;/* identifier for the requested method */ unsigned size;/* total bytes in list of parameters */ char **data;/* parameters as sequence of bytes */ }; /* General definition of operation to be called at skeleton of object */ typedef void (*METHOD_CALL)(unsigned, char* unsigned*, char**); long register_object (METHOD_CALL call);/* register an object: from stub */ void unrigester_object (long object)id);/* unrigester an object: from stub */ void invoke_adapter (message *request);/* call the adapter: from deMUX*/

Object Adapter (4) The thread.h file used by the adapter for using threads. typedef struct thread THREAD;/* hidden definition of a thread */ thread *CREATE_THREAD (void (*body)(long tid), long thread_id); /* Create a thread by giving a pointer to a function that defines the actual */ /* behavior of the thread, along with a thread identifier */ void get_msg (unsigned *size, char **data); void put_msg(THREAD *receiver, unsigned size, char **data); /* Calling get_msg blocks the thread until of a message has been put into its */ /* associated buffer. Putting a message in a thread's buffer is a nonblocking */ /* operation. */

Object Adapter (5) The main part of an adapter that Implements a thread-per-object policy. Demultiplexer thread Adapter thread

Code Migration Migration: shift entity (process, application, …) from A to B. Why?: - gain more performance: utilize lightly-loaded nodes or exploit parallelism (e.g. search in the Web). - enhance reliability/availability: separate faulty and well-behaved applications (rather new). - be more flexible (see next slide) Load: cumulative CPU requirements of ready-to-run processes, length of ready- to-run queue, utilization, … Goals (related to performance): a) minimize computation time, b) minimize advent of communication (important in distributed systems) Examples: - client code is better executed at server, if too many data are needed to obtain some result. - server code is better executed at client, if too many user interactions are needed prior to actual processing.

Dynamic Client Configuration (enhances flexibility) The principle of dynamically configuring a client to communicate to a server. The client first fetches the necessary software, and then invokes the server.  Issue: security e.g. protocol implementation (language that server speaks)

Models for Code Migration (1) Mobility: refers to the fact that an entity can be migrated. Weak mobility: only code part of entity (with some initialization data) is migrated. Entity can only begin computation at target node.  Java applets a) code executed in same process (less secure but efficient, e.g. applets are executed in browsers) b) code executed in different process (more secure, but resources like files are not protected, and less efficient) Strong mobility: both code and whole state of entity (data, CPU registers, etc.) are migrated.  the entity (e.g. process) can continue computation on target node from where it has been stopped.  example: D’Agent  remote cloning: copy of entity on target machine, but original remains at sender machine (e.g. Unix fork and continue on different machine). Sender-initiated: initiative of migration is taken at sender side (e.g. upload code to a server) Receiver-initiated: initiative of migration is taken at receiver side (e.g. Java applets).

Models for Code Migration (2) Alternatives for code migration.

Migration and Local Resources (1) What to do with resources after a process has been migrated? Resources: monitors, files, ports, libraries, …  Resource bindings may change after migration (unlike code and state) Process-to-resource bindings: Binding by identifier: Process needs exactly the resource used before migration.  new resource is equal old resource, e.g. local port Binding by value: Process needs the value of the resource used before migration.  new resource is equivalent to old resource, e.g. programming library Binding by type: Process needs a resource of a specific type.  new and old resources have same type, e.g. monitors, printer, … Resource-to-machine bindings: Unattached resources: Not bound to a specific machine, e.g. unshared file Fastened resources: In principle independent of any machines, but de facto (e.g. enormous moving overhead) bound to a machine, e.g. Web database Fixed resources: bound to a specific machine, e.g. devices

Migration and Local Resources (2) MV: move resource GR: use global reference CP: copy resource RB: rebind to (local) resource Actions to be taken with respect to the references to local resources when migrating code to another machine.  Establishing global references may always solve the problem of resource bindings after migration, however it may introduce more overhead (e.g. communication, reconfiguring owners of global reference). UnattachedFastenedFixed 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 RB (or GR) Resource-to machine binding Process-to- resource binding

Migration in Heterogeneous Systems The principle of maintaining a migration stack to support migration of an execution segment in a heterogeneous environment State-of-the-art: Use of a virtual machine (e.g. Java)  relies on only one language 3-15

Overview of Code Migration in D'Agents (1) A simple example of a Tcl agent in D'Agents submitting a script to a remote machine agent_submit: sender-initiated weak migration (with separate process at receiver side) proc factorial n { if ($n  1) { return 1; }# fac(1) = 1 expr $n * [ factorial [expr $n – 1] ] # fac(n) = n * fac(n – 1) } set number … # tells which factorial to compute set machine … # identify the target machine agent_submit $machine –procs factorial –vars number –script {factorial $number } agent_receive …# receive the results (left unspecified for simplicity) Main Program

Overview of Code Migration in D'Agents (2) An example of a Tel agent in D'Agents migrating to different machines where it executes the UNIX who command agent_jump: sender-initiated strong migration agent_fork: sender-initiated remote cloning proc all_users machines { set list ""# Create an initially empty list foreach m $machines {# Consider all hosts in the set of given machines agent_jump $m# Jump to each host set users [exec who]# Execute the who command append list $users# Append the results to the list } return $list# Return the complete list when done } set machines …# Initialize the set of machines to jump to set this_machine# Set to the host that starts the agent # Create a migrating agent by submitting the script to this machine, from where # it will jump to all the others in $machines. agent_submit $this_machine –procs all_users -vars machines -script { all_users $machines } agent_receive …#receive the results (left unspecified for simplicity) Main Program

Implementation Issues (1) The architecture of the D'Agents system. Agent mgmt (e.g. Ids), authentication, communication Agent start/end, migration, agent-level communication

Implementation Issues (2) The parts comprising the state of an agent in D'Agents. StatusDescription Global interpreter variablesVariables needed by the interpreter of an agent Global system variablesReturn codes, error codes, error strings, etc. Global program variablesUser-defined global variables in a program Procedure definitionsDefinitions of scripts to be executed by an agent Stack of commandsStack of commands currently being executed Stack of call frames Stack of activation records, one for each running command

Software Agents in Distributed Systems Important properties by which different types of agents can be distinguished. Other functional properties: Interface agents: personal agents that assist users in the use of applications (usually learning/intelligent agents) Information agents: process information from different sources (usually mobile agents that roam the network) Property Common to all agents? Description AutonomousYesCan act on its own ReactiveYesResponds timely to changes in its environment ProactiveYesInitiates actions that affects its environment CommunicativeYes Can exchange information with users and other agents ContinuousNoHas a relatively long lifespan MobileNoCan migrate from one site to another AdaptiveNoCapable of learning

Agent Technology The general model of an agent platform (FIPA model). FIPA: Foundation for Intelligent Physical Agents Agent communication channel Create/delete agent, end points mapping, … What do other agents offer?

Some Agent Applications Searching (e.g. in the Web):  Enhances parallelism.  Mobility is asset. E-Commerce:  Walk in the network to find best offers.  Pay at seller side.  Issue: security. Network management:  Performance, fault, configuration mgmt, and other functions.  Cooperation is asset: networks may span over different organizational domains.  Examples: a) Construct new complex services in cooperation with other agents (on-the-fly!). b) Solve performance reductions or fault situations by cooperating with agents in other domains. Computer-assisted learning:  Intelligence is asset: agent should be able to adapt to student’s knowledge.  Relevant in distributed systems, if (distributed) agents cooperate in doing their work.

Agent Communication Languages (1) Examples of different message types in the FIPA ACL giving the purpose of a message, along with the description of the actual message content. Message purposeDescriptionMessage Content INFORMInform that a given proposition is trueProposition QUERY-IFQuery whether a given proposition is trueProposition QUERY-REFQuery for a given objectExpression CFPAsk for a proposalProposal specifics PROPOSEProvide a proposalProposal ACCEPT-PROPOSALTell that a given proposal is acceptedProposal ID REJECT-PROPOSALTell that a given proposal is rejectedProposal ID REQUESTRequest that an action be performedAction specification SUBSCRIBESubscribe to an information source Reference to source

Agent Communication Languages (2) A simple example of a FIPA ACL message sent between two agents using Prolog to express genealogy information. FieldValue PurposeINFORM Language (syntax)Prolog Ontology (semantics)genealogy Contentfemale(beatrix), parent(beatrix, juliana, bernhard)