30.12.2013 Views

T-Kernel Specification (1.B0.02)

T-Kernel Specification (1.B0.02)

T-Kernel Specification (1.B0.02)

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

6.1. KERNEL INTERNAL STATE ACQUISITION FUNCTIONS 273<br />

td get tim<br />

Get System Time<br />

[C Language Interface]<br />

ER ercd = td_get_tim ( SYSTIM *tim, UNIT *ofs ) ;<br />

[Parameters]<br />

SYSTIM* tim Packet address for returning current time (ms)<br />

UNIT* ofs Location for returning elapsed time from tim (nanoseconds)<br />

[Return Parameters]<br />

ER & ercd &<br />

Error code<br />

tim detail:<br />

Current time (ms)<br />

ofs detail:<br />

Elapsed time from tim (nanoseconds)<br />

[Error Codes]<br />

E OK<br />

Normal completion<br />

[Description]<br />

Gets the current time as total elapsed milliseconds since 0:00:00 (GMT), January 1, 1985. The value<br />

returned in tim is the same as that obtained by tk get tim. tim is the resolution of time interrupt<br />

intervals (cycles), but even more precise time information is obtained in ofs as the elapsed time from<br />

tim in nanoseconds. The resolution of ofs is implementation-dependent, but generally is the timer<br />

hardware resolution.<br />

Since tim is time counted based on timer interrupts, in some cases time is not refreshed, when a timer<br />

interrupt cycle arrives while interrupts are disabled and the timer interrupt handler is not started (is<br />

delayed). In such cases, the time as updated by the previous timer interrupt is returned in tim, and<br />

the elapsed time from the previous timer interrupt is returned in ofs. Accordingly, in some cases ofs<br />

will be a longer time than the timer interrupt cycle. The length of elapsed time that can be measured<br />

by ofs depends on the hardware, but preferably it should be able to measure at least up to twice the<br />

timer interrupt cycle ( 0 ≤ ofs < twice the timer interrupt cycle).<br />

Note that the time returned in tim and ofs is the time at some point between the calling of and return<br />

from td get tim. It is neither the time at which td get tim was called nor the time of return from<br />

td get tim. In order to obtain more accurate information, this function should be called in interrupts<br />

disabled state.<br />

Copyright c○ 2002, 2003 by T-Engine Forum<br />

T-<strong>Kernel</strong> <strong>1.B0.02</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!