Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!sharkey!atanasoff!hascall From: hascall@atanasoff.cs.iastate.edu (John Hascall) Newsgroups: comp.arch Subject: Context switch tasks Message-ID: <788@atanasoff.cs.iastate.edu> Date: 11 Feb 89 19:36:59 GMT Reply-To: hascall@atanasoff.cs.iastate.edu (John Hascall) Organization: Iowa State U. Computer Science Department, Ames, IA Lines: 42 A couple of days ago I posted a question about saving/restoring registers during context switch. A couple of people sent me mail saying that register/save restore was a very small part of the time taken by a context switch. One person claimed about 1%! What all are you people doing during context switch??? And are they things which are required by the architecture of the machine or by a particular OS? Tasks done at in response to reschedule interrupt (as I see it): 1) Block interrupts 2) Save current processes registers (GP, pagetable-base etc) 3) Select new process 4) Invalidate per-process TLB entries 5) Restore registers 6) Return from interrupt ?) assorted bit and register twiddling A check of the VMS scheduler interrupt handler shows it to be similar (and the longest path through the code looks to be 28 instructions, of course SVPCTX and LDPCTX do the copying of the PCB registers to/from memory (24 longwords) -- and most assuredly they take a majority of the time spent). You can see for yourself (if you have access to a VMS system) with: $ analyze/system SDA> exam/noskip SCH$RESCHED;84 (I think it's covered in Levy's book on the VAX-11 architecture too.) I haven't looked at this section of the BSD code (for VAXen) in a while (and it's at home, of course :-), but I'm sure it's not all that different. John Hascall ISU Comp Center (I just work here, any ideas or opinions which may have found their way into the above nonsense are strictly my own.)