SlideServe
Menu
Préférences
© SlideServe · v2026

Lab: Timer and Timer Signals

pavel avatar
13 diapositives · 309 Views · Sep 20, 2014

Lab: Timer and Timer Signals. Lab. Goal. The goal of this lab is (1) to under the defects of software timers, (2) to write a periodic program without timers, (3) to write a periodic program using timer. Experimental Environment. Hardware Host computer PC Software

Lab: Timer and Timer Signals - slide 1
01 / 13Lab: Timer and Timer Signals
1 / 17

Télécharger la présentation

Lab: Timer and Timer Signals
Une image / un lien ci-dessous est fourni (tel quel) pour télécharger la présentation

Politique de téléchargement : le contenu du site vous est fourni TEL QUEL pour votre information et votre usage personnel ; il ne peut être vendu, concédé sous licence ni partagé sur d’autres sites sans l’accord de son auteur.Le contenu vous est fourni TEL QUEL, pour votre information et votre usage personnel uniquement. Téléchargez la présentation en cliquant sur ce lien. Lors du téléchargement, si vous ne parvenez pas à télécharger une présentation, l’éditeur a peut-être supprimé le fichier de son serveur.Pendant le téléchargement, si vous ne parvenez pas à obtenir une présentation, le fichier a peut-être été supprimé par l’éditeur.

F I N

Plus de contenu associé

Transcription de la présentation
  1. Lab: Timer and Timer Signals

  2. Lab. Goal The goal of this lab is (1) to under the defects of software timers, (2) to write a periodic program without timers, (3) to write a periodic program using timer.

  3. Experimental Environment • Hardware • Host computer PC • Software • Cygwin on Windows XP • GNU GCC

  4. Lab. Procedures • Create Timer. • Append mutex to your program.

  5. Reference functions • Definition: control device • #include < sys/ioctl.h > int ioctl(int d, int request, ...) • request will be TIOCMGET and TIOCMSET • e.g. Get the status of rs232 registers, and set the RTS register to high ioctl(a, TIOCMGET, &status ); status |= TIOCM_RTS;

  6. Reference functions • Definition: examine and change signal action • #include <signal.h> • int sigaction( int sig, const struct sigaction *act, struct sigaction *oact);

  7. Reference functions • The structure sigaction, used to describe an action to be taken, is defined in the header <signal.h> to include at least the following members:

  8. Reference functions Definition: Structure for timer_ functions itimerspec Public Attributes Timespec it_value // current value Timespec it_interval // reset value struct timespec { time_t tv_sec; /**< seconds*/ long tv_nsec; /**< nanoseconds*/ };

  9. Reference functions • Definition: create a per-process timer (REALTIME) • #include <time.h> • #include <signal.h> • include library -lrt • int timer_create( clockid_t clockid, struct sigevent *evp, timer_t *timerid);

  10. Reference functions • Definition: set timer time (REALTIME) • #include <time.h> • include library #-lrt • int timer_settime( timer_t timerid, int flags, const struct itimerspec *value, struct itimerspec *ovalue);

  11. Reference functions • Definition: wait for a signal • #include <signal.h> • int sigsuspend(constsigset_t *sigmask);

  12. Download files You can download the aLAB5.tar (include reference code) from http://newslab.csie.ntu.edu.tw/course/NetworkedSoCSystems/files/aLAB5.tar

  13. Sampling Periods • Task T1: period =200 ms • Task T2: period =100 ms • I/O: get and print out current time to a file. • Computation: double x; for(i=1;i<1+(int) (1000.0*rand()/(RAND_MAX+1.0)); i++){ x = sin(x * 1000);} • I/O: get and print out current time to a file.