berndporr / linux-timer-demo

Linux timer demo for periodic sampling

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Linux Timer Demo

This code demonstrates how to create a periodic timer under Linux, for example if you need to sample a signal and you don't have any external interrupts.

The demo calls the function "handler" every 500ms. Just change its.it_interval.tv_nsec to any other interval. It's in nanoseconds.

How to compile

make

How to run

./linux-timer-demo

and it prints out a message every 500ms and checks that the handler has been really called by this timer.

The code is loosely based on the timer_create() man page.

About

Linux timer demo for periodic sampling

License:GNU General Public License v3.0


Languages

Language:C++ 84.1%Language:Makefile 15.9%