tbe careful about not switching to procs unless necessary. - plan9port - [fork] Plan 9 from user space
 (HTM) git clone git://src.adamsgaard.dk/plan9port
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit c9896e2edba3bf17061447f3491a866a74e2cbb9
 (DIR) parent 1c39bb59193d68cb6119a053260d1381d303b24d
 (HTM) Author: rsc <devnull@localhost>
       Date:   Sun, 23 May 2004 00:58:00 +0000
       
       be careful about not switching to procs unless necessary.
       
       Diffstat:
         M acid/thread                         |      16 +++++++++++-----
       
       1 file changed, 11 insertions(+), 5 deletions(-)
       ---
 (DIR) diff --git a/acid/thread b/acid/thread
       t@@ -81,11 +81,15 @@ defn stkignore(s){
        }
        
        defn threadstkline(T){
       -        local stk, frame, pc, pc0, file, s, sym, i, stop;
       +        local stk, frame, pc, pc0, file, s, sym, i, stop, P, mainpid;
        
       -        if T.state == Running then
       +        if T.state == Running then {
       +                P = (Proc)T.proc;
       +                mainpid = pid;
       +                if mainpid != P.pid then setproc(P.pid);
                        stk = strace({});
       -        else
       +                if mainpid != P.pid then setproc(mainpid);
       +        } else
                        stk = strace(label(T.sched));
        
                stop = 0;
       t@@ -151,7 +155,6 @@ defn pthreads(P){
                local T, Tq, mainpid;
        
                mainpid = pid;
       -//        setproc(P.pid);
                Tq = (Tqueue)P.threads;
                T = (Thread)Tq.$head;
                while T != 0 do{
       t@@ -159,7 +162,6 @@ defn pthreads(P){
                        thread(T);
                        T = (Thread)T.nextt;
                }
       -//        setproc(mainpid);
        }
        
        defn threads(){
       t@@ -305,7 +307,11 @@ defn threadstk(T){
                // setproc(P.pid);
        
                if T.state == Running then{
       +                if P.pid != mainpid then
       +                        setproc(P.pid);
                        stk();
       +                if P.pid != mainpid then
       +                        setproc(mainpid);
                } else {
                        labstk(T.sched);
                }