hello
I am trying to count the total number of clock ticks for each process (only when its actually running).
I inserted the following code in schedule() (sched.h):
...
switch_tasks:
prefetch(next);
clear_tsk_need_resched(prev);
if (likely(prev != next)) {
rq->nr_switches++;
rq->curr = next;
/*my code start here*/
if(next->start_count==1) next->start_run=jiffies;
if(prev->start_count==1)
{
prev->total_running += (jiffies-prev->start_run);
printk("total running = %lu, jif-start = %lu\n", \
prev->total_running, jiffies-prev->start_run);
}
...
I added the printk
because I got weird results. here is some of the output:
total running = 1522, jif-start = 1
total running = 1522, jif-start = 0
total running = 1523, jif-start = 1
total running = 1, jif-start = 1
total running = 0, jif-start = 0
total running = 0, jif-start = 0
total running = 0, jif-start = 0
total running = 0, jif-start = 0
It does not make sense to me....
is something wrong with my code?