Hi,
I would like to know about which threads will be preempted by which on my 
OpenSolaris machine. 
Therefore, I ran a multithreaded program "myprogram" with 32 threads on my 
24-core Solaris machine. I make sure that each thread of my program has same 
priority (priority zero), so that we can reduce priority inversions (saving 
preemptions -- system overhead). However, I ran the following script 
whoprempt.d to see who preempted myprogram threads and got the following output 
Unlike what I thought, myprogram threads are preempted (for 2796 times -- last 
line of the output) by the threads of same myprogram. 

Could anyone explain why this happens, please? 

DTrace script
==============

#pragma D option quiet
 
 sched:::preempt
 {
         self->preempt = 1;
 }

 sched:::remain-cpu
  /self->preempt/
 {
          self->preempt = 0;
 }
  
 sched:::off-cpu
 /self->preempt/
 {
            /*
              * If we were told to preempt ourselves, see who we ended up 
giving                 
              * the CPU to.
               */
                         @[stringof(args[1]->pr_fname), args[0]->pr_pri, 
execname,
                                  curlwpsinfo->pr_pri] = count();
                                      self->preempt = 0;
 }
  
 END
  {
          printf("%30s %3s %30s %3s %5s\n", "PREEMPTOR", 
"PRI","||","PREEMPTED", "PRI", "#");
          printa("%30s %3d %30s %3d %5@d\n", @);
  }


Output:
=======
PREEMPTOR  PRI   ||       PREEMPTED PRI     #
   dtrace   0    ||       myprogram   0     1
   dtrace   50   ||      myprogram   0     1
    sched  -1      ||    myprogram   0     1
 myprogram   0    ||        dtrace   0     1
           ....
           .....       
       nscd  59   ||     myprogram   0     4
   sendmail  59    ||    myprogram   0     4
      sched  60     ||   myprogram   0    92
      sched  98     ||   myprogram   0   272
      sched  99     ||   myprogram   0  2110
  myprogram   0   ||     myprogram   0  2796
-- 
This message posted from opensolaris.org
_______________________________________________
zfs-discuss mailing list
zfs-discuss@opensolaris.org
http://mail.opensolaris.org/mailman/listinfo/zfs-discuss

Reply via email to