CGS 3763 Operating Systems Concepts Spring 2013 Dan C. Marinescu Office: HEC 304 Office hours: M-Wd 11:30 - 12:30 AM.

Slides:



Advertisements
Similar presentations
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 4: Multithreaded Programming.
Advertisements

Threads. Objectives To introduce the notion of a thread — a fundamental unit of CPU utilization that forms the basis of multithreaded computer systems.
Silberschatz, Galvin and Gagne ©2009Operating System Concepts – 8 th Edition Chapter 4: Threads.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Lecture 6: Threads Chapter 4.
Modified from Silberschatz, Galvin and Gagne ©2009 Lecture 7 Chapter 4: Threads (cont)
Chapter 4: Multithreaded Programming
Course: Operating Systems Instructor: Umar Kalim NUST Institute of Information Technology, Pakistan Operating Systems.
4.1 Silberschatz, Galvin and Gagne ©2005 Operating System Principles Chapter 4 Multithreaded Programming Objectives Objectives To introduce a notion of.
Based on Silberschatz, Galvin and Gagne  2009 Threads Definition and motivation Multithreading Models Threading Issues Examples.
1 School of Computing Science Simon Fraser University CMPT 300: Operating Systems I Ch 4: Threads Dr. Mohamed Hefeeda.
1 School of Computing Science Simon Fraser University CMPT 300: Operating Systems I Ch 4: Threads Dr. Mohamed Hefeeda.
Chapter 4: Multithreaded Programming. 4.2 Silberschatz, Galvin and Gagne ©2005 Operating System Principles Objectives To introduce a notion of a thread.
Chapter 4: Threads. 4.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Objectives Thread definitions and relationship to process Multithreading.
Silberschatz, Galvin and Gagne ©2009Operating System Concepts – 8 th Edition Chapter 4: Threads.
Chapter 4: Threads READ 4.1 & 4.2 NOT RESPONSIBLE FOR 4.3 &
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 4: Multithreaded Programming.
Chapter 4: Threads. 4.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 4: Threads Overview Multithreading Models Threading Issues.
14.1 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts with Java – 8 th Edition Chapter 4: Threads.
COT 4600 Operating Systems Fall 2009 Dan C. Marinescu Office: HEC 439 B Office hours: Tu-Th 3:00-4:00 PM.
COT 4600 Operating Systems Spring 2011 Dan C. Marinescu Office: HEC 304 Office hours: Tu-Th 5:00 – 6:00 PM.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 4: Threads.
Chapter 4: Threads. 4.2CSCI 380 Operating Systems Chapter 4: Threads Overview Multithreading Models Threading Issues Pthreads Windows XP Threads Linux.
1 Lecture 4: Threads Operating System Fall Contents Overview: Processes & Threads Benefits of Threads Thread State and Operations User Thread.
Copyright © 2006 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill Technology Education Lecture 4 Operating Systems.
Chapter 4: Threads. 4.2 Chapter 4: Threads Overview Multithreading Models Threading Issues Pthreads Windows XP Threads Linux Threads Java Threads.
14.1 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts with Java – 8 th Edition Chapter 4: Threads.
Silberschatz, Galvin and Gagne ©2011Operating System Concepts Essentials – 8 th Edition Chapter 4: Threads.
Process Management. Processes Process Concept Process Scheduling Operations on Processes Interprocess Communication Examples of IPC Systems Communication.
Silberschatz, Galvin and Gagne ©2009Operating System Concepts – 8 th Edition Chapter 4: Threads.
COT 4600 Operating Systems Fall 2009 Dan C. Marinescu Office: HEC 439 B Office hours: Tu-Th 3:00-4:00 PM.
Chapter 4: Threads. 4.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th edition, Jan 23, 2005 Chapter 4: Threads Overview Multithreading.
Chapter 4: Threads. 4.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 4: Threads Overview Multithreading Models Threading Issues.
Chapter 4: Threads. 2 Overview Multithreading Models Threading Issues Pthreads Windows XP Threads Linux Threads.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Chapter 4: Threads Modified from the slides of the text book. TY, Sept 2010.
Chapter 4: Threads.
Chapter 4: Threads. 4.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th edition, Jan 23, 2005 Chapter 4: Threads Overview Multithreading.
Department of Computer Science and Software Engineering
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 4: Threads.
Lecture 3 Threads Erick Pranata © Sekolah Tinggi Teknik Surabaya 1.
CGS 3763 Operating Systems Concepts Spring 2013 Dan C. Marinescu Office: HEC 304 Office hours: M-Wd 11: :30 AM.
CGS 3763 Operating Systems Concepts Spring 2013 Dan C. Marinescu Office: HEC 304 Office hours: M-Wd 11: :30 AM.
Saurav Karmakar. Chapter 4: Threads  Overview  Multithreading Models  Thread Libraries  Threading Issues  Operating System Examples  Windows XP.
COT 4600 Operating Systems Fall 2009 Dan C. Marinescu Office: HEC 439 B Office hours: Tu-Th 3:00-4:00 PM.
Chapter 4: Threads. 4.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th edition, Jan 23, 2005 Typical Program Processor utilization?
1 Advanced Operating Systems - Fall 2009 Lecture 5 – January 26, 2009 Dan C. Marinescu Office: HEC 439 B. Office hours:
Operating System Concepts
Silberschatz, Galvin and Gagne ©2009Operating System Concepts – 8 th Edition Chapter 4: Threads.
Lecturer 3: Processes multithreaded Operating System Concepts Process Concept Process Scheduling Operation on Processes Cooperating Processes Interprocess.
COT 4600 Operating Systems Spring 2011 Dan C. Marinescu Office: HEC 304 Office hours: Tu-Th 5:00 – 6:00 PM.
Silberschatz, Galvin and Gagne ©2009Operating System Concepts – 8 th Edition Chapter 4: Threads.
1 Chapter 5: Threads Overview Multithreading Models & Issues Read Chapter 5 pages
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 4: Threads.
Lecture 5. Example for periority The average waiting time : = 41/5= 8.2.
14.1 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts with Java – 8 th Edition Chapter 4: Multithreaded Programming.
COP 4600 Operating Systems Fall 2010 Dan C. Marinescu Office: HEC 439 B Office hours: Tu-Th 3:30-4:30 PM.
Introduction to threads
Client-Server Communication
OPERATING SYSTEM CONCEPT AND PRACTISE
Chapter 4: Threads.
Chapter 5: Threads Overview Multithreading Models Threading Issues
Chapter 4: Multithreaded Programming
Process Management Presented By Aditya Gupta Assistant Professor
CGS 3763 Operating Systems Concepts Spring 2013
Chapter 4: Threads.
Chapter 4: Threads.
Chapter 4: Threads.
Modified by H. Schulzrinne 02/15/10 Chapter 4: Threads.
CGS 3763 Operating Systems Concepts Spring 2013
Chapter 4: Threads.
Presentation transcript:

