Hi 9fans,

While reading src/9/port/proc.c:^runproc, I realized that the
following code is called without any lock. I would expect one in order
to walk through the each rq lists, as it is called with interrupt
enabled.

I think this would not crash the system because procs are not
dynamically allocated or freed.

I also know that locking can be a problem regarding performance.

       for(rq = &runq[Nrq-1]; rq >= runq; rq--){
           for(p = rq->head; p; p = p->rnext){
               if(p->mp == nil || p->mp == MACHP(m->machno)
               || (!p->wired && i > 0))
                   goto found;
           }
       }

What do you think ?

Phil;

Ps: It seems runqs were designed to be individually locked. Is there
any info about the reason why all the runq are locked at once using :

   lock(runq);
   // ...
   unlock(runq);

where we could expect (with some other changes of course) :

   lock(rq);
   // ...
   unlock(rq);

?

Reply via email to