#StackBounty: #c #linux #multithreading #clock clock_gettime(CLOCK_MONOTONIC) monotonicity across cores/threads

Bounty: 50

I have multiple processes that communicate with each other running on different cores of a dual-processor X86-64 Linux machine. The content of the communication includes timestamps. I want to write time-related logic of the programs with the simple assumption that all the timestamps are from the same global clock. Can I count on clock_gettime(CLOCK_MONOTONIC) to give me monotonic timestamps even across different threads running on different cores?

Particularly, suppose Process A takes a timestamp X and sends it to Process B via shared memory. Process B reads it and then takes a timestamp Y. X cannot be greater than Y.

Does the timestamp taken using clock_gettime(CLOCK_MONOTONIC) have the above property? If not, what are some other types of monotonic timestamp that have this property?

Get this bounty!!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.