4061 Session 17 (3/19). Today Time in UNIX Today’s Objectives Define what is meant when a system is called “interrupt-driven” Describe some trade-offs.

Slides:



Advertisements
Similar presentations
Time Measurement Topics Time scales Interval counting Cycle counters K-best measurement scheme time.ppt CS 105 Tour of Black Holes of Computing.
Advertisements

System Integration and Performance
Real-Time Library: RTX
CS 6560 Operating System Design Lecture 7: Kernel Synchronization Kernel Time Management.
The Process Control Block From: A Process Control Block (PCB, also called Task Control Block or Task Struct) is.
BFS: Brain F*ck Scheduler Jacob Chan. Objectives  Brain F*ck Scheduling  What it is  How it works  Features  Scalability  Limitations  Definition.
Effects of Clock Resolution on the Scheduling of Interactive and Soft Real- Time Processes by Yoav Etsion, Dan Tsafrir, Dror G. Feitelson Presented by.
1 Traditional Unix Scheduling “Traditional” means –No consideration on realtime processes. –Typically 4.3BSD and SVR3 MFQ-based –Preemptive (time quantum.
1 Lecture 6 Performance Measurement and Improvement.
1 Soft Timers: Efficient Microsecond Software Timer Support For Network Processing Mohit Aron and Peter Druschel Rice University Presented By Jonathan.
Time Measurement October 25, 2001 Topics Time scales Interval counting Cycle counters K-best measurement scheme class18.ppt.
Double buffer SDRAM Memory Controller Presented by: Yael Dresner Andre Steiner Instructed by: Michael Levilov Project Number: D0713.
UC Berkeley 1 Time dilation in RAMP Zhangxi Tan and David Patterson Computer Science Division UC Berkeley.
COMS W6998 Spring 2010 Erich Nahum
Chapter 4 Processor Technology and Architecture. Chapter goals Describe CPU instruction and execution cycles Explain how primitive CPU instructions are.
Chapter 4 Assessing and Understanding Performance
Signal Signal : - is a notification sent to a process to notify it of some event - interrupts whatever the process is doing and force it to handle a signal.
1 Today I/O Systems Storage. 2 I/O Devices Many different kinds of I/O devices Software that controls them: device drivers.
Week 8 - Friday.  What did we talk about last time?  String to int conversions  Users and groups  Password files.
1 Physical Clocks need for time in distributed systems physical clocks and their problems synchronizing physical clocks u coordinated universal time (UTC)
Signals & Timers CS241 Discussion Section Spring 2009 Week 6.
Linux Scheduling CS Scheduling Policy ► The scheduling algorithm of traditional Unix systems must fulfill several conflicting objectives  Fast.
GPS based time synchronization of PC hardware Antti Gröhn
Chapter 4 Storage Management (Memory Management).
10/19/2015Erkay Savas1 Performance Computer Architecture – CS401 Erkay Savas Sabanci University.
4061 Session 15 (3/6). Today More about signals A (relevant) aside Quiz review.
Performance.
Computer Systems Week 7: Looping and Input/Output with 3-bit Alma Whitfield.
Copyright ©: Nahrstedt, Angrave, Abdelzaher1 Timers and Clocks.
Time Management.  Time management is concerned with OS facilities and services which measure real time, and is essential to the operation of timesharing.
Ted Pedersen – CS 3011 – Chapter 10 1 A brief history of computer architectures CISC – complex instruction set computing –Intel x86, VAX –Evolved from.
Cpr E 308 Spring 2005 Process Scheduling Basic Question: Which process goes next? Personal Computers –Few processes, interactive, low response time Batch.
1 Soft Timers: Efficient Microsecond Software Timer Support For Network Processing Mohit Aron and Peter Druschel Rice University Presented By Oindrila.
Lecture 6 Page 1 CS 111 Online Preemptive Scheduling Again in the context of CPU scheduling A thread or process is chosen to run It runs until either it.
Copyright ©: Nahrstedt, Angrave, Abdelzaher, Caccamo1 Timers and Clocks II.
CE Operating Systems Lecture 2 Low level hardware support for operating systems.
Copyright ©: Nahrstedt, Angrave, Abdelzaher, Caccamo1 Timers and Clocks.
Lecture 2a: Performance Measurement. Goals of Performance Analysis The goal of performance analysis is to provide quantitative information about the performance.
Processor Structure and Function Chapter8:. CPU Structure  CPU must:  Fetch instructions –Read instruction from memory  Interpret instructions –Instruction.
1 Virtual Memory. Cache memory: provides illusion of very high speed Virtual memory: provides illusion of very large size Main memory: reasonable cost,
September 10 Performance Read 3.1 through 3.4 for Wednesday Only 3 classes before 1 st Exam!
Lecture 5: 9/10/2002CS170 Fall CS170 Computer Organization and Architecture I Ayman Abdel-Hamid Department of Computer Science Old Dominion University.
Timing Tutorial #5 CPSC 261. Clocks Most computer systems have a number of clocks – Give time signals to the pipeline and memory Tick at 2.67 GHz (or.
Time Management.  Time management is concerned with OS facilities and services which measure real time.  These services include:  Keeping track of.
Time Sources and Timing David Ferry, Chris Gill CSE 522S - Advanced Operating Systems Washington University in St. Louis St. Louis, MO
Announcements Assignment 2 Out Today Quiz today - so I need to shut up at 4:25 1.
Week 9 - Wednesday.  What did we talk about last time?  structs.
Ch6. Flow of Time Ch7. Getting Hold of Memory 홍원의.
Measuring Time Alan L. Cox Some slides adapted from CMU slides.
Soft Timers : Efficient Microsecond Software Timer Support for Network Processing - Mohit Aron & Peter Druschel CS533 Winter 2007.
Measuring Performance Based on slides by Henri Casanova.
Timers and Time Management Ok-Kyun Ha
Threads prepared and instructed by Shmuel Wimer Eng. Faculty, Bar-Ilan University 1July 2016Processes.
Mohit Aron Peter Druschel Presenter: Christopher Head
Copyright ©: Nahrstedt, Angrave, Abdelzaher, Caccamo
Performance Analysis Tools
Yoav Etsion, Dan Tsafrir, Dror G. Feitelson
Defining Performance Which airplane has the best performance?
Chapter 5a: CPU Scheduling
Time Sources and Timing
Week 9 - Wednesday CS222.
Mechanism: Limited Direct Execution
Presented by Kristen Carlson Accardi
CS490 Windows Internals Quiz 2 09/27/2013.
Time Sources and Timing
Interrupt handling Explain how interrupts are used to obtain processor time and how processing of interrupted jobs may later be resumed, (typical.
Time Sources and Timing
Operating Systems CMPSC 473
Performance.
Chapter 13: I/O Systems “The two main jobs of a computer are I/O and [CPU] processing. In many cases, the main job is I/O, and the [CPU] processing is.
Presentation transcript:

4061 Session 17 (3/19)

Today Time in UNIX

Today’s Objectives Define what is meant when a system is called “interrupt-driven” Describe some trade-offs in setting the timer interrupt frequency Write programs that format time values, measure time intervals, and utilize high- precision or interval timers

Admin Remember - Homework 3 is due a week from Wed. Quiz 3 Results, overview, questions –Grading questions: Qiang #2/4, Riea #1/3

Time in Perspective 1 second (s) == 1,000 milliseconds (ms) == 1,000,000 microseconds (μs) Million Instructions Per Second (MIPS) –A measure of *peak* CPU speed (not comparable across architectures...) –1992: Intel 486DX (66 MHz) - 54 MIPS –2006: Intel Core 2 Extreme QX6700 (3.33 GHz) MIPS Thus, 57,063,000,000 instructions per second, or 57,063 instructions per microsecond

Interrupt-Driven Systems have a “heartbeat” –Every so often, a timer interrupts whatever is happening, and the OS determines what to do next (e.g. scheduling) The period between beats is known as a “jiffy” –Increment a kernel-internal value (jiffies) every timer interrupt. The timer interrupt is the default scheduling quantum –All other timers are based on jiffies. –The timer interrupt rate (and jiffy increment rate) is defined by a compile-time constant called HZ

Tuning Older linux kernels on Intel: 10 ms (1/100 s, 100 Hz) –10 ms == 10,000 μs –up to 570,630,000 instructions per jiffy on really fast HW Newer linux kernels on Intel: 4 ms (1/250 s, 250 Hz) For a few revisions, kernels were set to 1 ms. Deemed too short. Why?

Timer Interrupt Frequency Higher frequency leads to: –(+) better latency –(+) more timer granularity –(+) better performance for poll()/select() –(-) overhead (lower throughput) “jiffie wraparound” bug: system uptime clock –32 bits, 100 jiffies per second = 497 days –(they fixed by moving to 64 bit storage)

Notes Note: timeslice != jiffy –Scheduling is implemented by checking against the jiffy counter, but the length of a quantum can be longer than one jiffy vmstat 1: look at interrupts per second –On an idle system, can get a feel for timer Hz –in: interrupts in last second –cs: context switches in last second

Timers and Jiffies We’re going to be talking about timers today –e.g. How sleep(10) is implemented Keep in mind that without special kernel modifications timers can be no more accurate than the length of the jiffy –These special kernel modifications are written, and will likely be put in the linux mainline code soon

Time and Timers An alarm is a signal that is delivered to a process after a time interval. The resolution of a clock is the minimum interval that can be represented. The accuracy of a clock is its difference from some generally-accepted standard. Time interval measurements are available for –wall-clock time, –user-mode runtime, –kernel-mode runtime, and –user-mode and kernel-mode runtime for children

Getting the Time From the command line with date, in a variety of formats, in any timezone. time_t time(time_t *tm) –This gives you the "time since epoch" in seconds. –Returns and (optionally) stores result in tm. Accurate computation of long time intervals is not possible, because Unix time ignores leap seconds.

Y2K, Unix-style time_t datatype used to store seconds since Jan 1, 1970 time_t was originally a 32 bit signed long This number wraps (the highest-order bit is set to 1) during the year 2038, indicating a time *before* this is only a problem for 32 bit systems (changing these systems to use 64 bit longs is hard) –Will there be any 32 bit systems left in 2038?

From Wikipedia Using a (signed) 64-bit value introduces a new wraparound date in about 290 billion years, on Sunday, December 4, 292,277,026,596. The 128-bit Unix time resets later, on December 31, 17,014,118,346,046,923,173,168,730,371,588,4 10. However, these are not widely regarded as pressing issues.

Higher-precision Times int gettimeofday(struct timeval *tv, struct timezone *tz); struct timeval { time_t tv_sec; /* seconds */ suseconds_t tv_usec; /* microseconds */ }; This gives you the time with microsecond resolution, but not microsecond accuracy. The tz value is ignored. Just use NULL.

NTP Many network algorithms require (reasonably) accurate comparison of times across a network. How do I know that both machines are set correctly? Network-connected machines can achieve millisecond accuracy with the network time protocol NTP.

Time Formatting Given a time value, there are two steps to getting a human-readable string representing the time. –Break the time down into parts: seconds, minutes, hours, month, year. See man ctime. –Convert the broken-down time into a string. –Set time zone info in tzname, timezone. Many of these functions use static data. –If you call ctime() or gmtime() a second time, the results from the first call may be gone. –There are "thread-safe" versions of these, eg. ctime_r(), but they still use static locations for timezone info.

Sleep and Alarm The alarm(m) call causes SIGALRM to be sent to your process after m seconds. The sleep(m) call uses SIGALRM to pause your process. A higher-precision way to get your process to pause: –int nanosleep(const struct timespec *req, struct timespec *rem); req is the desired pause time. If interrupted, rem is the remaining unused time.

Process Pauses nanosleep() has different behaviors –Delay <= 2 ms: busy loop (no signals!) –Delay > 2 ms: implemented like sleep() The BSD version is called usleep(usec) –This is considered obsolete in Linux. –From the standpoint of simplicity, portability, and efficiency, nanosleep() is almost always the best choice.

Interval Timers Each process has a set of interval timers available. You can set them to send a periodic signal, based on passage of real time, or runtime. Use getitimer(...) and setitimer(...)

Interval Timers (2) The three interval timers: –ITIMER_REAL decrements in real time delivers SIGALRM –ITIMER_VIRTUAL decrements only when the process is executing delivers SIGVTALRM –ITIMER_PROF decrements both when the process executes and when the system is executing on behalf of the process. delivers SIGPROF Each has a current value, and an “interval” If the interval > 0, then the timer will restart

Measuring Runtime The system keeps track of time spent in user and kernel, for a process and its children. –clock_t times(struct tms *buffer); Returns accumulated runtime.