So what does CLOCK_SOFTTIME do?

If we wanted to sort our clock sources by "hardness" we'd have the following ordering. You can think of CLOCK_MONOTONIC as being a freight train—it doesn't stop for anyone. Next on the list is CLOCK_REALTIME, because it can be pushed around a bit (as we saw with the time adjustment). Finally, we have CLOCK_SOFTTIME, which we can push around a lot.

The main use of CLOCK_SOFTTIME (a QNX Neutrino extension to POSIX) is for things that are "soft"—things that aren't going to cause a critical failure if they don't get done. CLOCK_SOFTTIME is "active" only when the CPU is running. (Yes, this does sound obvious :-) but wait!) When the CPU is powered down because power management has detected that nothing is going to happen for a little while, CLOCK_SOFTTIME gets powered down as well!

Here's a timing chart showing the three clock sources:

Real time QNX Neutrino time Activity
11:22:05 11:22:00 Wake up at "now" + 00:00:30 (see below)
11:22:15 11:22:15 Clock gets adjusted as before
11:22:20 11:22:20 Power management turns off CPU
11:22:30 11:22:30 CLOCK_REALTIME wakes up
11:22:35 11:22:35 CLOCK_MONOTONIC wakes up
11:45:07 11:45:07 Power management turns on CPU, and CLOCK_SOFTTIME wakes up

There are a few things to note here:

When CLOCK_SOFTTIME "over-sleeps," it wakes up as soon as it's able—it doesn't stop "timing" while the CPU is powered down, it's just not in a position to wake up until after the CPU powers up. Other than that, CLOCK_SOFTTIME is just like CLOCK_REALTIME.