CGS 3763 Operating Systems Concepts Spring 2013 Dan C. Marinescu Office: HEC 304 Office hours: M-Wd 11: :30 AM

Last time:  Stubs  Client-server systems  Thin clients  Examples of client-server systems: event service, , X-windows, Web Today:  Heterogeneity  Remote procedure call  Threads Next time  Threads  Shared memory Reading assignments  Chapter 4 of the textbook  Chapters 4 textbook slides Lecture 16 – Wednesday, February 13, Lecture 16

3Lecture 15

Client server interactions in HTTP Lecture 154

5 Heterogeneity The client and the service may run on systems with different:  internal data representation, e.g., big versus little endian  processor architecture, e.g., 32 bit /64 bit addressing  operating systems, e.g., version of Linux, Mac OS, etc.  libraries Multiple clients and services provided/available on systems with different characteristics :  the same service may be provided by multiple systems;  a service may in turn user services available on other systems;  the same client may use multiple services. Marshaling/unmarshaling  conversion of the information in a message into a canonical representation and back Lecture 16

6 Little-endian and big-endian Lecture 16

7 Timing; response time The client and the service are connected via communication channel. The response time is a function of the latency and the bandwidth of the communication channel. Distinguish between  service time  communication time Synchronous call  the client blocks waiting for the response. Easier to manage. Asynchronous calls  the client does not block. Multi-threading and asynchronous calls. Message buffering  in kernel space (to allow clients to make asynchronous calls)  in user space (before sending) Lecture 16

