Timers

4,411 views

Published on

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
4,411
On SlideShare
0
From Embeds
0
Number of Embeds
2,719
Actions
Shares
0
Downloads
0
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Timers

  1. 1. Timers © 2010 Anil Kumar Pugalia <email@sarika-pugs.com> All Rights Reserved.
  2. 2. What to Expect? Alarm based Trivial Timer Interval Timers based on other Signals © 2010 Anil Kumar Pugalia <email@sarika-pugs.com> 2 All Rights Reserved.
  3. 3. Trivial Timer Based on the alarm signal (SIGALRM) One Timer per Process Timer resolution is in seconds Activated using the alarm() system call Any subsequent calls to alarm cancels the previous ones, if not already triggered Triggered after seconds specified in last alarm() call SIGALRM handler is the timer handler One shot behaviour, unless activated again © 2010 Anil Kumar Pugalia <email@sarika-pugs.com> 3 All Rights Reserved.
  4. 4. Other User Space Timers Based on Interval Timers Total of three timers possible per Process ITIMER_REAL (Based on real time) – SIGALRM ITIMER_VIRTUAL (Based on execution time) – SIGVTALRM ITIMER_PROF (Based on overall execution time) – SIGPROF Timer Resolution is in micro seconds Though expiry may be a little later Activated using setitimer system call And can be queried using gettimer system call Triggered Periodically, every interval, after current value As specified in the setitimer call From the call to setitimer © 2010 Anil Kumar Pugalia <email@sarika-pugs.com> 4 All Rights Reserved.
  5. 5. Other User Space Timers ... POSIX.1-2008 marks the setitimer / getitimer calls obsolete Rather recommends the following timer_settime, timer_gettime timer_create, timer_delete timer_getoverrun With these, many more interval timers could be used Using signals other than the 3 usual ones Also including the real-time signals © 2010 Anil Kumar Pugalia <email@sarika-pugs.com> 5 All Rights Reserved.
  6. 6. What all have we learnt? Alarm based Trivial Timer Interval Timers based on other Signals © 2010 Anil Kumar Pugalia <email@sarika-pugs.com> 6 All Rights Reserved.
  7. 7. Any Queries? © 2010 Anil Kumar Pugalia <email@sarika-pugs.com> 7 All Rights Reserved.

×