70 likes | 204 Vues
This assignment focuses on implementing a system call, Sleep(), in the Nachos operating system, along with developing a non-preemptive shortest job first (SJF) scheduler. The project requires defining a system call number for Sleep, preparing registers, and adding a new case for the Sleep system call in the exception handler. Additionally, you'll design test cases to validate your SJF scheduler implementation, replacing the default Round Robin scheduling in Nachos. Follow the provided resources for a comprehensive understanding of the tasks.
E N D
If you still have trouble to install Nachos • https://code.google.com/p/damody/downloads/detail?name=mips-decstation.linux-xgcc.gz
Part 1-System call • Implement a system call – Sleep() • userprog/syscall.h • Define a system call number of Sleep • test/start.s • Prepare registers for Sleep • userprog/exception.cc • Add a new case for Sleep
System call:start.s • Assembly language assist to make system calls to the Nachos kernel • http://www.mrc.uidaho.edu/mrc/people/jff/digital/MIPSir.html • Take System call Sleep as an example .globl Sleep .ent Sleep PrintInt: addiu $2,$0,SC_Sleep // put system call number in register 2 syscall /* all parameter of this system call will be stored in register4, 5, 6, and 7 by MIPS machine automatically. */ .end PrintInt
Part 2-Non-preemptive shortest job first scheduler • Nachos default scheduler: Round Robin • Shortest job first • n+1 = tn + (1- )n • n time of the nth predicate CPU burst • tntime of the nth actual CPU burst • Design several test case to proof your result • E-mail your code and presentation files(report) to TA
Begin Running Invoke Sleep(x) Per timer interrupt: 1.Record actual CPU burst 2.Wake up time up threads 1.Set next predicted CPU burst 2.Insert this thread to Sleeping thread lists 3.Invoke thread->Sleep Non-preemptive shortest job first scheduler • thread/alarm.cc, thread/alarm.h • Implement WaitUntil(int x) to handle sleep(int t) • Add a class to management the threads which are sleeping
More details • http://puremonkey2010.blogspot.tw/2013/05/nachos-40-nachos-system-call.html