Processes Chapter 3. Processes  OS provides concurrency transparency of multiple processes (sharing CPU, memory)  High price  Process creation  Context.

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.
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.
3.5 Interprocess Communication Many operating systems provide mechanisms for interprocess communication (IPC) –Processes must communicate with one another.
Computer Science Lecture 8, page 1 CS677: Distributed OS Code and Process Migration Motivation How does migration occur? Resource migration Agent-based.
Processes Chapter 3. Thread Usage in Nondistributed Systems Context switching as the result of IPC –Process: a running program (mgmt. unit of OS) –Thread:
3.5 Interprocess Communication
Threads CSCI 444/544 Operating Systems Fall 2008.
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.
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.
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.
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
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.
Chapter 4 Threads, SMP, and Microkernels Patricia Roy Manatee Community College, Venice, FL ©2008, Prentice Hall Operating Systems: Internals and Design.
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.
Processes and Threads Processes have two characteristics: – Resource ownership - process includes a virtual address space to hold the process image – Scheduling/execution.
Univ. of TehranDistributed Operating Systems1 Advanced Operating Systems University of Tehran Dept. of EE and Computer Engineering By: Dr. Nasser Yazdani.
Lecture 3 Process Concepts. What is a Process? A process is the dynamic execution context of an executing program. Several processes may run concurrently,
Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved DISTRIBUTED SYSTEMS.
DISTRIBUTED SYSTEMS Principles and Paradigms Second Edition ANDREW S
3.1 Silberschatz, Galvin and Gagne ©2009Operating System Concepts with Java – 8 th Edition Chapter 3: Processes.
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.
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.
Chapter 4: Threads. 4.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th edition, Jan 23, 2005 Chapter 4: Threads Overview Multithreading.
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.
Multithreaded Programing. Outline Overview of threads Threads Multithreaded Models  Many-to-One  One-to-One  Many-to-Many Thread Libraries  Pthread.
Department of Computer Science and Software Engineering
1 Chapter 3 Processes Dowon Cho (RTMM Lab) & Jongwon Lee (SE Lab)
Acknowledgement: These slides are adapted from slides provided in Thißen & Spaniol's course Distributed Systems and Middleware, RWTH Aachen Processes Distributed.
Cooperating Processes The concurrent processes executing in the operating system may be either independent processes or cooperating processes. A process.
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.
ITEC 502 컴퓨터 시스템 및 실습 Chapter 2-2: Threads Mi-Jung Choi DPNM Lab. Dept. of CSE, POSTECH.
1 Chapter 5: Threads Overview Multithreading Models & Issues Read Chapter 5 pages
Processes Chapter 3. Processes  Process is a program in running state  PROCESSES ARE THE BUILDING BLOCKS OF DISTRIBUTED SYSTEMS, ESPECIALLY IN unix.
DISTRIBUTED SYSTEMS Principles and Paradigms Second Edition ANDREW S
Processes Chapter 3.
Chapter 2 Processes and Threads Today 2.1 Processes 2.2 Threads
Distributed Systems - Comp 655
Processes Chapter 3.
Prof. Leonardo Mostarda University of Camerino
Processes Chapter 3.
Processes Chapter 3.
Presentation transcript:

Processes Chapter 3

Processes  OS provides concurrency transparency of multiple processes (sharing CPU, memory)  High price  Process creation  Context switch  Difference between Processes and Threads?  Thread context includes only CPU context  Using thread, no concurrency transparency anymore!  Multithreading improves performance

Thread Usage in Nondistributed Systems Context switching as the result of IPC

User-level thread or kernel thread  User-level threads  Cheap to create/destroy  Thread context switch is efficient, e.g., the values of CPU registers  Drawback: block the process to which the thread belongs when calling a (synchronous) system call  Kernel-level threads  Do not have such a drawback  Drawback: expensive in thread operations (create, destroy, synchronization). Context switching is as expensive as process context switching  Solution?  Lightweight processes (LWP): hybrid of user-level and kernel- level threads

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

Threads in Distributed Systems  Property of threads: allowing blocking system calls without blocking the entire process in which the thread is running.  Multithreaded Clients  Hide communication latencies  Example: Web browser ?  Multithreaded Servers  Simplify server code  Exploit parallelism, high performance

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

