ADC Home > Reference Library > Technical Notes > Legacy Documents > Mac OS 9 & Earlier >

Legacy Documentclose button

Important: This document is part of the Legacy section of the ADC Reference Library. This information should not be used for new development.

Current information on this Reference Library topic can be found here:

Time Manager Q&As

CONTENTS

This Technical Note contains a collection of archived Q&As relating to a specific topic - questions sent the Developer Support Center (DSC) along with answers from the DSC engineers. Current Q&As can be found on the Macintosh Technical Q&As web site.

[Oct 01 1990]






Time Manager and calculating >24-hour elapsed times

Date Written: 7/23/92

Last reviewed: 6/14/93

I'm trying to use the Macintosh Time Manager to calculate elapsed times, but when I increase the delay time from $4FFFFFF to $5FFFFFF I get incorrect results. Why is this happening?

There seems to be an undocumented limitation of the Time Manager: it can't keep track of times longer than about a day, so it replaces them with the maximum time it supports. For Time Manager tasks, this isn't crippling; the task simply executes earlier than expected. When used for elapsed-time calculations, however, it's a bad thing; the Time Managerinstalls the task with the smaller time, and when you remove it, you see a smaller than expected remaining time. This makes it appear as if a large period of time has passed.

The value at which the Time Manager trims is approximately $53A8FE5. The reason for this strange value is somewhat complex. The Time Manager uses a VIA timer to do its measurement. This timer runs at 783360 Hz, giving it a resolution of about 1.276 microseconds. However, the Macintosh could never actually provide this kind of accuracy, given its latencies and overhead. Also, this frequency would have given a 32-bit counter a range of only about 91 minutes. Therefore, the Time Manager actually throws away the low four bits of this counter, keeping a 32-bit counter with a resolution of 20.425 microseconds and a range of 24 hours, 22 minutes. This time is a lot larger than the maximum number of microseconds that can be measured, but is equal to 87,724,005 milliseconds, which is (ta-dahh!) $53A8FE5. This is why you were overflowing the Time Manager's internal counter, causing your task to be clipped.

All should work well if you use times less than 24 hours. If you need to measure durations for times exceeding the Time Manager's limits, you can use a fixed-frequency task that executes every hour and increments an hour counter. To determine the fractional hours component of the time, you'd remove the task to determine how much longer till the next hour.

Back to top

Downloadables

Acrobat gif

Acrobat version of this Note (24K).

Download



Did this document help you?
Yes: Tell us what works for you.
It’s good, but: Report typos, inaccuracies, and so forth.
It wasn’t helpful: Tell us what would have helped.