1 / 26

Quick look at pdp-11 CPU

제 24 강 : Process Image. Quick look at pdp-11 CPU. Chapter Two CPU registers. Two kinds of stack Case: Fixed size Case: Variable size SP : Stack Pointer SP : Stack Pointer EP : Environment Pointer (boundary or size) Stack & Function call frame

patia
Download Presentation

Quick look at pdp-11 CPU

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. 제24강 : Process Image Quick look at pdp-11 CPU

  2. Chapter TwoCPU registers • Two kinds of stack • Case: Fixed size Case: Variable size • SP: Stack Pointer SP: Stack Pointer EP: Environment Pointer (boundary or size) • Stack & Function call frame Call argument Local variable Return address Register save top - SP top - SP pop this portion main() { x= sin (arg); - - - y= sin (arg); } sin (arg); { local var; expression; return; } EP bottom bottom

  3. pdp-11 CPU has 2 SP’s user stack Base main() do_a() do_b() read() main() do_a() do_b() read() ls SP sys call kernel stack Base read() do_p() do_q() do_r() kernel read() do_p() do_q() do_r() SP

  4. PAR 2000 2500 3000 Why pdp-11 needs MMU(memory management unit) Physical Address Memory CPU Protection (multi-user) prevent R/W/Jump to other process’ image confine memory access intercept faulty access Scattered Allocation image can be scattered Allow Relocation during swapping, not on-demand paging VA loc 0 PA loc 2000 MMU Memory CPU Mapping Table for a.out PAR: Page Address Register (maps VA to PA)

  5. PAR 2000 2500 3000 PDR read write • Physical memory was divided up into 8K byte pages • memory space/process = 64Kbytes = 8 pages • Max 8 PAR’s per process • Access mode (R|W|...) per page PDR (Page Description Register) & PAR Pair • Allocate contiguous chunk of physical memory for each process Split up this chunk into 3 pieces text data areas stack • Unix may have used just three PAR|PDR’s contiguous pages 0 X text 1 X 2 W 3 W data 4 W 5 W 6 7 W stack PAGES

  6. 2 sets of memory mapping registers Memory PAR PDR kernel a.out < KERNEL> vi a.out PAR PDR sh a.out <activeUSER >

  7. Remember?Kernel has PCB for each application Kernel a.out sh vi mail user PCB PCB K-stack proc Hardware CPU mem disk tty CPU mem disk tty

  8. ls vi sh Kernel’s PCB in detail logical address struct user & k-stack share single page kernel PCB(sh) PCB(vi) PCB(ls) user 1 page / process “ppda” (per process data area) user kernel stack K-stack proc proc [NPROC] user K-stack proc vi sh ls

  9. Kernel’s PCB layout logical address kernel proc[ ] 1 global array for all processes u stack 1 page per each process (ppda) u stack u stack user kernel stack vi sh ls

  10. scatter ppda in physical address space logical address physical address logically contiguous physically scattered  adjacent to application’s image kernel proc kernel proc u stack u stack u stack u stack (ppda) 1 page per process vi u stack sh vi sh u stack ls ls

  11. each proc[ ] points to application’s ppda logical address physical address kernel proc kernel proc u stack ppda address struct proc { p_addr; p_size; } u stack u stack u stack size of swappable vi u stack sh vi sh u stack ls ls

  12. Logical Address Physical Address loc. 0 kernel a.out proc[0] proc[i] proc[k] kernel a.out proc[0] proc[i] proc[k] = 10000 = 20000 = 30000 loc. 0 20000 ppda vi a.out u stack vi ppda 30000 u stack sh sh a.out 50000 ppda u stack ls

  13. 2 sets of {PAR|PDR} PAR PDR struct user k-stack Kernel a.out < KERNEL> PAR PDR struct user k-stack vi a.out u--stack <Active USER > struct user k-stack sh a.out u--stack

  14. Kernel’s 7th PAR  active user’s ppda PAR PDR struct user k-stack kernel 7th mapping register Points to active process ppda (7-3-1-b) Hence, in Lion’s code “u ” always points to struct user of the current active process (cf. proc[PID]) Kernel a.out < KERNEL> PAR PDR struct user k-stack vi a.out u--stack <Active USER > struct user k-stack sh a.out u--stack

  15. main, icode

  16. proc[i].p_addr is address of process i’s ppda struct user image 7-th reg == ppda of active process struct user k-stack PAR PDR Kernel Proc[0] Proc[i] Proc[k] < KERNEL> struct user k-stack PAR PDR vi a.out u--stack struct user k-stack < USER > sh a.out u--stack

  17. struct user k-stack PAR PDR Kernel a.out sh (parent) ls (child) struct user k-stack sh a.out At this point, context switch: Kernel 7th PAR points to new ppda -------- User PAR/PDR also changes estabur() sureg() u--stack PAR PDR struct user k-stack ls a.out u--stack < USER >

  18. User a.out Kernel a.out Data Segment (swappable) Process sh Process vi Process ls 7-th page user user user user PPDA (7-th page) K-stack K-stack K-stack kernel stack PROC[ ] proc proc proc “ppda” (per process data area) kernel space 7-th kernel page CPU mem disk CPU mem disk * (7-2, 7-3) address of 7-th kernel page (ppda)  address of active process

  19. Process Image proc[i] p_addr (7-th kernel page) struct user k-stack ppda Swappable Image (data segment) Process Image text data bss p_size a.out u-stack bss: allocated at load time, init to zero struct user: located adjacent to program segment but is part of kernel address space

  20. 7-th page user • data segment (swappable image) (7-3) • allocated as one single segment (physically contiguous – for swap) • ppda (per process data area) (7-3) • 7th page of kernel • lower end -- struct "user“ • higher end -- kernel mode stack • proc[PID].p_addr, p_size (7-2) • address of process (swappable image) (whether in core or disk) • 7-th kernel (segmentation address) register points to <= proc[i].p_addr (address of the process) kernel stack

  21. Logical Address Physical Address PAR PDR loc. 0 kernel a.out proc[0] proc[i] proc[k] 10000 kernel a.out proc[0] proc[i] proc[k] = 10000 7-th page = 20000 p p d a of Active process = 30000 < KERNEL> ppda pda (sh) (vi) owned by kernel struct user k-stack(vi) 20000 ppda (sh) vi a.out vi a.out loc. 0 adjacent to application, for swapping 30000 struct user k-stack(sh) ppda (vi) loc. 0 sh a.out sh a.out

  22. Logical Address Physical Address PAR PDR loc. 0 kernel a.out proc[0] proc[i] proc[k] 10000 kernel a.out proc[0] proc[i] proc[k] = 10000 7-th page = 20000 = 30000 < KERNEL> ppda pda (sh) (vi) struct user k-stack(vi) 20000 Swappable Image “data segment” (7-3) ppda PAR PDR vi a.out vi a.out loc. 0 a.out 30000 struct user k-stack(sh) ppda loc. 0 < USER > sh a.out sh a.out

  23. PAR PDR sh vi sim a.out u-stack a.out u-stack a.out u-stack Adjacent Belongs USER user k-stack user k-stack user k-stack PAR PDR p_addr p_addr proc[i] proc[j] proc[k] … KERNEL

  24. CPU state3 types of CPU registers • with address • memory mapping PAR|PDR • instruction address PC • stack SP EP • with data • R0 R1 R2 R3 … • with others (status) • PSW (ZNCOM ..) < CPU State > PAR PDR PAR PDR CPU R0 R1 | SP E P PC USER KERNEL

  25. Physical Address 7-th kernel mapping register (6-2) struct user k-stack Mapping Registers PAR PDR Kernel a.out points to p.p.d.a. of active process (base of kernel stack) 7th Register 7 KERNEL struct user k-stack (vi) vi a.out kernel stack frame boundary top of kernel stack CPU Registers u--stack R0 R1 | R4 EP SP PC struct user k-stack (sh) k U sh a.out user stack u--stack

  26. proc[i].p_addr is address of process i’s struct user ppda image 7-th ksar == ppda of active process After the boot/init, 7-th ksar = proc #0 (kernel process) (1589) (6-3-1-b) (6-3-3-b) struct user k-stack PAR PDR Kernel Proc[0] < KERNEL> PAR PDR < USER >

More Related