280 likes | 471 Views
JOSLAB 4. Three Parts. Deadline: One week for each part, so that you don’t need to rush the deadline MUST finish them before 6.11 Submit: Code & Document Lab Interview Soon after the deadline Your need to do Answer TA’s questions and demo Prepare your slides (optional).
E N D
Three Parts • Deadline: • One week for each part, so that you don’t need to rush the deadline • MUST finish them before 6.11 • Submit: • Code & Document • Lab Interview • Soon after the deadline • Your need to do • Answer TA’s questions and demo • Prepare your slides (optional)
After JOSLAB3 • JOS After LAB3 • You can run a single process and call some system call
Problem NOW • How to ensure the order? • Many processes?
Solution • Operating System Schedule
Part A: Scheduling • Round-Robin Scheduling • Loop envs array and run it. • Note • A process enters kernel by two ways • Sysenter instruction (system call) • Trap (Pagefault blablabla……) • Hint :you can create a trap frame like structure for system call
Part A: Environment Creation • Unix-like fork • Create a new process • Sys_exofork : inc/lib.c • A library wrapper for sys_exofork • Use “INT” instruction to implement it • Much easier than sysenter
Part A:Reading materials • Unix Fork function • Understanding Linux Kernel • Creating Process .etc • INT instruction • Document and IA-32 Intel Architecture Software Developer's Manual, Volume 2A. • Documents about trap in LAB3
Part A: Q & A • Question need to answer • What’s the difference between fork in Linux and in JOS. • Why “INT” instruction is much easier than “sysenter” for exo_fork system call? And why exo_fork wrapper function must be an inline function? • Answer these questions in the document1
Part B: Copy-On-Write Fork • What is copy on write? • Understanding Linux Kernel (Wu Gang’s Linux course) • Process Address Space • Why & How to copy on write? • You will find the answer during this lab
Part B: Copy-On-Write Fork • User-level page fault handling • User-level: Difference between Linux and JOS • JOS is a LibOS!(problem one in homework 2)
Part B: Q&A • Mechanism need to understand • How to invoke the user pg fault handler? • What stack is used in pg fault handler? • Where does the pg fault handler return to? And how do you makeit? • Questions need to think • What’s the benefits of user-level pg fault handler? • Needn’t to answer them in doc, just thinking is OK.
Part B: Copy-On-Write Fork • Fork() in lib/fork.c • Dumbfork() in test case dumbfork.c maybe helpful to you.
Part C: Clock & IPC • Problem now: • Some process like a infinite loop will always occupy the CPU resource • Solution • Preemption
Part C: Preemption • Clock Interrupt • Intel Manual is a good friend when you confused. • Note • Don’t forget to enable interrupt when exit from the kernel • JOS will disable interrupt when enter the kernel
Part C: Q&A • Mechanism need to understand • What’s the difference between interrupt mechanism and exception? • What will trigger an interrupt? And how CPU is notified and handle it? • You can find this answer in Intel Doc • Also just thinking is OK
Part C: Preemption • You haveclock interrupt now, you can do preemption easily. • Intuitive • Reschedule task when an timer event happened.
Part C: IPC • Adelicious dessert if you finished all things before by yourself • IPC in JOS is really simple and trivial • So I won’t give too much comments here
END??? NO!!!
Suggestion • You can have a discussion but don’tcopy • You should understand the code you write • Why write? • How to write? • Can be more perfect? • Debug is a good way to learn • Don’t fear a bug.
REAL END Just enjoy it and have fun~
Q&A • Email TA(liwenhaosuper@gmail.com) • Come to TA’s office at Room 3402. • Service is available during 9:00-24:00