8 8 Peer-to-peer systems Decentralized architecture without a trusted intermediary. Peers are both suppliers and consumers of resources, in contrast to the traditional client-server model where servers supply, and clients consume. Peer-to-peer systems often implement an Application Layer overlay network on top of the native or physical network topology. Such overlays are used for indexing and peer discovery. Content is typically exchanged directly over the underlying IP network. Anonymous peer-to-peer systems implement extra routing layers to obscure the identity of the source or destination of queries. In structured peer-to-peer networks, connections in the overlay are fixed. They typically use distributed hash table-based (DHT) indexing, such as in the Chord system developed at MIT Unstructured peer-to-peer networks do not provide any algorithm for organization or optimization of network connections. Advantages   use of spare resources at many sites  difficult to censor content Disadvantage  Finding information in a large peer-to-peer network is hard. Lecture 16

9 9 Remote procedure call (RPC) Support inter-process communication of remotely located processes and allows implementation of client-server systems (RFC 1831) Preserve the semantics of a local procedure call. To use an RPC a process may use a special service: PORTMAP or RPCBIND available at port 111. A new RPC service uses the portmapper to register. The portmapper also allows a service lookup. If the process knows the port number of the RPC it may call directly. RPC/TCP and also RPC/UDP Messages  must be well-structured; contain the identification of the specific RPC  are addressed to an RPC demon listening at an RPC port. A machine independent representation of data  external data representation standard (XDR). Lecture 16

10 Stub Unburdens a user from implementation details of the RPC; it hides:  the marshalling of the arguments  the communication details The client calls the client stub which: 1. marshals the arguments of the call into messages 2. sends the message 3. waits for the responds 4. when the response arrives it un-marshals the results 5. returns to the client Lecture 16

11 Lecture 16

12 RPCs differ from ordinary procedure calls RPCs  reduce the so called fate sharing between caller and callee  have a different semantics (see next slide)  take longer  global variables and RPC do not mix well Lecture 16

13 RPC semantics At least once  the client stub resends a message up to a given number of times until it receives a message from the server; is no guarantee of a response  the server may end up executing the a request more than once  suitable for side-effect free operations At most once  a message is acted upon at most once.  If the timeout set for receiving the response expires then an error code is delivered to the client.  The server must keep a history of the time-stamps of all messages. Messages may arrive out of order…..  Suitable for operations which have side effects Exactly once  implement the at most once and request an acknowledgment from the server. Lecture 16

Threads Thread  the smallest sequence of programmed instructions that can be managed independently by an operating system scheduler  a light-weight process  multiple threads can share the same address space On a single processor, multithreading generally occurs by time- division multiplexing, the processorswitches between different threads. This context switching generally happens frequently enough that the user perceives the threads or tasks as running at the same time.processor On a multiprocessor or a multi-core system the threads actually run at the same time, with each processor or core running a particular thread or task. Lecture 1614

Single- and multi-threaded processes Lecture 1615

Reasons for multithreading Reduce the execution time of a compute-intensive task. Better resource utilization – recall the imbalance between the CPU, memory, and I/O device bandwidth/speed. Improve scalability Example: multithreaded execution on a two core system Lecture 1616

Challenges Identify activities that can run in parallel. Divide the workload among the threads and balance the load. Minimize the communication among threads. Avoid barrier-synchronization  instances when all threads have to wait until all of them reach a certain execution stage. Debugging. Lecture 1617

Multithreading and client-server systems Lecture 1618

User and kernel threads User threads- thread management done by user-level threads library  POSIX Pthreads  Win32 threads  Java threads Kernel threads  Windows XP/2000  Solaris  Linux  Tru64 UNIX  Mac OS X Recall that the kernel has to keep track of all processes on the system and uses the PCB to do that. The kernel has to keep track of al threads as well. Lecture 1619

Relations between user and kernel threads Many-to-One  several user-level threads mapped to single kernel thread:  Solaris Green Threads  GNU Portable Threads One-to-One  each user-level thread maps to kernel thread:  Windows NT/XP/2000  Linux  Solaris 9 and later Many-to many  many user level threads mapped to many kernel threads  Allows the operating system to create a sufficient number of kernel threads  Solaris prior to version 9  Windows NT/2000 with the ThreadFiber package Lecture 1620

Lecture 1621