Time Management.  Time management is concerned with OS facilities and services which measure real time, and is essential to the operation of timesharing.

Slides:



Advertisements
Similar presentations
Computer-System Structures Er.Harsimran Singh
Advertisements

Chapter 3 Process Description and Control
Lecture 11: Operating System Services. What is an Operating System? An operating system is an event driven program which acts as an interface between.
Operating Systems Input/Output Devices (Ch , 12.7; , 13.7)
OS2-1 Chapter 2 Computer System Structures. OS2-2 Outlines Computer System Operation I/O Structure Storage Structure Storage Hierarchy Hardware Protection.
Figure 2.8 Compiler phases Compiling. Figure 2.9 Object module Linking.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 2: Computer-System Structures Computer System Operation I/O Structure Storage.
Introduction to Operating Systems – Windows process and thread management In this lecture we will cover Threads and processes in Windows Thread priority.
I/O Hardware n Incredible variety of I/O devices n Common concepts: – Port – connection point to the computer – Bus (daisy chain or shared direct access)
Advanced OS Chapter 3p2 Sections 3.4 / 3.5. Interrupts These enable software to respond to signals from hardware. The set of instructions to be executed.
Computer System Structures memory memory controller disk controller disk controller printer controller printer controller tape-drive controller tape-drive.
1 Operating Systems Ch An Overview. Architecture of Computer Hardware and Systems Software Irv Englander, John Wiley, Bare Bones Computer.
Timers and Interrupts Shivendu Bhushan Summer Camp ‘13.
Operating Systems Input/Output Devices (Ch 5: )
General System Architecture and I/O.  I/O devices and the CPU can execute concurrently.  Each device controller is in charge of a particular device.
8254 Programmable Interval Timer
8254 Counter/Timer Counter Each of the three counter has 3 pins associated CLK: input clock frequency- 8 MHz OUT GATE: Enable (high) or disable.
1 Computer System Overview Chapter 1. 2 n An Operating System makes the computing power available to users by controlling the hardware n Let us review.
Implementing Processes and Process Management Brian Bershad.
2.1 Silberschatz, Galvin and Gagne ©2003 Operating System Concepts with Java Chapter 2: Computer-System Structures Computer System Operation I/O Structure.
CHAPTER 2: COMPUTER-SYSTEM STRUCTURES Computer system operation Computer system operation I/O structure I/O structure Storage structure Storage structure.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 2: Computer-System Structures Computer System Operation I/O Structure Storage.
Chapter 2: Computer-System Structures
1 CSE Department MAITSandeep Tayal Computer-System Structures Computer System Operation I/O Structure Storage Structure Storage Hierarchy Hardware Protection.
2: Computer-System Structures
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.
The Functions of Operating Systems Interrupts. Learning Objectives Explain how interrupts are used to obtain processor time. Explain how processing of.
Lecture 3 Process Concepts. What is a Process? A process is the dynamic execution context of an executing program. Several processes may run concurrently,
CE Operating Systems Lecture 11 Windows – Object manager and process management.
Device Drivers CPU I/O Interface Device Driver DEVICECONTROL OPERATIONSDATA TRANSFER OPERATIONS Disk Seek to Sector, Track, Cyl. Seek Home Position.
Timer Timer is a device, which counts the input at regular interval (δT) using clock pulses at its input. The counts increment on each pulse and store.
Operating Systems Lecture November 2015© Copyright Virtual University of Pakistan 2 Agenda for Today Review of previous lecture Hardware (I/O, memory,
Operating System Structure A key concept of operating systems is multiprogramming. –Goal of multiprogramming is to efficiently utilize all of the computing.
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.
CE Operating Systems Lecture 2 Low level hardware support for operating systems.
Operating Systems 1 K. Salah Module 1.2: Fundamental Concepts Interrupts System Calls.
1 CS.217 Operating System By Ajarn..Sutapart Sappajak,METC,MSIT Chapter 2 Computer-System Structures Slide 1 Chapter 2 Computer-System Structures.
O PERATING S YSTEM. What is an Operating System? An operating system is an event driven program which acts as an interface between a user of a computer,
Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, Operating System Concepts Operating Systems Lecture 4 Computer Systems Review.
Silberschatz, Galvin and Gagne  Applied Operating System Concepts Chapter 2: Computer-System Structures Computer System Architecture and Operation.
Processes, Threads, and Process States. Programs and Processes  Program: an executable file (before/after compilation)  Process: an instance of a program.
CE Operating Systems Lecture 2 Low level hardware support for operating systems.
Time Management.  Time management is concerned with OS facilities and services which measure real time.  These services include:  Keeping track of.
Chapter 2: Computer-System Structures(Hardware)
Chapter 2: Computer-System Structures
Data Structures Using C, 2e
Interrupts and signals
Protection of System Resources
Programmable Interval Timer
Programmable Interval Timer
Programmable Interval Timer 8254 LECTURE 3
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 2: Computer-System Structures Computer System Operation I/O Structure Storage.
Real-time Software Design
Computer System Overview
Computer-System Architecture
Module 2: Computer-System Structures
Programmable Interval timer 8253 / 8254
Processor Fundamentals
Programmable Interval timer 8253 / 8254
Operating Systems Lecture 3.
Module 2: Computer-System Structures
8253 – PROGRAMMABLE INTERVAL TIMER (PIT). What is a Timer? Timer is a specialized type of device that is used to measure timing intervals. Timers can.
Chapter 13: I/O Systems I/O Hardware Application I/O Interface
Chapter 2: Computer-System Structures
Chapter 2: Computer-System Structures
Module 2: Computer-System Structures
Contact Information Office: 225 Neville Hall Office Hours: Monday and Wednesday 12:00-1:00 and by appointment. Phone:
Module 2: Computer-System Structures
Presentation transcript:

Time Management

 Time management is concerned with OS facilities and services which measure real time, and is essential to the operation of timesharing systems.  These services include:  Keeping track of the time of day, and current date  Measuring the time used by various activities and processes, such as keeping one process from monopolizing the CPU.  Starting and stopping activities at specific times  Time management centers around processing interrupts generated by hardware clocks.

 A hardware clock is:  Is a physical device which measures time.  Causes periodic interrupts either at specific intervals, or upon the expiration of a preset time interval, and may need to be reset  Control of clocks can be provided via software using a clock driver, interrupt handlers, and timer management routines.  Since it is impossible to have a physical clock for each type of event that must be timed, multiple software/virtual clocks can be based on the same physical clock.

Physical clocks  Physical clocks generate precisely timed electronic pulses that synchronize the other components of the computer system, by periodically generating interrupts at a KNOWN frequency.  Line clocks: Simplest type of clock. They interrupt at a frequency that is based on that of the electric power line voltage cycle on which the computer is operating. In the US this is 50 or 60 Hertz, and the line clock would generate an interrupt every 1/60th of a second. A clock driver can then be used to interpret this interrupt and update software clocks appropriately.

Physical clocks  Programmable clocks: These clocks have 3 components: a crystal oscillator, a counter and a holding register. The oscillator generates a periodic signal, which is fed to the counter to make it count down to zero. When the value contained in this register reaches 0 then an interrupt is generated.  Programmable clocks typically have multiple modes of operation and can either interrupt once (one-shot mode) and stop until explicitly started again by software, or in (square wave mode) where after getting to zero and interrupting the contents of the holding register is automatically copied back into the counter register. The frequency of the interrupts for this type of clock can be set by software by setting the contents of the counter.  Several OS services are based on the predictable beat of a clock tick, such as the beginning of the next fetch/execute cycle.  Multiple software clocks can be defined for a single hardware clock to provide specific services: Time of Day, etc.

Clock Drivers  Clock interrupts are processed by software not unlike device drivers.  Service routines to read and modify the value or behavior of both hardware and virtual/software clocks. Synchronizing system and backup clocks.  Deal with interrupts that represent clock ticks. Interpret the clock ticks to update software clocks

Time of Day services  One of the responsibility of time management is to provide date and time of day services!  To do this the system must record the current date and time and provide this information (in a variety of ways) upon request.

Clock_Interrupt:save registers increment Time_Of_Day_Clock IF Time_Of_Day_Clock > 24 hours THEN IF Time_Of_Day_Clock > 24 hours THEN set Time_of_Day_Clock to 0 advance date ENDIF restore registers restore registers RETURN from interrupt RETURN from interrupt Based on the # of clock ticks in 1 day

Clock_Interrupt:save registers increment #_of_ticks_Counter IF #_of_ticks_Counter > 1 second THEN IF #_of_ticks_Counter > 1 second THEN Set #_of_ticks_counter to 0 Advance second_counter If second_counter > 24 hours then Set second_counter to 0 Advance date Endifendif restore registers restore registers RETURN from interrupt RETURN from interrupt Based on the # of clock ticks in 1 second

 When the current date or time is requested the time is translated into the number of seconds since 12AM, on Jan 1, 1970 for Unix, or Jan  This is translated into the current date and time.  Usually a separate counter is maintained for the current date, which is then incremented when a full 24 hours has past.

Other types of services  providing "watchdog" or monitoring timers for systems processes and expected events. (such as a wakeup call that is set each time a hard disk controller is sent a command. If the command fails, the expiration of the timer will indicate the problem. )  providing suspension of a process for a specified interval (pause for 30 minutes)  providing suspension of a process until a specific time of day  providing for the startup of a process at a specific time of day  providing for timing of expected events and asynchronous execution of procedures upon expiration of the interval (timeouts)  providing for cancellation of previous timer requests  Accounting for CPU usage

Timer Queues  Like a process queue, a timer queue is implemented to keep track of timing requests generated either by individual processes or the OS itself  This queue holds a set of logical timers (software clocks0) allocated to processes or system services. When the time in these logical timers expires an event is triggered.  These system must keep track of these timers, and one solution is to maintain an ordered linked list of timing requests

Contents of the timer queue element:  Pointers to the next (and previous element)  Time quantum  Link to the PCB of requesting process  Address of a procedure to call (representing the action to perform)  Type of request (user or OS)

 With each clock interrupt the clock driver has several things to do: incrementing the real time, decrementing the time quantum in timer requests, check for zero (any timer elements who’s counter has reached zero, and doing CPU accounting.  It is vital that each of these operations be arranged so that they are very fast, since they have to be repeated many times a second.  Let’s consider a timer queue….There are several ways the time stored in the first element can be manipulated….

8430 Current time * 8437 A * 8442 B * 8450 C * 8453 D * 8457 E * 8467 F PCB Front of queue When the current time matches the “time” stored in the first timer element, the event associated with that element is performed, a timer element will also contain a link to a PCB associated with the event, and an address of a routine that is to be executed to perform the event. Time stored as a “real” time the event is to occur

TIMER “Q” SEARCH: SET P TO THE TOP_TQE(timer queue element) DO WHILE TIME_OF_DAY_CLOCK >= P->TQE_TOD SCHEDULE ACTION OF P->TQE SET P TO NEXT TQE ENDWHILE SET TOP_TQE POINTER TO TQE POINTED TO BY P RETURN

Storing Intervals in elements 8430 Current time * 7 A * 5 B * 8 C * 3 D * 4 E * 10 F Front of queue Request for 8437, Request for 8442, Request for 8450 The event associated with the first TQE is to occur in 7 ticks from the current time. Time stored in later elements as based on the elements in front of it.

* 7 A * 0 B * 0 C * 3 D * 4 E * 10 F Front of queue 8430 Current time Request for 8437, Request for 8440, If multiple events are to occur at the same time, the time value of subsequent elements is zero.

Programmable clock 730 # of clock ticks until the event is to be triggered Timer Queue Head * 730 A * 405 B Programmable clock 685 Timer Queue Head * 730 A * 405 B Time can be stored in a programmable clock The time stored in the programmable clock would be decremented based on the rate of that clock.

 Adding new elements into the timer queue can require adjustments to other TQEs …

Programmable clock 685 Timer Queue Head * 730 A * 405 B A new request arrives for a time interval of 457 Programmable clock 457 Timer Queue Head * 405 B * 228 A * 457 C Timer interval in A reset to the time remaining in the programmable clock, minus the time interval of the new event.

Adding new timing requests  Determining the time interval for the new element  Searching the queue until an element is found whose event should occur after the time interval for the new element.  Inserting the new element into the queue  Adjusting the time interval of the element, in front of which the new element has been inserted.

Current time= 8430 Timerq_head 18 G 7 A 5 B 8 C 3 D 4 E 10 F For a queue where each element contains a time that is an interval from the current time. Element C is to occur in 20 ticks…

Current time= 8430 Timerq_ head 7 A 5 B 6 G 2 (8) C 3 D 4 E 10 F We insert G between elements b and c and adjust times in later elements to reflect the addition

Deleting element C Current time= 8430 Timerq_ head 7 A 5 B 6 G 2 C 3 D 4 E 10 F 5 D 4 E F Deleting elements also require adjustments. When an element is deleted the times in later elements must be increased.

Timing issues:  The time spent processing a clock interrupt is critical to the accuracy of the timing facility within an OS.  We must update the hardware clock as quickly as possible  Must be the highest priority interrupt if clock ticks are to be counted accurately.  Ability to block all but clock interrupts will allow critical work to be done, but still maintaining the accuracy of the clock