Benchmarks Documentation Examples Repository Blog Contact

Standard API

Function-like Macros

long get_cpu_freq(void)

Give userspace applications access to the current CPU frequency.

CPU frequency in Hz or 0 if frequency is unknown or unreliable.

uint32_t getmicrotime(void)

Returns current scheduler time. The time is returned with nanosecond resolution and precision depending on the timing provider implemented.

This value wraps around after about 4000 seconds on 32-bit CPUs

current scheduler time in nanoseconds

uint32_t shutdown(void)

This syscall will initiate CMRX kernel shutdown. Kernel shutdown ensures that the timing provider is stopped. Interrupts are also disabled globally. No check on existing threads status is made. It is up to the application developer to ensure that threads are in stable state before kernel is shut down. Any work done and not saved in threads still active will be lost.

It is not possible to call CMRX system calls once kernel has been shut down. While in general, the possibility of restarting kernel after it has been shut down is not ruled out this workflow is considered as unsupported.

After kernel is shut down the execution will continue in function named cmrx_shutdown_handler()

  • memory protection disabled
  • privileged mode execution
  • all interrupts disabled memory protection disabledprivileged mode executionall interrupts disabled

uint32_t diff_microtime(uint32_t older_timestamp, uint32_t newer_timestamp)

It will calculate the distance of two timestamps taking possible time counter wraparound. It assumes the order of timestamps is older first, newer last. This function only returns correct results for timestamps that are less than ~4000 seconds apart. For timestamps more than ~4000 seconds apart two (or even more) timestamp wraparounds happen and the distance calculation returns invalid values.

older_timestamp timestamp of event that happened first

newer_timestamp timestamp of event that happened last distance of timestamps in microseconds

  • older_timestamp timestamp of event that happened first
  • newer_timestamp timestamp of event that happened last

64kB of protected memory ought to be enough for everyone.