1 / 12

Project 1 Roadmap

Project 1 Roadmap. User Process 1. User Process 2. Size 2. Size 1. Base 1. Base 2. Address Space Protection in GeekOS. User Process n. Size n. Base n. User processes’ address spaces don’t overlap Kernel “sees” all address spaces. Kernel. Segmentation Principles. Segment Descriptor

Télécharger la présentation

Project 1 Roadmap

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. Project 1 Roadmap

  2. User Process1 User Process2 Size2 Size1 Base1 Base2 Address Space Protection in GeekOS User Processn Sizen Basen • User processes’ address spaces don’t overlap • Kernel “sees” all address spaces Kernel

  3. Segmentation Principles Segment Descriptor size base privilegeLevel … User Process • Kernel Address = User Address + Base • Gives user processes the illusion they have their own world that starts at 0 Kernel

  4. X86 Segmentation • Intel docs, fig. 3-1 and 3-5

  5. X86 Segmentation in GeekOS User Processn User Process2 User Process1 • GDT=Global Descriptor Table: holds LDT descriptors for user processes • LDT=Local Descriptor Table: holds segment descriptors for user processes LDT Desc1 GDT LDT Desc2 LDT Descn

  6. struct Segment_Descriptor ldt[0] struct Segment_Descriptor ldt[1] struct Segment_Descriptor *ldtDescriptor ushort_t ldtSelector ushort_t csSelector LDT descriptor ushort_t dsSelector int stackAddr int programSize char * program X86 Segmentation in GeekOS (implementation) User_Context GDT Selector Selector Selector

  7. Kernel_Thread Kernel_Thread Kernel_Thread User Context User Context User Context User Processes in GeekOS Kernel_Thread Kernel_Thread User Processes

  8. Lifetime of an User Process • Shell spawns user processes using Spawn_With_Path(see src/user/shell.c) • User processes termination • Normally - via Exit,called automatically when main() finishes • Killed - via Sys_Kill which you will implement • Parent processes can wait for their children using Wait

  9. System Calls • INT90 • put args in registers on user side • recover them on kernel side • call Sys_xxx accordingly • return result/error code • Use g_CurrentThread to get info about current thread

  10. Requirement #1:Background Processes • Shell • src/user/shell.c • Scan for & • If & detected, spawn in background, don’t Wait() • If & not detected, Spawn normally, do Wait() • Sys_Spawn() • src/geekos/syscall.c • need to consider ‘spawn in background argument’

  11. Requirement #2:Killing Background Processes • Kernel:Sys_Kill() • src/geekos/syscall.c • Get the PID of the victim process • Lookup the victim’s kernel_thread (see Lookup_Thread in src/geekos/kthread.c) • Dequeue thread from all queues, and ‘kill’ it • User • Add src/user/kill.c for testing • Add kill.c to USER_C_SRCS in build/Makefile to create an user program

  12. Requirement #3:Printing the process table • Kernel:Sys_PS() • src/geekos/syscall.c • Prepare an struct Process_Info array in kernel space • Walk all threads:s_allThreadList in src/geekos/kthread.c, fill out the above array • Copy array into user space: Copy_To_User() • User • Add the ‘ps’ user program: src/user/ps.c , see req #2 • Hit ‘ps’, ‘man ps’ in Linux to get an idea

More Related