Timers: Difference between revisions

From COMP15212 Wiki
gravatar Yuron [userbureaucratinterface-adminsysopPHRhYmxlIGNsYXNzPSJ0d3BvcHVwIj48dHI+PHRkIGNsYXNzPSJ0d3BvcHVwLWVudHJ5dGl0bGUiPkdyb3Vwczo8L3RkPjx0ZD51c2VyPGJyIC8+YnVyZWF1Y3JhdDxiciAvPmludGVyZmFjZS1hZG1pbjxiciAvPnN5c29wPGJyIC8+PC90ZD48L3RyPjwvdGFibGU+] (talk | contribs)
m (1 revision imported)
pc>Yuron
No edit summary
Line 1: Line 1:
{{#set: Priority=1 | Summary=An example I/O peripheral.}}<!--
{{#set: Priority=1 | Summary=An example I/O peripheral.}}<!--
-->{{#invoke:Dependencies|add|Peripheral devices,4}}
-->{{#invoke:Dependencies|add|Peripheral devices,4}}
A timer is quite a simple hardware device; a typical computer will
A timer is quite a simple hardware device; a typical computer will have several timers available.  Although they have no <em>physical</em> input or output wires, timers are still classed as [[IO|I/O]] devices and are handled in a similar manner.  Although a timer may be read explicitly, they typically do most of their work by providing [[interrupts]].
have several timers available.  Although they have no <em>physical</em> input
or output wires, timers are still classed as [IO I/O] devices and are
handled in a similar manner.  Although a timer may be read explicitly,
they typically do most of their work by providing
[[interrupts]].


Timers can have different characteristics.  As far as this module is
Timers can have different characteristics.  As far as this module is concerned there may be two useful forms of timer:
concerned there may be two useful forms of timer:


*Free running – continuously operating, providing interrupts at regularly spaced (typically preprogrammed) intervals. A typical use would be tracking & measuring elapsed time or maintaining the ‘time-of-day’.
*Free running – continuously operating, providing interrupts at regularly spaced (typically preprogrammed) intervals. A typical use would be tracking & measuring elapsed time or maintaining the ‘time-of-day’.
*One shot – provides a single interrupt after a preprogrammed delay.<br /> May be used for <em>time-slicing</em> – particularly if each process may be given a different length time-slice according (for example) to its priority.
*One shot – provides a single interrupt after a preprogrammed delay.<br /> May be used for <em>time-slicing</em> – particularly if each process may be given a different length time-slice according (for example) to its priority.


At some resolution, the latter can be provided by the former by
At some resolution, the latter can be provided by the former by counting pulses, if need be.
counting pulses, if need be.


==== Typical timer jobs ====
==== Typical timer jobs ====
Line 24: Line 17:
*Pre-emptive time-slicing (when applicable)
*Pre-emptive time-slicing (when applicable)


A [[Real_Time|real-time]] embedded system may also contain a special
A [[Real_Time|real-time]] embedded system may also contain a special [[Watchdog|watchdog timer]] which is there to [[reset]] the system if it appears to have crashed.
[[Watchdog|watchdog timer]] which is there to [[reset]] the
system if it appears to have crashed.
----
----
 
{{BookChapter|1.4.3, 12.3.3|26-27, 505-506}}
{{PageGraph}}
{{PageGraph}}
{{Category|IO}}
{{Category|IO}}

Revision as of 14:15, 4 August 2019

Depends on Peripheral devices

A timer is quite a simple hardware device; a typical computer will have several timers available. Although they have no physical input or output wires, timers are still classed as I/O devices and are handled in a similar manner. Although a timer may be read explicitly, they typically do most of their work by providing interrupts.

Timers can have different characteristics. As far as this module is concerned there may be two useful forms of timer:

  • Free running – continuously operating, providing interrupts at regularly spaced (typically preprogrammed) intervals. A typical use would be tracking & measuring elapsed time or maintaining the ‘time-of-day’.
  • One shot – provides a single interrupt after a preprogrammed delay.
    May be used for time-slicing – particularly if each process may be given a different length time-slice according (for example) to its priority.

At some resolution, the latter can be provided by the former by counting pulses, if need be.

Typical timer jobs

  • Maintaining a simple, software clock
  • Rescheduling sleeping processes
  • Monitoring performance/behaviour; profiling
    e.g. noting the time spent ‘idle’ for top etc.
  • Pre-emptive time-slicing (when applicable)

A real-time embedded system may also contain a special watchdog timer which is there to reset the system if it appears to have crashed.


Also refer to: Operating System Concepts, 10th Edition: Chapter 1.4.3, 12.3.3, pages 26-27, 505-506


Articles on IO
Cacheability • Device Drivers • Direct Memory Access (DMA) • IO • Interprocess Communication • Interrupt Controller • Interrupt Service Routines (ISRs) • Interrupts • Libraries • Peripheral devices • Pipes • Queues • Queues Extra • Resources • Shell • Sockets • Spooling and Buffering • Starvation • Streams • System Calls • Thrashing • Timers • Using Peripherals • Virtualisation • Write Buffer