Nachos Project Assignment 2 CPU scheduling

advertisement
Nachos Project Assignment 2
CPU scheduling
If you still have trouble to install Nachos
• https://code.google.com/p/damody/downloads/detail?name=mipsdecstation.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
• tn time of the nth actual CPU burst
• Design several test case to proof your result
• E-mail your code and presentation files(report) to TA
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
Begin Running
Per timer interrupt:
1.Record actual CPU burst
2.Wake up time up threads
Invoke Sleep(x)
1.Set next predicted CPU burst
2.Insert this thread to Sleeping thread lists
3.Invoke thread->Sleep
More details
• http://puremonkey2010.blogspot.tw/2013/05/nachos-40-nachossystem-call.html
Download