EECS122 - UCB 1 CS 194: Distributed Systems Processes, Threads, Code Migration Computer Science Division Department of Electrical Engineering and Computer.

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

Chapter 4 Threads Patricia Roy Manatee Community College, Venice, FL ©2008, Prentice Hall Operating Systems: Internals and Design Principles, 6/E William.
Threads, SMP, and Microkernels
Processes: Code Migration Chapter 3 Will Cameron CSC 8530 Dr. Schragger.
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.
Computer Systems/Operating Systems - Class 8
Day 10 Threads. Threads and Processes  Process is seen as two entities Unit of resource allocation (process or task) Unit of dispatch or scheduling (thread.
1 Threads, SMP, and Microkernels Chapter 4. 2 Process: Some Info. Motivation for threads! Two fundamental aspects of a “process”: Resource ownership Scheduling.
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.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 5: Threads Overview Multithreading Models Threading Issues Pthreads Solaris.
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
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:
1 School of Computing Science Simon Fraser University CMPT 300: Operating Systems I Ch 4: Threads Dr. Mohamed Hefeeda.
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.
1 Chapter 4 Threads Threads: Resource ownership and execution.
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.
Threads. Processes and Threads  Two characteristics of “processes” as considered so far: Unit of resource allocation Unit of dispatch  Characteristics.
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.
A. Frank - P. Weisberg Operating Systems Introduction to Tasks/Threads.
Threads CS 416: Operating Systems Design, Spring 2001 Department of Computer Science Rutgers University
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 Threads Chapter 4 Reading: 4.1,4.4, Process Characteristics l Unit of resource ownership - process is allocated: n a virtual address space to.
Give an example to show the advantages to using multithreaded Clients See page 142 of the core book (Tanebaum 2002).
Threads Chapter 4. Modern Process & Thread –Process is an infrastructure in which execution takes place  (address space + resources) –Thread is a program.
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.
9/13/20151 Threads ICS 240: Operating Systems –William Albritton Information and Computer Sciences Department at Leeward Community College –Original slides.
Processes, Threads and Virtualization
1 Lecture 4: Threads Operating System Fall Contents Overview: Processes & Threads Benefits of Threads Thread State and Operations User Thread.
Multithreading Allows application to split itself into multiple “threads” of execution (“threads of execution”). OS support for creating threads, terminating.
Silberschatz, Galvin and Gagne ©2009Operating System Concepts – 8 th Edition Chapter 4: Threads.
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.
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.
Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved DISTRIBUTED SYSTEMS.
Threads, SMP, and Microkernels Chapter 4. Process Resource ownership - process is allocated a virtual address space to hold the process image Scheduling/execution-
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.
Processes. Processes and threads Process forms a building block in distributed systems Processes granularity is not sufficient for distributed systems.
Computer Science Lecture 7, page 1 CS677: Distributed OS Multiprocessor Scheduling Will consider only shared memory multiprocessor Salient features: –One.
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.
Lecture 5: Threads process as a unit of scheduling and a unit of resource allocation processes vs. threads what to program with threads why use threads.
Department of Computer Science and Software Engineering
Operating Systems: Internals and Design Principles
1 Chapter 3 Processes Dowon Cho (RTMM Lab) & Jongwon Lee (SE Lab)
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.
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.
Threads, SMP, and Microkernels
Processes Chapter 3.
Prof. Leonardo Mostarda University of Camerino
Processes Chapter 3.
Processes Chapter 3.
Presentation transcript:

EECS122 - UCB 1 CS 194: Distributed Systems Processes, Threads, Code Migration Computer Science Division Department of Electrical Engineering and Computer Sciences University of California, Berkeley Berkeley, CA (Based on textbook slides)

Problem Escape the curse of blocking! A spreadsheet should be able to recompute the values while waiting for user input A file server should be able to serve other clients while waiting a disk read to complete …

Solutions Multi-processing Multi-threading One process + event driven programming

What is a Process? Execution context –Program counter (PC) –Stack pointer (SP) –Data registers Code Data Stack Code Static Data Heap PC SP Process

What is a Thread? Execution context –Program counter (PC) –Stack pointer (SP) –Data registers Stack (T1) Code Static Data Heap PC (T1) SP (T1) PC (T2) SP (T2) Stack (T2) Process

Process vs. Thread (1) Process: unit of allocation –Resources, privileges, etc Thread: unit of execution –PC, SP, registers Each process has one or more threads Each thread belong to one process

Process vs. Thread (2) Processes –Inter-process communication is expensive: need to context switch –Secure: one process cannot corrupt another process

Process vs. Thread (3) Threads –Inter-thread communication cheap: can use process memory and may not need to context switch –Not secure: a thread can write the memory used by another thread

User Level vs. Kernel Level Threads User level: use user-level thread package; totally transparent to OS –Light-weight –If a thread blocks, all threads in the process block Kernel level: threads are scheduled by OS –A thread blocking won’t affect other threads in the same process –Can take advantage of multi-processors –Still requires context switch, but cheaper than process context switching

Thread Creation Example (Java) final List list; // some sort unsorted list of objects // A Thread class for sorting a List in the background class Sorter extends Thread { List l; public Sorter(List l) { this.l = l; } // constructor public void run() { Collections.sort(l); } // Thread body } // Create a Sorter Thread Thread sorter new Sorter(list); // Start running the thread; the new thread starts running the run method above // while the original thread continues with the next instructions sorter.start(); System.out.println(“I’m the original thread”); (Java in a Nutshell, Flanagan)

Thread Implementation Combining kernel-level lightweight processes and user-level threads –LWPs are transparent to applications –A thread package can be shared by multiple LWPs –A LWP looks constantly after runnable threads

User-level, Kernel-level and Combined (Operating Systems, Stallings)

Example of Combined Threads (Operating Systems, Stallings)

Multithreaded Servers A multithreaded server organized in a dispatcher/worker model

Event Driven Programming Organize program as a finite state automaton Never call blocking functions When a function returns –Need a callback mechanism to invoke process, or –Process can periodically pool for return values Very efficient; zero context switching! Hard to program

Trade-offs ModelCharacteristics ThreadsParallelism, blocking system calls Single-threaded processNo parallelism, blocking system calls Event driven (Finite state machine) Parallelism, nonblocking system calls

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

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

Code Migration: Motivation Performance –Move code on a faster machine –Move code closer to data Flexibility –Allow to dynamically configure a distributed system

Dynamically Configuring a Client The client first fetches the necessary software, and then invokes the server

Code Migration Model Process model for code migration (Fugetta et al., 98) –Code segment: set of instructions that make up the program –Resource segment: references to external resources –Execution segment: store current execution state Type of mobility –Weak mobility: migrate only code segment –Strong mobility: migrate execution segment and resource segment

Models for Code Migration

Migration and Local Resources Types of process-to-resource binding –Binding by identifier (e.g., URL, (IPaddr:Port)) –Binding by value (e.g., standard libraries) –Binding by type (e.g., monitor, printer) Type of resources –Unattached resources: can be easily moved (e.g., data files) –Fastened resources: can be used but at a high cost (e.g., local databases, web sites) –Fixed resources: cannot be moved (e.g., local devices)

Migration and Local Resources Actions to be taken with respect to the references to local resources when migrating code –GR: establish a global system wide reference –MV: move the resource –CP: copy the value of resource –RB: rebind the process to locally available resource 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 Maintain a migration stack in an independent format Migrate only at certain points in the program (e.g., before/after calling a procedure)

Weak Mobility in D'Agents (1) A Tel agent in D'Agents submitting a script to a remote machine (adapted from [Gray ‘95]) 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)

Strong Mobility in D'Agents (2) A Tel agent in D'Agents migrating to different machines where it executes the UNIX who command (adapted from [Gray 95]) 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)