Menu

Clock?

2014-07-01
2014-07-02
  • Marco Achziger

    Marco Achziger - 2014-07-01

    Is there a way to get in genode with nova a clock?

    example of what i search for:

    struct timespec start, stop;
    clock_gettime(CLOCK_MONOTONIC, &start);
    atestmethod();
    clock_gettime(CLOCK_MONOTONIC, &stop);

    and then measure execution time by (stop.tv_sec - start.tv_sec) + (double)(stop.tv_nsec - start.tv_nsec) / (double)BILLION;

     
  • Norman Feske

    Norman Feske - 2014-07-02

    Hi Marco,

    welcome to Genode!

    Regarding your question about obtaining time information, there are three options:

    First. there is a real-time clock (RTC) driver, located at os/src/drivers/rtc. When started, your program can open a session to this driver to obtain the real-world time. The session interface is located at os/include/rtc_session.

    Second, you may use a connection to the timer service. The Timer::Session interface has a function 'elapsed_ms', which returns the number of milliseconds that have passed since the session was created. However, the granularity is milliseconds.

    Finally, you can use the values returned by the rdtsc instruction, This is the best option for benchmarking. Please have a look at os/include/x86_32/trace/timestamp.h for the function binding. In your program, you can include <trace timestamp.h=""> and call the 'timestamp' function.

    Btw, I warmly recommend you to post questions like this on our mailing list, which is the primary point for discussions around Genode. The forum is pretty much deserted. Please subscribe to the list here:

    http://genode.org/community/mailing-lists

    Cheers
    Norman

     

Log in to post a comment.