Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I ensure my program runs from beginning to end without interruption?
    primarykey
    data
    text
    <p>I'm attempting to time code using RDTSC (no other profiling software I've tried is able to time to the resolution I need) on Ubuntu 8.10. However, I keep getting outliers from task switches and interrupts firing, which are causing my statistics to be invalid.</p> <p>Considering my program runs in a matter of milliseconds, is it possible to disable all interrupts (which would inherently switch off task switches) in my environment? Or do I need to go to an OS which allows me more power? Would I be better off using my own OS kernel to perform this timing code? I am attempting to prove an algorithm's best/worst case performance, so it must be totally solid with timing.</p> <p>The relevant code I'm using currently is:</p> <pre><code>inline uint64_t rdtsc() { uint64_t ret; asm volatile("rdtsc" : "=A" (ret)); return ret; } void test(int readable_out, uint32_t start, uint32_t end, uint32_t (*fn)(uint32_t, uint32_t)) { int i; for(i = 0; i &lt;= 100; i++) { uint64_t clock1 = rdtsc(); uint32_t ans = fn(start, end); uint64_t clock2 = rdtsc(); uint64_t diff = clock2 - clock1; if(readable_out) printf("[%3d]\t\t%u [%llu]\n", i, ans, diff); else printf("%llu\n", diff); } } </code></pre> <p>Extra points to those who notice I'm not properly handling overflow conditions in this code. At this stage I'm just trying to get a consistent output without sudden jumps due to my program losing the timeslice.</p> <p>The nice value for my program is -20.</p> <p>So to recap, is it possible for me to run this code without interruption from the OS? Or am I going to need to run it on bare hardware in ring0, so I can disable IRQs and scheduling? Thanks in advance!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload