Understanding the Python GIL
|
|
|
- Margery Parsons
- 9 years ago
- Views:
Transcription
1 Understanding the Python GIL David Beazley Presented at PyCon 2010 Atlanta, Georgia 1
2 Introduction As a few of you might know, C Python has a Global Interpreter Lock (GIL) >>> import that The Unwritten Rules of Python 1. You do not talk about the GIL. 2. You do NOT talk about the GIL. 3. Don't even mention the GIL. No seriously.... It limits thread performance Thus, a source of occasional "contention" 2
3 An Experiment Consider this trivial CPU-bound function def countdown(n): while n > 0: n -= 1 Run it once with a lot of work COUNT = countdown(count) # 100 million Now, subdivide the work across two threads t1 = Thread(target=countdown,args=(COUNT//2,)) t2 = Thread(target=countdown,args=(COUNT//2,)) t1.start(); t2.start() t1.join(); t2.join() 3
4 A Mystery Performance on a quad-core MacPro Sequential Threaded (2 threads) : 7.8s : 15.4s (2X slower!) Performance if work divided across 4 threads Threaded (4 threads) : 15.7s (about the same) Performance if all but one CPU is disabled Threaded (2 threads) Threaded (4 threads) Think about it... : 11.3s (~35% faster than running : 11.6s with all 4 cores) 4
5 This Talk An in-depth look at threads and the GIL that will explain that mystery and much more Some cool pictures A look at the new GIL in Python 3.2 5
6 Disclaimers I gave an earlier talk on this topic at the Chicago Python Users Group (chipy) That is a different, but related talk I'm going to go pretty fast... please hang on 6
7 Part I Threads and the GIL 7
8 Python Threads Python threads are real system threads POSIX threads (pthreads) Windows threads Fully managed by the host operating system Represent threaded execution of the Python interpreter process (written in C) 8
9 Alas, the GIL Parallel execution is forbidden There is a "global interpreter lock" The GIL ensures that only one thread runs in the interpreter at once Simplifies many low-level details (memory management, callouts to C extensions, etc.) 9
10 Thread Execution Model With the GIL, you get cooperative multitasking I/O I/O I/O I/O I/O Thread 1 run run Thread 2 Thread 3 release GIL acquire GIL run release GIL run acquire GIL run When a thread is running, it holds the GIL GIL released on I/O (read,write,send,recv,etc.) 10
11 CPU Bound Tasks CPU-bound threads that never perform I/O are handled as a special case A "check" occurs every 100 "ticks" CPU Bound Thread Run 100 ticks check Run 100 ticks check Run 100 ticks check Change it using sys.setcheckinterval() 11
12 What is a "Tick?" Ticks loosely map to interpreter instructions def countdown(n): while n > 0: print n n -= 1 Instructions in the Python VM Not related to timing (ticks might be long) Tick 1 Tick 2 Tick 3 Tick 4 >>> import dis >>> dis.dis(countdown) 0 SETUP_LOOP 33 (to 36) 3 LOAD_FAST 0 (n) 6 LOAD_CONST 1 (0) 9 COMPARE_OP 4 (>) 12 JUMP_IF_FALSE 19 (to 34) 15 POP_TOP 16 LOAD_FAST 0 (n) 19 PRINT_ITEM 20 PRINT_NEWLINE 21 LOAD_FAST 0 (n) 24 LOAD_CONST 2 (1) 27 INPLACE_SUBTRACT 28 STORE_FAST 0 (n) 31 JUMP_ABSOLUTE
13 The Periodic "Check" The periodic check is really simple The currently running thread... Resets the tick counter Runs signal handlers if the main thread Releases the GIL Reacquires the GIL That's it 13
14 Implementation (C) Decrement ticks Reset ticks Run signal handlers Release and reacquire the GIL /* Python/ceval.c */... if (--_Py_Ticker < 0) {... _Py_Ticker = _Py_CheckInterval;... if (things_to_do) { if (Py_MakePendingCalls() < 0) {... } } if (interpreter_lock) { /* Give another thread a chance */ PyThread_release_lock(interpreter_lock);... } /* Other threads may run now */ Note: Each thread is running this same code PyThread_acquire_lock(interpreter_lock, 1); 14
15 Big Question What is the source of that large CPU-bound thread performance penalty? There's just not much code to look at Is GIL acquire/release solely responsible? How would you find out? 15
16 Part 2 The GIL and Thread Switching Deconstructed 16
17 Python Locks The Python interpreter only provides a single lock type (in C) that is used to build all other thread synchronization primitives It's not a simple mutex lock It's a binary semaphore constructed from a pthreads mutex and a condition variable The GIL is an instance of this lock 17
18 Locks Deconstructed pseudocode Locks consist of three parts locked = 0 # Lock status mutex = pthreads_mutex() # Lock for the status cond = pthreads_cond() # Used for waiting/wakeup Here's how acquire() and release() work release() { mutex.acquire() locked = 0 mutex.release() cond.signal() } A critical aspect concerns this signaling between threads acquire() { mutex.acquire() while (locked) { cond.wait(mutex) } locked = 1 mutex.release() } 18
19 Thread Switching Suppose you have two threads Thread 1 Running Thread 2 READY Thread 1 : Running Thread 2 : Ready (Waiting for GIL) 19
20 Thread Switching Easy case : Thread 1 performs I/O (read/write) Thread 1 Running release GIL I/O Thread 2 READY Thread 1 might block so it releases the GIL 20
21 Thread Switching Easy case : Thread 1 performs I/O (read/write) Thread 1 Running release GIL I/O signal pthreads/os Thread 2 READY context switch Running acquire GIL Release of GIL results in a signaling operation Handled by thread library and operating system 21
22 Thread Switching Tricky case : Thread 1 runs until the check Thread ticks release GIL check signal??? pthreads/os Which thread runs now? Thread 2 READY??? Either thread is able to run So, which is it? 22
23 pthreads Undercover Condition variables have an internal wait queue Condition Variable waiters cv.wait() thread enqueues thread thread thread queue of threads waiting on cv (often FIFO) cv.signal() dequeues Signaling pops a thread off of the queue However, what happens after that? 23
24 OS Scheduling The operating system has a priority queue of threads/processes ready to run Signaled threads simply enter that queue The operating system then runs the process or thread with the highest priority It may or may not be the signaled thread 24
25 Thread Switching Thread 1 might keep going Thread 1 (high priority) 100 ticks release GIL check acquire GIL pthreads/os Running Thread 2 (low priority) schedule READY... Runs later Thread 2 moves to the OS "ready" queue and executes at some later time 25
26 Thread Switching Thread 2 might immediately take over Thread 1 (low priority) Thread 2 (high priority) 100 ticks release GIL READY check signal pthreads/os context switch acquire GIL Running Again, highest priority wins 26
27 Part 3 What Can Go Wrong? 27
28 GIL Instrumentation To study thread scheduling in more detail, I instrumented Python with some logging Recorded a large trace of all GIL acquisitions, releases, conflicts, retries, etc. Goal was to get a better idea of how threads were scheduled, interactions between threads, internal GIL behavior, etc. 28
29 GIL Logging An extra tick counter was added to record number of cycles of the check interval Locks modified to log GIL events (pseudocode) release() { mutex.acquire() locked = 0 if gil: log("release") mutex.release() cv.signal() } Note: Actual code in C, event logs are stored entirely in memory until exit (no I/O) acquire() { mutex.acquire() if locked and gil: log("busy") while locked: cv.wait(mutex) if locked and gil: log("retry") locked = 1 if gil: log("acquire") mutex.release() } 29
30 A Sample Trace thread id tick countdown total number of "checks" executed t ACQUIRE t RELEASE t ACQUIRE t RELEASE t ACQUIRE t BUSY t RELEASE t ACQUIRE t RETRY t RELEASE t ACQUIRE t RETRY t RELEASE t ACQUIRE t BUSY t RELEASE ACQUIRE : GIL acquired RELEASE : GIL released BUSY : Attempted to acquire GIL, but it was already in use RETRY : Repeated attempt to acquire the GIL, but it was still in use Trace files were large (>20MB for 1s of running) 30
31 Logging Results The logs were quite revealing Interesting behavior on one CPU Diabolical behavior on multiple CPUs Will briefly summarize findings followed by an interactive visualization that shows details 31
32 Single CPU Threading Threads alternate execution, but switch far less frequently than you might imagine Thread ticks check 100 ticks check... check READY signal signal pthreads/os Thread Context Switch Thread 2 schedule READY run Hundreds to thousands of checks might occur before a thread context switch (this is good) 32
33 Multicore GIL War With multiple cores, runnable threads get scheduled simultaneously (on different cores) and battle over the GIL Thread 1 (CPU 1) Thread 2 (CPU 2) Release GIL Acquire GIL Release GIL Acquire GIL run run run signal signal Wake Acquire GIL (fails) Wake Acquire GIL (fails) Thread 2 is repeatedly signaled, but when it wakes up, the GIL is already gone (reacquired) 33
34 Multicore Event Handling CPU-bound threads make GIL acquisition difficult for threads that want to handle events Thread 1 (CPU 1) Thread 2 (CPU 2) run signal signal signal signal sleep Event Acquire GIL (fails) Acquire GIL (fails) Acquire GIL (fails) Acquire GIL (success) run Might repeat 100s-1000s of times 34
35 Behavior of I/O Handling I/O ops often do not block Thread 1 run read write write write write run signal burst Due to buffering, the OS is able to fulfill I/O requests immediately and keep a thread running However, the GIL is always released Results in GIL thrashing under heavy load 35
36 GIL Visualization (Demo) Let's look at all of these effects Some facts about the plots: Generated from ~2GB of log data Rendered into ~2 million PNG image tiles Created using custom scripts/tools I used the multiprocessing module 36
37 Part 4 A Better GIL? 37
38 The New GIL Python 3.2 has a new GIL implementation (only available by svn checkout) The work of Antoine Pitrou (applause) It aims to solve all that GIL thrashing It is the first major change to the GIL since the inception of Python threads in 1992 Let's go take a look 38
39 New Thread Switching Instead of ticks, there is now a global variable /* Python/ceval.c */... static volatile int gil_drop_request = 0; A thread runs until the value gets set to 1 At which point, the thread must drop the GIL Big question: How does that happen? 39
40 New GIL Illustrated Suppose that there is just one thread Thread 1 running It just runs and runs and runs... Never releases the GIL Never sends any signals Life is great! 40
41 New GIL Illustrated Suppose, a second thread appears Thread 1 running Thread 2 SUSPENDED It is suspended because it doesn't have the GIL Somehow, it has to get it from Thread 1 41
42 New GIL Illustrated Waiting thread does a timed cv_wait on GIL Thread 1 running Thread 2 SUSPENDED cv_wait(gil, TIMEOUT) By default TIMEOUT is 5 milliseconds, but it can be changed The idea : Thread 2 waits to see if the GIL gets released voluntarily by Thread 1 (e.g., if there is I/O or it goes to sleep for some reason) 42
43 New GIL Illustrated Voluntary GIL release Thread 1 running I/O signal Thread 2 SUSPENDED running cv_wait(gil, TIMEOUT) This is the easy case. Second thread is signaled and it grabs the GIL. 43
44 New GIL Illustrated If timeout, set gil_drop_request Thread 1 running gil_drop_request = 1 Thread 2 TIMEOUT SUSPENDED cv_wait(gil, TIMEOUT) cv_wait(gil, TIMEOUT) Thread 2 then repeats its wait on the GIL 44
45 New GIL Illustrated Thread 1 suspends after current instruction Thread 1 running Thread 2 gil_drop_request = 1 TIMEOUT SUSPENDED signal running cv_wait(gil, TIMEOUT) cv_wait(gil, TIMEOUT) Signal is sent to indicate release of GIL 45
46 New GIL Illustrated On a forced release, a thread waits for an ack Thread 1 cv_wait(gotgil) running WAIT gil_drop_request = 1 signal signal (ack) Thread 2 TIMEOUT SUSPENDED running cv_wait(gil, TIMEOUT) cv_wait(gil, TIMEOUT) Ack ensures that the other thread successfully got the GIL and is now running This eliminates the "GIL Battle" 46
47 New GIL Illustrated The process now repeats itself for Thread 1 Thread 1 cv_wait(gotgil) cv_wait(gil, TIMEOUT) running WAIT SUSPENDED gil_drop_request = 1 signal gil_drop_request =0 Thread 2 TIMEOUT SUSPENDED running cv_wait(gil, TIMEOUT) cv_wait(gil, TIMEOUT) So, the timeout sequence happens over and over again as CPU-bound threads execute 47
48 Does it Work? Yes, apparently (4-core MacPro, OS-X ) Sequential : 11.53s Threaded (2 threads) : 11.93s Threaded (4 threads) : 12.32s Keep in mind, Python is still limited by the GIL in all of the usual ways (threads still provide no performance boost) But, otherwise, it looks promising! 48
49 Part 5 Die GIL Die!!! 49
50 Alas, It Doesn't Work The New GIL impacts I/O performance Here is a fragment of network code Thread 1 Thread 2 def spin(): while True: # some work pass def echo_server(s): while True: data = s.recv(8192) if not data: break s.sendall(data) One thread is working (CPU-bound) One thread receives and echos data on a socket 50
51 Response Time New GIL increases response time Thread 1 running gil_drop_request = 1 signal Thread 2 TIMEOUT READY cv_wait(gil, TIMEOUT) running cv_wait(gil, TIMEOUT) data arrives To handle I/O, a thread must go through the entire timeout sequence to get control Ignores the high priority of I/O or events 51
52 Unfair Wakeup/Starvation Most deserving thread may not get the GIL Thread 1 running gil_drop_request = 1 signal Thread 2 Thread 3 data arrives TIMEOUT READY cv_wait(gil, TIMEOUT) READY READY cv_wait(gil, TIMEOUT) running wakeup Caused by internal condition variable queuing Further increases the response time 52
53 Convoy Effect I/O operations that don't block cause stalls Thread 1 Thread 2 running timeout sig timeout sig timeout READY READY READY data arrives send (executes immediately) send (executes immediately) Since I/O operations always release the GIL, CPU-bound threads will always try to restart On I/O completion (almost immediately), the GIL is gone so the timeout has to repeat 53
54 An Experiment Send 10MB of data to an echo server thread that's competing with a CPU-bound thread Python (2 CPU) : 0.57s (10 sample average) Python 3.2 (2 CPU) : 12.4s (20x slower) What if echo competes with 2 CPU threads? Python (2 CPU) : 0.25s (Better performance?) Python 3.2 (2 CPU) : 46.9s (4x slower than before) Python 3.2 (1 CPU) : 0.14s (330x faster than 2 cores?) Arg! Enough already! 54
55 Part 6 Score : Multicore 2, GIL 0 55
56 Fixing the GIL Can the GIL's erratic behavior be fixed? My opinion : Yes, maybe. The new GIL is already 90% there It just needs a few extra bits 56
57 The Missing Bits Priorities: There must be some way to separate CPU-bound (low priority) and I/O bound (high priority) threads Preemption: High priority threads must be able to immediately preempt low-priority threads 57
58 A Possible Solution Operating systems use timeouts to automatically adjust task priorities (multilevel feedback queuing) If a thread is preempted by a timeout, it is penalized with lowered priority (bad thread) If a thread suspends early, it is rewarded with raised priority (good thread) High priority threads always preempt low priority threads Maybe it could be applied to the new GIL? 58
59 Remove the GIL? This entire talk has been about the problem of implementing one tiny little itty bitty lock Fixing Python to remove the GIL entirely is an exponentially more difficult project If there is one thing to take away, there are practical reasons why the GIL remains 59
60 Final Thoughts Don't use this talk to justify not using threads Threads are a very useful programming tool for many kinds of concurrency problems Threads can also offer excellent performance even with the GIL (you need to study it) However, you should know about the tricky corner cases 60
61 Final Thoughts Improving the GIL is something that all Python programmers should care about Multicore is not going away You might not use threads yourself, but they are used for a variety of low-level purposes in frameworks and libraries you might be using More predictable thread behavior is good 61
62 Thread Terminated That's it! Thanks for listening! Questions 62
SYSTEM ecos Embedded Configurable Operating System
BELONGS TO THE CYGNUS SOLUTIONS founded about 1989 initiative connected with an idea of free software ( commercial support for the free software ). Recently merged with RedHat. CYGNUS was also the original
CPU Scheduling Outline
CPU Scheduling Outline What is scheduling in the OS? What are common scheduling criteria? How to evaluate scheduling algorithms? What are common scheduling algorithms? How is thread scheduling different
Process Scheduling CS 241. February 24, 2012. Copyright University of Illinois CS 241 Staff
Process Scheduling CS 241 February 24, 2012 Copyright University of Illinois CS 241 Staff 1 Announcements Mid-semester feedback survey (linked off web page) MP4 due Friday (not Tuesday) Midterm Next Tuesday,
W4118 Operating Systems. Instructor: Junfeng Yang
W4118 Operating Systems Instructor: Junfeng Yang Outline Introduction to scheduling Scheduling algorithms 1 Direction within course Until now: interrupts, processes, threads, synchronization Mostly mechanisms
Linux Process Scheduling Policy
Lecture Overview Introduction to Linux process scheduling Policy versus algorithm Linux overall process scheduling objectives Timesharing Dynamic priority Favor I/O-bound process Linux scheduling algorithm
Operating Systems Concepts: Chapter 7: Scheduling Strategies
Operating Systems Concepts: Chapter 7: Scheduling Strategies Olav Beckmann Huxley 449 http://www.doc.ic.ac.uk/~ob3 Acknowledgements: There are lots. See end of Chapter 1. Home Page for the course: http://www.doc.ic.ac.uk/~ob3/teaching/operatingsystemsconcepts/
Last Class: Semaphores
Last Class: Semaphores A semaphore S supports two atomic operations: S Wait(): get a semaphore, wait if busy semaphore S is available. S Signal(): release the semaphore, wake up a process if one is waiting
Scheduling 0 : Levels. High level scheduling: Medium level scheduling: Low level scheduling
Scheduling 0 : Levels High level scheduling: Deciding whether another process can run is process table full? user process limit reached? load to swap space or memory? Medium level scheduling: Balancing
4003-440/4003-713 Operating Systems I. Process Scheduling. Warren R. Carithers ([email protected]) Rob Duncan ([email protected])
4003-440/4003-713 Operating Systems I Process Scheduling Warren R. Carithers ([email protected]) Rob Duncan ([email protected]) Review: Scheduling Policy Ideally, a scheduling policy should: Be: fair, predictable
Multiprocessor Scheduling and Scheduling in Linux Kernel 2.6
Multiprocessor Scheduling and Scheduling in Linux Kernel 2.6 Winter Term 2008 / 2009 Jun.-Prof. Dr. André Brinkmann [email protected] Universität Paderborn PC² Agenda Multiprocessor and
Chapter 5 Process Scheduling
Chapter 5 Process Scheduling CPU Scheduling Objective: Basic Scheduling Concepts CPU Scheduling Algorithms Why Multiprogramming? Maximize CPU/Resources Utilization (Based on Some Criteria) CPU Scheduling
CS414 SP 2007 Assignment 1
CS414 SP 2007 Assignment 1 Due Feb. 07 at 11:59pm Submit your assignment using CMS 1. Which of the following should NOT be allowed in user mode? Briefly explain. a) Disable all interrupts. b) Read the
Chapter 6, The Operating System Machine Level
Chapter 6, The Operating System Machine Level 6.1 Virtual Memory 6.2 Virtual I/O Instructions 6.3 Virtual Instructions For Parallel Processing 6.4 Example Operating Systems 6.5 Summary Virtual Memory General
Why Threads Are A Bad Idea (for most purposes)
Why Threads Are A Bad Idea (for most purposes) John Ousterhout Sun Microsystems Laboratories [email protected] http://www.sunlabs.com/~ouster Introduction Threads: Grew up in OS world (processes).
Operating System: Scheduling
Process Management Operating System: Scheduling OS maintains a data structure for each process called Process Control Block (PCB) Information associated with each PCB: Process state: e.g. ready, or waiting
Semaphores and Monitors: High-level Synchronization Constructs
Semaphores and Monitors: High-level Synchronization Constructs 1 Synchronization Constructs Synchronization Coordinating execution of multiple threads that share data structures Past few lectures: Locks:
Chapter 13 Embedded Operating Systems
Operating Systems: Internals and Design Principles Chapter 13 Embedded Operating Systems Eighth Edition By William Stallings Embedded System Refers to the use of electronics and software within a product
RTOS Debugger for ecos
RTOS Debugger for ecos TRACE32 Online Help TRACE32 Directory TRACE32 Index TRACE32 Documents... RTOS Debugger... RTOS Debugger for ecos... 1 Overview... 2 Brief Overview of Documents for New Users... 3
Deciding which process to run. (Deciding which thread to run) Deciding how long the chosen process can run
SFWR ENG 3BB4 Software Design 3 Concurrent System Design 2 SFWR ENG 3BB4 Software Design 3 Concurrent System Design 11.8 10 CPU Scheduling Chapter 11 CPU Scheduling Policies Deciding which process to run
! Past few lectures: Ø Locks: provide mutual exclusion Ø Condition variables: provide conditional synchronization
1 Synchronization Constructs! Synchronization Ø Coordinating execution of multiple threads that share data structures Semaphores and Monitors: High-level Synchronization Constructs! Past few lectures:
ò Paper reading assigned for next Thursday ò Lab 2 due next Friday ò What is cooperative multitasking? ò What is preemptive multitasking?
Housekeeping Paper reading assigned for next Thursday Scheduling Lab 2 due next Friday Don Porter CSE 506 Lecture goals Undergrad review Understand low-level building blocks of a scheduler Understand competing
CPU Scheduling 101. The CPU scheduler makes a sequence of moves that determines the interleaving of threads.
CPU Scheduling CPU Scheduling 101 The CPU scheduler makes a sequence of moves that determines the interleaving of threads. Programs use synchronization to prevent bad moves. but otherwise scheduling choices
Project No. 2: Process Scheduling in Linux Submission due: April 28, 2014, 11:59pm
Project No. 2: Process Scheduling in Linux Submission due: April 28, 2014, 11:59pm PURPOSE Getting familiar with the Linux kernel source code. Understanding process scheduling and how different parameters
2. is the number of processes that are completed per time unit. A) CPU utilization B) Response time C) Turnaround time D) Throughput
Import Settings: Base Settings: Brownstone Default Highest Answer Letter: D Multiple Keywords in Same Paragraph: No Chapter: Chapter 5 Multiple Choice 1. Which of the following is true of cooperative scheduling?
Software and the Concurrency Revolution
Software and the Concurrency Revolution A: The world s fastest supercomputer, with up to 4 processors, 128MB RAM, 942 MFLOPS (peak). 2 Q: What is a 1984 Cray X-MP? (Or a fractional 2005 vintage Xbox )
Real Time Programming: Concepts
Real Time Programming: Concepts Radek Pelánek Plan at first we will study basic concepts related to real time programming then we will have a look at specific programming languages and study how they realize
Synchronization. Todd C. Mowry CS 740 November 24, 1998. Topics. Locks Barriers
Synchronization Todd C. Mowry CS 740 November 24, 1998 Topics Locks Barriers Types of Synchronization Mutual Exclusion Locks Event Synchronization Global or group-based (barriers) Point-to-point tightly
Real-Time Systems Prof. Dr. Rajib Mall Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur
Real-Time Systems Prof. Dr. Rajib Mall Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur Lecture No. # 26 Real - Time POSIX. (Contd.) Ok Good morning, so let us get
ICS 143 - Principles of Operating Systems
ICS 143 - Principles of Operating Systems Lecture 5 - CPU Scheduling Prof. Nalini Venkatasubramanian [email protected] Note that some slides are adapted from course text slides 2008 Silberschatz. Some
Readings for this topic: Silberschatz/Galvin/Gagne Chapter 5
77 16 CPU Scheduling Readings for this topic: Silberschatz/Galvin/Gagne Chapter 5 Until now you have heard about processes and memory. From now on you ll hear about resources, the things operated upon
Thread Synchronization and the Java Monitor
Articles News Weblogs Buzz Chapters Forums Table of Contents Order the Book Print Email Screen Friendly Version Previous Next Chapter 20 of Inside the Java Virtual Machine Thread Synchronization by Bill
Chapter 1 Computer System Overview
Operating Systems: Internals and Design Principles Chapter 1 Computer System Overview Eighth Edition By William Stallings Operating System Exploits the hardware resources of one or more processors Provides
Operating Systems Lecture #6: Process Management
Lecture #6: Process Written by based on the lecture series of Dr. Dayou Li and the book Understanding 4th ed. by I.M.Flynn and A.McIver McHoes (2006) Department of Computer Science and Technology,., 2013
Input / Output and I/O Strategies
The Four Major Input / Output Strategies Preliminary Definitions A Silly Example to Illustrate Basic Definitions Input / Output and I/O Strategies A Context for Advanced I/O Strategies The Four Strategies
CPU Scheduling. Basic Concepts. Basic Concepts (2) Basic Concepts Scheduling Criteria Scheduling Algorithms Batch systems Interactive systems
Basic Concepts Scheduling Criteria Scheduling Algorithms Batch systems Interactive systems Based on original slides by Silberschatz, Galvin and Gagne 1 Basic Concepts CPU I/O Burst Cycle Process execution
CS 377: Operating Systems. Outline. A review of what you ve learned, and how it applies to a real operating system. Lecture 25 - Linux Case Study
CS 377: Operating Systems Lecture 25 - Linux Case Study Guest Lecturer: Tim Wood Outline Linux History Design Principles System Overview Process Scheduling Memory Management File Systems A review of what
Distributed Systems [Fall 2012]
Distributed Systems [Fall 2012] [W4995-2] Lec 6: YFS Lab Introduction and Local Synchronization Primitives Slide acks: Jinyang Li, Dave Andersen, Randy Bryant (http://www.news.cs.nyu.edu/~jinyang/fa10/notes/ds-lec2.ppt,
Shared Address Space Computing: Programming
Shared Address Space Computing: Programming Alistair Rendell See Chapter 6 or Lin and Synder, Chapter 7 of Grama, Gupta, Karypis and Kumar, and Chapter 8 of Wilkinson and Allen Fork/Join Programming Model
Outline: Operating Systems
Outline: Operating Systems What is an OS OS Functions Multitasking Virtual Memory File Systems Window systems PC Operating System Wars: Windows vs. Linux 1 Operating System provides a way to boot (start)
Monitors, Java, Threads and Processes
Monitors, Java, Threads and Processes 185 An object-oriented view of shared memory A semaphore can be seen as a shared object accessible through two methods: wait and signal. The idea behind the concept
Real-Time Scheduling 1 / 39
Real-Time Scheduling 1 / 39 Multiple Real-Time Processes A runs every 30 msec; each time it needs 10 msec of CPU time B runs 25 times/sec for 15 msec C runs 20 times/sec for 5 msec For our equation, A
CS11 Java. Fall 2014-2015 Lecture 7
CS11 Java Fall 2014-2015 Lecture 7 Today s Topics! All about Java Threads! Some Lab 7 tips Java Threading Recap! A program can use multiple threads to do several things at once " A thread can have local
Scheduling. Yücel Saygın. These slides are based on your text book and on the slides prepared by Andrew S. Tanenbaum
Scheduling Yücel Saygın These slides are based on your text book and on the slides prepared by Andrew S. Tanenbaum 1 Scheduling Introduction to Scheduling (1) Bursts of CPU usage alternate with periods
OS OBJECTIVE QUESTIONS
OS OBJECTIVE QUESTIONS Which one of the following is Little s formula Where n is the average queue length, W is the time that a process waits 1)n=Lambda*W 2)n=Lambda/W 3)n=Lambda^W 4)n=Lambda*(W-n) Answer:1
Operating Systems. 05. Threads. Paul Krzyzanowski. Rutgers University. Spring 2015
Operating Systems 05. Threads Paul Krzyzanowski Rutgers University Spring 2015 February 9, 2015 2014-2015 Paul Krzyzanowski 1 Thread of execution Single sequence of instructions Pointed to by the program
Last Class: OS and Computer Architecture. Last Class: OS and Computer Architecture
Last Class: OS and Computer Architecture System bus Network card CPU, memory, I/O devices, network card, system bus Lecture 3, page 1 Last Class: OS and Computer Architecture OS Service Protection Interrupts
Windows Server Performance Monitoring
Spot server problems before they are noticed The system s really slow today! How often have you heard that? Finding the solution isn t so easy. The obvious questions to ask are why is it running slowly
Frequently Asked Questions: Cisco Jabber 9.x for Android
Frequently Asked Questions Frequently Asked Questions: Cisco Jabber 9.x for Android Frequently Asked Questions (FAQs) 2 Setup 2 Basics 4 Connectivity 8 Calls 9 Contacts and Directory Search 14 Voicemail
CPU Scheduling. CPU Scheduling
CPU Scheduling Electrical and Computer Engineering Stephen Kim ([email protected]) ECE/IUPUI RTOS & APPS 1 CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms Multiple-Processor Scheduling
CPU SCHEDULING (CONT D) NESTED SCHEDULING FUNCTIONS
CPU SCHEDULING CPU SCHEDULING (CONT D) Aims to assign processes to be executed by the CPU in a way that meets system objectives such as response time, throughput, and processor efficiency Broken down into
Jive Connects for Openfire
Jive Connects for Openfire Contents Jive Connects for Openfire...2 System Requirements... 2 Setting Up Openfire Integration... 2 Configuring Openfire Integration...2 Viewing the Openfire Admin Console...3
Comp 204: Computer Systems and Their Implementation. Lecture 12: Scheduling Algorithms cont d
Comp 204: Computer Systems and Their Implementation Lecture 12: Scheduling Algorithms cont d 1 Today Scheduling continued Multilevel queues Examples Thread scheduling 2 Question A starvation-free job-scheduling
Multi-core architectures. Jernej Barbic 15-213, Spring 2007 May 3, 2007
Multi-core architectures Jernej Barbic 15-213, Spring 2007 May 3, 2007 1 Single-core computer 2 Single-core CPU chip the single core 3 Multi-core architectures This lecture is about a new trend in computer
Mutual Exclusion using Monitors
Mutual Exclusion using Monitors Some programming languages, such as Concurrent Pascal, Modula-2 and Java provide mutual exclusion facilities called monitors. They are similar to modules in languages that
How To Write A Multi Threaded Software On A Single Core (Or Multi Threaded) System
Multicore Systems Challenges for the Real-Time Software Developer Dr. Fridtjof Siebert aicas GmbH Haid-und-Neu-Str. 18 76131 Karlsruhe, Germany [email protected] Abstract Multicore systems have become
Road Map. Scheduling. Types of Scheduling. Scheduling. CPU Scheduling. Job Scheduling. Dickinson College Computer Science 354 Spring 2010.
Road Map Scheduling Dickinson College Computer Science 354 Spring 2010 Past: What an OS is, why we have them, what they do. Base hardware and support for operating systems Process Management Threads Present:
Chapter 6 Concurrent Programming
Chapter 6 Concurrent Programming Outline 6.1 Introduction 6.2 Monitors 6.2.1 Condition Variables 6.2.2 Simple Resource Allocation with Monitors 6.2.3 Monitor Example: Circular Buffer 6.2.4 Monitor Example:
REAL TIME OPERATING SYSTEMS. Lesson-10:
REAL TIME OPERATING SYSTEMS Lesson-10: Real Time Operating System 1 1. Real Time Operating System Definition 2 Real Time A real time is the time which continuously increments at regular intervals after
Parallel Programming
Parallel Programming 0024 Recitation Week 7 Spring Semester 2010 R 7 :: 1 0024 Spring 2010 Today s program Assignment 6 Review of semaphores Semaphores Semaphoren and (Java) monitors Semaphore implementation
Chapter 5: CPU Scheduling. Operating System Concepts 8 th Edition
Chapter 5: CPU Scheduling Silberschatz, Galvin and Gagne 2009 Chapter 5: CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms Thread Scheduling Multiple-Processor Scheduling Operating
Objectives. Chapter 5: CPU Scheduling. CPU Scheduler. Non-preemptive and preemptive. Dispatcher. Alternating Sequence of CPU And I/O Bursts
Objectives Chapter 5: CPU Scheduling Introduce CPU scheduling, which is the basis for multiprogrammed operating systems Describe various CPU-scheduling algorithms Discuss evaluation criteria for selecting
COS 318: Operating Systems. Semaphores, Monitors and Condition Variables
COS 318: Operating Systems Semaphores, Monitors and Condition Variables Prof. Margaret Martonosi Computer Science Department Princeton University http://www.cs.princeton.edu/courses/archive/fall11/cos318/
Lecture 6: Semaphores and Monitors
HW 2 Due Tuesday 10/18 Lecture 6: Semaphores and Monitors CSE 120: Principles of Operating Systems Alex C. Snoeren Higher-Level Synchronization We looked at using locks to provide mutual exclusion Locks
White Paper. Real-time Capabilities for Linux SGI REACT Real-Time for Linux
White Paper Real-time Capabilities for Linux SGI REACT Real-Time for Linux Abstract This white paper describes the real-time capabilities provided by SGI REACT Real-Time for Linux. software. REACT enables
Tasks Schedule Analysis in RTAI/Linux-GPL
Tasks Schedule Analysis in RTAI/Linux-GPL Claudio Aciti and Nelson Acosta INTIA - Depto de Computación y Sistemas - Facultad de Ciencias Exactas Universidad Nacional del Centro de la Provincia de Buenos
Introduction. Scheduling. Types of scheduling. The basics
Introduction In multiprogramming systems, when there is more than one runable (i.e., ready), the operating system must decide which one to activate. The decision is made by the part of the operating system
CPU Scheduling. CSC 256/456 - Operating Systems Fall 2014. TA: Mohammad Hedayati
CPU Scheduling CSC 256/456 - Operating Systems Fall 2014 TA: Mohammad Hedayati Agenda Scheduling Policy Criteria Scheduling Policy Options (on Uniprocessor) Multiprocessor scheduling considerations CPU
CS423 Spring 2015 MP4: Dynamic Load Balancer Due April 27 th at 9:00 am 2015
CS423 Spring 2015 MP4: Dynamic Load Balancer Due April 27 th at 9:00 am 2015 1. Goals and Overview 1. In this MP you will design a Dynamic Load Balancer architecture for a Distributed System 2. You will
Concurrent Programming
Concurrent Programming Shared Memory Passing the baton Monitors Verónica Gaspes www.hh.se/staff/vero CERES, November 2, 2007 ceres Outline 1 Recap 2 Readers & Writers Readers & writers (mutual exclusion)
CS4410 Final Exam : Solution set. while(ticket[k] && (ticket[k],k) < (ticket[i],i))
1. Bakery Algorithm after optimization: CS4410 Final Exam : Solution set 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 int ticket[n] = 0; boolean choosing[n] = false; void CSEnter(int i) { choosing[i]
Introduction Disks RAID Tertiary storage. Mass Storage. CMSC 412, University of Maryland. Guest lecturer: David Hovemeyer.
Guest lecturer: David Hovemeyer November 15, 2004 The memory hierarchy Red = Level Access time Capacity Features Registers nanoseconds 100s of bytes fixed Cache nanoseconds 1-2 MB fixed RAM nanoseconds
Massachusetts Institute of Technology 6.005: Elements of Software Construction Fall 2011 Quiz 2 November 21, 2011 SOLUTIONS.
Massachusetts Institute of Technology 6.005: Elements of Software Construction Fall 2011 Quiz 2 November 21, 2011 Name: SOLUTIONS Athena* User Name: Instructions This quiz is 50 minutes long. It contains
CSE 120 Principles of Operating Systems. Modules, Interfaces, Structure
CSE 120 Principles of Operating Systems Fall 2000 Lecture 3: Operating System Modules, Interfaces, and Structure Geoffrey M. Voelker Modules, Interfaces, Structure We roughly defined an OS as the layer
Understanding Hardware Transactional Memory
Understanding Hardware Transactional Memory Gil Tene, CTO & co-founder, Azul Systems @giltene 2015 Azul Systems, Inc. Agenda Brief introduction What is Hardware Transactional Memory (HTM)? Cache coherence
A Survey of Parallel Processing in Linux
A Survey of Parallel Processing in Linux Kojiro Akasaka Computer Science Department San Jose State University San Jose, CA 95192 408 924 1000 [email protected] ABSTRACT Any kernel with parallel processing
Secondary Storage. Any modern computer system will incorporate (at least) two levels of storage: magnetic disk/optical devices/tape systems
1 Any modern computer system will incorporate (at least) two levels of storage: primary storage: typical capacity cost per MB $3. typical access time burst transfer rate?? secondary storage: typical capacity
Facing the Challenges for Real-Time Software Development on Multi-Cores
Facing the Challenges for Real-Time Software Development on Multi-Cores Dr. Fridtjof Siebert aicas GmbH Haid-und-Neu-Str. 18 76131 Karlsruhe, Germany [email protected] Abstract Multicore systems introduce
Survey on Job Schedulers in Hadoop Cluster
IOSR Journal of Computer Engineering (IOSR-JCE) e-issn: 2278-0661, p- ISSN: 2278-8727Volume 15, Issue 1 (Sep. - Oct. 2013), PP 46-50 Bincy P Andrews 1, Binu A 2 1 (Rajagiri School of Engineering and Technology,
Kepware Technologies Optimizing KEPServerEX V5 Projects
Kepware Technologies Optimizing KEPServerEX V5 Projects September, 2010 Ref. 50.16 Kepware Technologies Table of Contents 1. Overview... 1 2. Factors that Affect Communication Speed... 1 2.1 Defining Bandwidth...
Main Points. Scheduling policy: what to do next, when there are multiple threads ready to run. Definitions. Uniprocessor policies
Scheduling Main Points Scheduling policy: what to do next, when there are multiple threads ready to run Or multiple packets to send, or web requests to serve, or Definitions response time, throughput,
Programming real-time systems with C/C++ and POSIX
Programming real-time systems with C/C++ and POSIX Michael González Harbour 1. Introduction The C language [1], developed in 1972 by Dennis Ritchie at the Bell Telephone Laboratories, is the most widely
Chapter 2: OS Overview
Chapter 2: OS Overview CmSc 335 Operating Systems 1. Operating system objectives and functions Operating systems control and support the usage of computer systems. a. usage users of a computer system:
napp-it ZFS Storage principles for Video Performance Dual Xeon, 40 GB RAM Intel X540, mtu 9000 (JumboFrames) Server OS: Oracle Solaris 11.3 SMB 2.
napp-it ZFS Storage principles for Video Performance Server: Dual Xeon, 40 GB RAM Intel X540, mtu 9000 (JumboFrames) Server OS: Oracle Solaris 11.3 SMB 2.1 OmniOS 151017 bloody SMB 2.1 Client OS: MacPro
Event processing in Java: what happens when you click?
Event processing in Java: what happens when you click? Alan Dix In the HCI book chapter 8 (fig 8.5, p. 298), notification-based user interface programming is described. Java uses this paradigm and you
These sub-systems are all highly dependent on each other. Any one of them with high utilization can easily cause problems in the other.
Abstract: The purpose of this document is to describe how to monitor Linux operating systems for performance. This paper examines how to interpret common Linux performance tool output. After collecting
Multi-core Programming System Overview
Multi-core Programming System Overview Based on slides from Intel Software College and Multi-Core Programming increasing performance through software multi-threading by Shameem Akhter and Jason Roberts,
Operating Systems. III. Scheduling. http://soc.eurecom.fr/os/
Operating Systems Institut Mines-Telecom III. Scheduling Ludovic Apvrille [email protected] Eurecom, office 470 http://soc.eurecom.fr/os/ Outline Basics of Scheduling Definitions Switching
VEEAM ONE 8 RELEASE NOTES
VEEAM ONE 8 RELEASE NOTES This Release Notes document provides last-minute information about Veeam ONE 8 Update 2, including system requirements, installation instructions as well as relevant information
Chapter 1 FUNDAMENTALS OF OPERATING SYSTEM
Chapter 1 FUNDAMENTALS OF OPERATING SYSTEM An operating system is a program that acts as an intermediary between a user of a computer and the computer hardware. The purpose of an operating system is to
CPU Scheduling. Core Definitions
CPU Scheduling General rule keep the CPU busy; an idle CPU is a wasted CPU Major source of CPU idleness: I/O (or waiting for it) Many programs have a characteristic CPU I/O burst cycle alternating phases
OPERATING SYSTEMS SCHEDULING
OPERATING SYSTEMS SCHEDULING Jerry Breecher 5: CPU- 1 CPU What Is In This Chapter? This chapter is about how to get a process attached to a processor. It centers around efficient algorithms that perform
Announcements. Basic Concepts. Histogram of Typical CPU- Burst Times. Dispatcher. CPU Scheduler. Burst Cycle. Reading
Announcements Reading Chapter 5 Chapter 7 (Monday or Wednesday) Basic Concepts CPU I/O burst cycle Process execution consists of a cycle of CPU execution and I/O wait. CPU burst distribution What are the
POSIX. RTOSes Part I. POSIX Versions. POSIX Versions (2)
RTOSes Part I Christopher Kenna September 24, 2010 POSIX Portable Operating System for UnIX Application portability at source-code level POSIX Family formally known as IEEE 1003 Originally 17 separate
Java Memory Model: Content
Java Memory Model: Content Memory Models Double Checked Locking Problem Java Memory Model: Happens Before Relation Volatile: in depth 16 March 2012 1 Java Memory Model JMM specifies guarantees given by
