[LITMUS^RT] Questions about tick mechanism in Kernel

Hang Su hangsu.cs at gmail.com
Sun Apr 29 01:35:12 CEST 2012


Hi all:

I add a tick_test to struct rq in kernel/sched.c, like

struct rq{
  unsigned long long tick_test ;
  ...
  ...
}

and initialize it for each rq  in sched_init in kernel/sched.c, like

for_each_possible_cpu(i) {
  rq->tick_test = 0 ;
  ...
  ...
}

Inside scheduler_tick function, which is called by timer code , I increase
tick_test by one print it for each rq , like

void scheduler_tick(void){
...
...
 raw_spin_lock(&rq->lock);
 update_rq_clock(rq);
 update_cpu_load(rq);
 */*edited by Hang*/
   rq->tick_test++ ;
   printk(KERN_DEBUG "THIS_CPU:%d TICK:%llu\n",cpu, rq->tick_test);*
 curr->sched_class->task_tick(rq, curr, 0);
 raw_spin_unlock(&rq->lock);
...
...
}

And I set Timer Frequency 1000 Hz, the result is like:

[  361.174006] THIS_CPU:0 TICK:361175
[  361.174129] THIS_CPU:1 TICK:360959
[  361.175004] THIS_CPU:0 TICK:361176
[  361.175130] THIS_CPU:1 TICK:360960
[  361.176006] THIS_CPU:0 TICK:361177
[  361.176129] THIS_CPU:1 TICK:360961
[  361.177005] THIS_CPU:0 TICK:361178
[  361.177130] THIS_CPU:1 TICK:360962
[  361.178006] THIS_CPU:0 TICK:361179
[  361.178129] THIS_CPU:1 TICK:360963
[  361.179004] THIS_CPU:0 TICK:361180
[  361.179130] THIS_CPU:1 TICK:360964
[  361.180006] THIS_CPU:0 TICK:361181
[  361.180129] THIS_CPU:1 TICK:360965
[  361.181004] THIS_CPU:0 TICK:361182
[  361.181130] THIS_CPU:1 TICK:360966
[  361.182006] THIS_CPU:0 TICK:361183
[  361.182129] THIS_CPU:1 TICK:360967
[  361.183004] THIS_CPU:0 TICK:361184
[  361.183130] THIS_CPU:1 TICK:360968
[  361.184007] THIS_CPU:0 TICK:361185
[  361.184129] THIS_CPU:1 TICK:360969
[  361.185004] THIS_CPU:0 TICK:361186
[  361.185129] THIS_CPU:1 TICK:360970
[  361.186005] THIS_CPU:0 TICK:361187
[  361.186133] THIS_CPU:1 TICK:360971

The tick of CPU0 seems be to reasonable, but the tick of CPU1 does not. The
gap of ticks between CPU0 and CPU1 is always 216. The timer represents how
many seconds have elapsed since boot. It is a local timer for each CPU or
global timer shared by all CPUs ? What is the reason for this gap ? In
LITMUS pfair implementation, we have two ticksin pfair_state, curr_tick and
local_tick. From comments, cur_tick is updated by the CPU and local_tick is
the  local cpu currently executing. So, cur_tick is advanced by the same
way as mine ? How does local_tick advance ?

Thanks.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.litmus-rt.org/pipermail/litmus-dev/attachments/20120428/d4e282b2/attachment.html>


More information about the litmus-dev mailing list