ELE542 Cours 04 4
Systèmes ordinés en temps réel 7
Cours no4
ANSI C – Fonction date & time
Ætime_t time( time_t *timer ); // timer.h
Get current system time as type time_t
Résultat :
struct tm {
int tm_sec; /* seconds after the minute - [0,59] */
int tm_min; /* minutes after the hour - [0,59] */
int tm_hour; /* hours since midnight - [0,23] */
int tm_mday; /* day of the month - [1,31] */
int tm_mon; /* months since January - [0,11] */
int tm_year; /* years since 1900 */
int tm_wday; /* days since Sunday - [0,6] */
int tm_yday; /* days since January 1 - [0,365] */
int tm_isdst; /* daylight savings time flag */
}; Résolution : ±1 seconde
Systèmes ordinés en temps réel 8
Cours no4
ANSI C – Fonction clock
Æclock_t clock( void ); // timer.h
Retourne le nombre de ticks de l’horloge
Notes :
•typedef long clock_t;
•Temps en secondes = clock_t/CLOCKS_PER_SEC;
•Sous Windows2000, CLOCKS_PER_SEC = 1 000;
•Sous DOS (TurboC), CLOCKS_PER_SEC = 18.2.
Résolution = 0.99985 ms