Multithreaded Servers (2) Three ways to construct a server. ModelCharacteristics ThreadsParallelism, blocking system calls Single-threaded processNo parallelism, blocking system calls Finite-state machineParallelism, nonblocking system calls

Clients

The X-Window System The basic organization of the X Window System

Client-Side Software for Distribution Transparency A possible approach to transparent replication of a remote object using a client-side solution.

Servers: General Design Issues  Iterative servers or concurrent servers (fork, threading)

Servers: General Design Issues a)Client-to-server binding using a daemon as in DCE b)Client-to-server binding using a superserver as in UNIX 3.7

Servers: General Design Issues  Stateless servers or stateful servers?  Stateless servers  Do not keep info on the state of the clients  Do not inform the clients when changing its state  Example: Web server  Stateful servers  In contrast with stateless servers  May better performance  But if crash, need to recover the client states, complexity  Unscalable  Cookie: a solution

Object Servers  Definition: a server to support distributed objects  The server itself does not provide a specific service  It provides only the means to invoke local objects that implement the services  Objects  Data represents its state  Coding forms the implementation of its methods/services  How to invoke objects  Only one way to invoke objects: that provide same interface  Different policies to invoke different objects: created on-demand or precreated objects  Each object has a thread v.s. each invocation request corresponds to a thread? (threading, concurrent access control)

Object Adapter  Definition: A mechanism to group objects by policies, or a software implementing a specific activation policy  Generic components, for each policy  Unaware of the specific interfaces of the objects it wraps  Actions  Extracts an object reference from an invocation request  Dispatches the request to the referenced objects (via the server-side stub of the object)  Sends back the response message

Object Adapter (1) Organization of an object server supporting different activation policies.

Object Adapter (2) 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 1 #define MAX_DATA /* Definition of general message format */ 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 */ void unrigester_object (long object)id);/* unrigester an object */ void invoke_adapter (message *request);/* call the adapter */

Object Adapter (3) The thread.h file used by the adapter for using threads. Thread communications by buffers/message queues 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 Implementation  Implements a thread-per-object policy  Buffers/Message queues as communication between threads

Object Adapter (4) The main part of an adapter that implements a thread-per-object policy.

Thinking and reflections  The concept of object adapters and buffers/MSG queues as thread communications can be extended to support concurrent server design  Front server: receive requests, put the requests into corresponding thread’s MSG queues/buffers  Thread read requests, perform the functions and put the response message into the front server’s queue  Front server/Reply server writes back the message to the clients

Code Migration  Previous applications: move data  Now: move code/program  Reasons for migrating code  Move computation load, improve performance  Reduce bandwidth cost by data transferring  Flexibility: dynamically configure distributed system  Examples:  Ship client application to the database server to reduce the amount of data needed to be transferred  Client-side downloads codes from server, such as filling out a form at client-side

Reasons for Migrating Code The principle of dynamically configuring a client to communicate to a server. The client first fetches the necessary software, and then invokes the server.

Implication of Code Migration  Not ONLY code  Code segment  Resource segment: needed by the process  Execution segment: current execution state of the process  Weak mobility  strong mobility  Weak: only code segment which is portable  Strong: a process stops, move to another environments and resumes its execution. Powerful but hard to implement

Models for Code Migration Alternatives for code migration.

Migration and Local Resources Actions to be taken with respect to the references to local resources when migrating code to another machine. Binding by identifier, by value and by type (rebinding the same type) 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. For procedural languages such as C and Java. Code migration is restricted to specific points (e.g., a subroutine is called) in the execution of the program. Migration stack 3-15

Overview of Code Migration in D'Agents (1) A simple example of a Tel agent in D'Agents submitting a script to a remote machine (adapted from [gray.r95]) 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)

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 (adapted from [gray.r95]) all_users $machines 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)

Implementation Issues (1) The architecture of the D'Agents system.

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 Some important properties by which different types of agents can be distinguished. 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 (adapted from [fipa98-mgt]).

Agent Communication Languages (1) Examples of different message types in the FIPA ACL [fipa98-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 give 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 LanguageProlog Ontologygenealogy Contentfemale(beatrix),parent(beatrix,juliana,bernhard)