2 years ago

#66319

test-img

kuga

clock source for select()

I am investigating the clock sources that common posix objects wait on. I am worried that our code is affected by time changes by user or services like ntp.

It is mostly CLOCK_REALTIME or "just the system clock".

E.g:

The timeout shall be based on the CLOCK_REALTIME clock. The resolution of the timeout shall be the resolution of the clock on which it is based. The timespec data type is defined in the <time.h> header.

https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_mutex_timedlock.html

This means it is definitely affected by time changes.

I cannot find this information on sockets. There is receive timeout (sockopt SO_RCVTIMEO), linger timeout (sockopt SO_LINGER) and especially select(). I am particularly interested in select() as it can also be called on other file descriptors like mqueues.

sockets

posix

0 Answers

Your Answer

Accepted video resources