CMSC412Project 0Administriviahttp://www.cs.umd.edu/class/fall2009/cmsc412/CSIC 2118, MW 9:00-9:50 / 10:00-10:50John Silberholz ([email protected])Calvin Grunewald ([email protected])TAs−Bo Han ([email protected])−Vasilieos Lekakis ([email protected])Why are we here?To get you started on the project and answer your questionsGive you background materialShow you how the concepts you learn in lecture apply to GeekOSCome with questionsWhy are operating systems such a big deal?Semester ProjectParallel to lectureLots of code−Heavily commented−Read it!Use the forum−Quickest way to get questions answeredCome to recitation with questionsThese projects are challenging, but funBest advice for successStart early−Seriously−No, for realGetting StartedGetting the source−svn co https://svn.cs.umd.edu/repos/geekos/project0−Uname: “sv-geekosro”; passwd: “”Setup instructions are on the website:−QEMU, Compilers, DebuggersLinux, Mac, and LinuxlabCygwin−GeekOS buildGeekOS Emulation EnvironmentGeekOSQEMU (Hardware emulator)Linux/MacReal HardwareProject 0Project requirements−Resource restrictions on GeekOS processes:# of active processes# of syscalls by a single processSystem callsSoftware interrupt−The only interrupt callable from user level: idt.c Init_IDT−SYSCALL_INT: 0x90Operation: syscall.h; syscall.c; libc/process.c−Put args in registers on user side; raise INT−Recover them on kernel side−Call the appropriate Sys_xxxx−Return result/error code in appropriate registerUse g_CurrentThread for information about who raised itThreadsEach thread is a Kernel_Thread object: kthread.hCurrent thread: g_CurrentThread (global)User mode threads−Kernel_Thread with a populated User_ContextTransfer from user to kernel mode: syscallKernel vs. user memory−One from user view and one from kernel−Kernel needs to access user memory (but not vice versa!)−Use Copy_From_User/Copy_To_UserThe system queuesThread_Queue structureRun Queue:−Threads which are ready to run, but not currently running−GeekOS has one run queue (for now.....)Wait Queues:−Threads that are waiting for a specific event or on a specific device (keyboard/network/other threads)−geekos/kthread.c Join()−Follow Get_Key syscall to see how the thread gets in the keyboard wait queueInterruptsTypes:−Illegal operations (result in kills)−Faults (like page faults; not of concern now)−Hardware interrupts−Software interrupts (traps): syscall intInterrupt handlers−geekos/int.c−On completion control returns to the thread that was interruptedInterruptsWhen you don't want them:−When modifying global structures, queues, etc.−When you want an atomic operation−Disable_Interrupts() / Enable_Interrupts()include/geekos/int.hUse caution (interrupt state dependent)Enable_Interrupts() when finishedSee examples: src/geekos/user.c: Attach_User_Context()−Begin_Int_Atomic() / End_Int_AtomicOblivious way of saving and restoring interrupt
View Full Document