Timers via file descriptors

Do you recall a key philosophy of the Unix (and, thus, Linux) design that we covered in Chapter 1, Linux System Architecture, of this book? That is, everything is a process; if it's not a process, it's a file. The file abstraction is heavily used on Linux; here, too, with timers, we find that there is a way to represent and use timers via the file abstraction.

How is this done? The timerfd_* APIs provide the required abstraction. In this book, we shall not attempt to delve into the intricate details; rather, we would like the reader to become aware that one can use the file abstraction—reading a timer via the read(2) system call—if required.

The following table quickly outlines the timerfd_* API set:

API ...

Get Hands-On System Programming with Linux now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.