1 / 9

Context Switching in pdp/unix savu() retu()

제 25 강 : Context Switching in pdp / unix , savu () retu (). Context Switching in pdp/unix savu() retu(). savu( ) SP,EP. sh vi sim. CPU R0 R1 | S P E P. PAR PDR. a.out j u-stack. a.out k u-stack. a.out i u-stack. user

khuong
Download Presentation

Context Switching in pdp/unix savu() retu()

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 제25강 : Context Switching in pdp/unix, savu() retu() Context Switching in pdp/unixsavu() retu()

  2. savu( ) SP,EP sh vi sim CPU R0 R1 | S P E P PAR PDR a.out j u-stack a.out k u-stack a.out i u-stack user k-stack user k-stack user k-stack KERNEL proc[i] proc[j] proc[k] … • Process-k was running so far • We will run process-j next • 3. Save current EP & SP in struct user • savu(u.u_rsav) • ** no need to save ppda address • ** Pk’s struct user saved EP & SP Kernel a.out

  3. CPU R0 R1 | S P E P sh vi sim PAR PDR a.out k u-stack a.out j u-stack a.out i u-stack user k-stack user k-stack user k-stack KERNEL 1. Process-k was running so far 2. We will run process-j next 3. Save current EP & SP in struct user savu(u.u_rsav) 4. Choose next proc[j] to run 5.retu(proc[j] . p_addr) loads Kernel 7th PAR  p_addr CPU(SP, EP)  u.u_rsav proc[i] proc[j] proc[k] … Kernel a.out

  4. retu( ) EP SP ppda sh vi sim CPU R0 R1 | S P E P PAR PDR a.out k u-stack a.out j u-stack a.out i u-stack user k-stack user k-stack user k-stack ppda KERNEL p_addr 1. Process-k was running so far 2. We will run process-j next 3. Save current EP & SP in struct user savu(u.u_rsav) 4. Choose next proc[j] to run 5. retu(proc[j] . p_addr) loads Kernel 7th PAR  p_addr CPU(SP, EP)  u.u_rsav proc[i] proc[j] proc[k] … Kernel a.out Now kernel is ready to work for new proc[j] now kernel is pointing to new image (vi’s a.out) to new struct user (vi’s environment) (just say “u” and it’s new user struct now) to new kernel stack (vi’s kernel history)

  5. summaryretu() assembler procedure (8-2-1) a.out EP PAR PDR proc[i].p_addr load new ppda from proc[ ] user kernel stack k-stack structuseru.u_rsav[] load SP & EP bottom = ppda SP

  6. user kernel stack summarysavu() assembler procedure (8-2-1) a.out EP PAR PDR X proc[i].p_addr don’t need this proc[ ] already has it k-stack structuseru.u_rsav[] save SP & EP bottom = ppda =proc[] SP

  7. r5 = EP r6 = SP r7 = PC savu retu call trap()

  8. SummaryContext Switching PAR PDR calls savu() for retiring process CPU(SP, EP)  u .u_rsav calls retu() for arising process kernel’s 7th-page proc[new] CPU(SP,EP)  u .u_rsav text kernel code data user KERNEL ppda SP kernel stack for user EP swappable data segment PAR PDR text data stack USER

  9. Assembler procedures (8-2-1) • savu() + retu() co-routine jump • savu (u.u_rsav) save kernel SP EP => u.u_rsav (save) (omit saving ppda addr – since it’s in p_addr) • retu(proc[i].p_addr) 7-th kernel address reg. => new ppda CPU kernel SP, EP <= from u.u_rsav • aretu() + return non-local goto • aretu(x) SP EP <=X (new stack frame) • then “return” instruction (pop return address) To where? Not to immediate caller … to whatever that was stored in stack before Retiringprocess Arising process

More Related