We think you have liked this presentation. If you wish to download it, please recommend it to your friends in any social system. Share buttons are a little bit lower. Thank you!
Presentation is loading. Please wait.
Published byIris Garner
Modified over 2 years ago
CMPT 431 Dr. Alexandra Fedorova Lecture III: OS Support
2 CMPT 431 © A. Fedorova The Role of the OS The operating system needs to provide support for implementation of distributed systems We will look at how distributed systems services interact with the operating systems We will discuss the support that the operating system needs to provide
3 CMPT 431 © A. Fedorova Direct Interaction with the OS OS Process: a DS component system calls A process directly interacts with the OS via system calls Example: a web browser, a web server
4 CMPT 431 © A. Fedorova Interaction via Middleware Layer OS Process: a DS component system calls Middleware Function calls or IPC A process directly interacts with the OS via a middleware layer A middleware layer directly interacts with the OS Example: a peer-to-peer file system implemented over a distributed hash table
5 CMPT 431 © A. Fedorova Interaction via Inclusion OS DS component A DS component is a part of the operating system, i.e., an operating system daemon Example: Network File System (NFS) daemon Runs as a kernel thread, shares address space with the kernel, interacts with the rest of the OS via function calls Why would one want to build a DS component that interacts with the OS via inclusion?
6 CMPT 431 © A. Fedorova Digression: Protection Implementation In the Kernel System calls are expensive Why? – Protection domains Refresh memory protection from your OS class Good thing: we get memory protection Bad thing: crossing protection domains is expensive. Why? So is this the best solution?
7 CMPT 431 © A. Fedorova Alternative: Protection Via Language Safety features are guaranteed by language/runtime Compiler checks safe memory access In addition there are manifests w.r.t. what the process will and will not do This way you get protection And no need for hardware protection domains – everything can run in a single address space Singularity: an OS from Microsoft implemented these concepts... End digression
8 CMPT 431 © A. Fedorova Infrastructure Provided by the OS Networking –Interface to network devices –Implementation of common protocols: TPC, UDP, IP Processes and threads –Efficient scheduling, load balancing and thread switching –Efficient thread synchronization –Efficient inter-process communication (IPC)
9 CMPT 431 © A. Fedorova The Need for Good Process/Thread Support Many distributed applications are implemented using multiple threads or processes Why?
10 CMPT 431 © A. Fedorova Motivation for Multithreaded Designs Servers provide access to large data sets (web servers, e-commerce servers) Even in the presence of caching, they often need to do I/O (to access files on disk or a network FS) I/O takes much longer than computation Overlapping I/O with computation to improve response time Threads make it easy to overlap I/O with computation While one thread blocks on I/O another can perform computation block Single thread time compute Multiple threads 1 request1.6 requests
11 CMPT 431 © A. Fedorova Process or Thread Scheduling Will use “process” and “thread” interchangeably –A single-threaded process maps to a kernel thread –Each thread in a multithreaded process (usually) maps to a kernel thread A scheduler decides which thread runs next on the CPU To ensure good support for DS components, a scheduler must: –Be scalable –Balance the load well –Ensure good interactive response –Keep context switches to a minimum (why?)
12 CMPT 431 © A. Fedorova Case Study: Solaris™ 10 OS Solaris is often used on server systems Known for its good scalability, good load balancing and interactive performance We will look at Solaris runqueues and how they are managed –A runqueue is a scheduling queue –A structure containing pointers to runnable threads – i.e., threads that are waiting for CPU
13 CMPT 431 © A. Fedorova Runqueues in Solaris Global kernel priority queue kpqueue User priority queues for CPU0 disp_q s User priority queues for CPU1 disp_q s …… Pri 0Pri 1Pri NPri 0Pri 1Pri N There is a user-level queue for each priority level A dispatcher runs the thread from the highest-priority non-empty queue
14 CMPT 431 © A. Fedorova Processor Load Balancing Load balancing ensures that the load is evenly distributed among the CPUs on a multiprocessor This improves the overall response time Solaris kernel ensures that queues are well balanced when it enqueues a thread into a runqueue /* * setbackdq() keeps runqs balanced such that the difference in length * between the chosen runq and the next one is no more than RUNQ_MAX_DIFF. * (…) */ A comment from Solaris source code. Source: http://cvs.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/uts/common/disp/disp.c, line 1200
15 CMPT 431 © A. Fedorova Tuning Thread Priorities For Improved Response Time If a thread has waited too long for a processor, its priority is elevated, so no thread is starved Threads holding critical resources are put to the front of the queue so that they release those resources as quickly as possible /* * Put the specified thread on the front of the dispatcher * queue corresponding to its current priority. * * Called with the thread in transition, onproc or stopped state * and locked (transition implies locked) and at high spl. * Returns with the thread in TS_RUN state and still locked. */ A comment on setfrontdq from Solaris source code. Source: http://cvs.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/uts/common/disp/disp.c, line 1381
16 CMPT 431 © A. Fedorova Ensuring Good Responsiveness in Time- Sharing Scheduler Solaris’s time-sharing scheduler (the default scheduler) assigns priorities so as to ensure good interactive performance Timeslice: the amount of time a thread can run on CPU before it is pre-empted If thread T used up it’s entire timeslice on CPU: –priority(T)↓, timeslice(T)↑ If thread T has given up CPU before using up its timeslice: –priority(T) ↑, timeslice (T) ↓ Why is this done?
17 CMPT 431 © A. Fedorova Time-Sharing Scheduler: Answers Minimizing context switch costs: –CPU-bound threads stay on CPU longer without a context switch –In compensation, they are scheduled less often, due to decreased priority –Reducing the number of context switches improves performance Ensuring good response for interactive applications –Interactive applications usually don’t use up their entire timeslice –Example: process a network message and release the CPU before the timeslice expires –Those applications will have their priority elevated, so they will respond quickly when response is needed (e.g., the next network packet arrives)
18 CMPT 431 © A. Fedorova What Limits Performance of MP/MT Applications? The cost of context switching – depends on the hardware; the OS cannot fix it alone –Save/restore the registers –Flush the CPU pipeline –If switching address spaces May need to flush the TLB (depends on the processor) May need to flush the cache (depends on the processor) The cost of inter-process communication(IPC): requires context switching The cost of inter-thread synchronization – by and large depends on the program structure; OS can fix some of it, but not all
19 CMPT 431 © A. Fedorova Thread Synchronization If lock is not available, threads wait Execution becomes serialized
20 CMPT 431 © A. Fedorova Next… Talk about synchronization Operating system support for efficient synchronization Transactional memory – new programming paradigm for efficient synchronization
CMPT 401 Dr. Alexandra Fedorova Lecture III: OS Support.
CMPT 401 Summer 2007 Dr. Alexandra Fedorova Lecture III: OS Support.
Threads CS 416: Operating Systems Design, Spring 2001 Department of Computer Science Rutgers University
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.
1 Processes and Threads Creation and Termination States Usage Implementations.
Chapter 51 Threads Chapter 5. 2 Process Characteristics Concept of Process has two facets. A Process is: A Unit of resource ownership: a virtual.
3.1 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Process An operating system executes a variety of programs: Batch system.
Review: Chapters 1 – Chapter 1: OS is a layer between user and hardware to make life easier for user and use hardware efficiently Control program.
We will focus on operating system concepts What does it do? How is it implemented? Apply to Windows, Linux, Unix, Solaris, Mac OS X. Will discuss differences.
I/O Systems ◦ Operating Systems ◦ CS550. Note: Based on Operating Systems Concepts by Silberschatz, Galvin, and Gagne Strongly recommended to read.
Recall: Three I/O Methods Synchronous: Wait for I/O operation to complete. Asynchronous: Post I/O request and switch to other work. DMA (Direct Memory.
Computers Operating System Essentials. Operating Systems PROGRAM HARDWARE OPERATING SYSTEM.
1 Multithreaded Programming in Java. 2 Agenda Introduction Thread Applications Defining Threads Java Threads and States Examples.
Operating System Examples - Scheduling. References r er/ch10.html r bangalore.org/blug/meetings/200401/scheduler-
© 2004, D. J. Foreman 1 Scheduling & Dispatching.
Scheduling Lecture 6. What is Scheduling? An O/S often has many pending tasks. –Threads, async callbacks, device input. The order may matter. –Policy,
User-Level Interprocess Communication for Shared Memory Multiprocessors Brian N. Bershad, Thomas E. Anderson, Edward D. Lazowska, and Henry M. Levy Presented.
Threads, SMP, and Microkernels
Scheduling Basic scheduling policies, for OS schedulers (threads, tasks, processes) or thread library schedulers Review of Context Switching overheads.
1 Chapter 5: Threads Overview Multithreading Models & Issues Read Chapter 5 pages
Lecture 3 Process Concepts. What is a Process? A process is the dynamic execution context of an executing program. Several processes may run concurrently,
Processes Chapter 3. Processes in Distributed Systems Processes and threads –Introduction to threads –Distinction between threads and processes Threads.
1 Processes and Threads Chapter Processes 2.2 Threads 2.3 Interprocess communication 2.4 Classical IPC problems 2.5 Scheduling.
Chapter 7 Protocol Software On A Conventional Processor.
Processes and Threads Chapter 3 and 4 Operating Systems: Internals and Design Principles, 6/E William Stallings Patricia Roy Manatee Community College,
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.
Operating Systems: Summary INF1060: Introduction to Operating Systems and Data Communication.
1 Previous lecture review n Out of basic scheduling techniques none is a clear winner: u FCFS - simple but unfair u RR - more overhead than FCFS may not.
A. Frank - P. Weisberg Operating Systems Introduction to Tasks/Threads.
Thread basics. A computer process Every time a program is executed a process is created It is managed via a data structure that keeps all things memory.
Processes Part I Processes & Threads* *Referred to slides by Dr. Sanjeev Setia at George Mason University Chapter 3.
Chapter 4 Memory Management Basic memory management Swapping
Silberschatz, Galvin and Gagne ©2009Operating System Concepts – 8 th Edition Chapter 4: Threads.
Chapter 4: Threads. Overview Multithreading Models Threading Issues Pthreads Windows XP Threads.
Threads Chapter 4 Threads are a subdivision of processes
1 Scheduling. 2 Content of This Lecture Why CPU scheduling? Basic scheduling algorithms FIFO (FCFS) Shortest job first Round Robin Priority Scheduling.
Avishai Wool lecture Priority Scheduling Idea: Jobs are assigned priorities. Always, the job with the highest priority runs. Note: All scheduling.
CS533 - Concepts of Operating Systems 1 The Mach System Presented by Catherine Vilhauer.
Scheduler Activations Effective Kernel Support for the User-Level Management of Parallelism.
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.
Operating System Concepts
Operating Systems CMPSC 473 Threads September 16, Lecture 7 Instructor: Bhuvan Urgaonkar.
CMPT 300: Final Review Chapters 8 – Memory Management: Ch. 8, 9 Address spaces Logical (virtual): generated by the CPU Physical: seen by the memory.
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Chapter 4: Threads.
Chapter 6 I/O Systems.
OPERATING SYSTEM SUPPORT DISTRIBUTED SYSTEMS CHAPTER 6 Lawrence Heyman July 8, 2002.
Operating System A program that controls the execution of application programs An interface between applications and hardware 1.
1 School of Computing Science Simon Fraser University CMPT 300: Operating Systems I Dr. Mohamed Hefeeda.
© 2017 SlidePlayer.com Inc. All rights reserved.