1 / 16

Nachos Project Assignment 2 CPU scheduling

Nachos Project Assignment 2 CPU scheduling. TA : 吳哲榮 2010/11/18. Nachos Assignment 2. Abstract You have already learned how OS schedules processes, so this assignment is to implement one by yourself. Implement a system call – Sleep() Non-preemptive shortest job first scheduler.

winka
Download Presentation

Nachos Project Assignment 2 CPU scheduling

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. Nachos Project Assignment 2CPU scheduling TA : 吳哲榮 2010/11/18

  2. Nachos Assignment 2 • Abstract • You have already learned how OS schedules processes, so this assignment is to implement one by yourself. • Implement a system call – Sleep() • Non-preemptive shortest job first scheduler

  3. System Call - Sleep • Please implement Sleep(int x) system call block the thread which called this system call, and return to READY state after x timer interrupts.

  4. System Call - Sleep - Hints • Please study • userprog/exception.cc • userprog/syscall.h • test/start.s to realize how system calls are implemented.

  5. System Call - test/start.s • Assembly language assist to make system calls to the Nachos kernel. Define System call stubs system call code -- r2 arg1 -- r4 arg2 -- r5 arg3 -- r6 arg4 -- r7 The result of the system call, if any, must be put back into r2.

  6. System Call - test/start.s • Take System call PrintInt as an example .globl PrintInt .ent PrintInt PrintInt: addiu $2,$0,SC_PrintInt // 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. */ j $31 .end PrintInt

  7. Declare a new system call – userprog/syscall.h • Define a new system call ID. • Declare the interface for Nachos system calls, which will be called by the user program.

  8. ExceptionHandler - userprog/exception.cc • Fetch system call number in Register 2 • Add new case to the exception handler case SyscallException: switch(type) { … }

  9. System Call - Sleep (Hint) • Modify exception.cc, syscall.h, start.s • Modify thread/alarm.cc, thread/alarm.h to implement WaitUntil(int x) to handle Sleep(int x) system call • Add a new class to manage these threads blocked by calling Sleep(x).

  10. Nachos Scheduling Policy • The Nachos scheduling policy is simple: threads reside on a single, unprioritized ready list, and threads are selected in a round-robin fashion. That is, threads are always appended to the end of the ready list, and the scheduler always selects the thread at the front of the list.

  11. SJF Scheduling • Default Nachos scheduling algorithm isRound-Robin,we are going to implementanothernon-preemptive SJF scheduling • Use n+1 = tn + (1- )n topredictnextCPU burst n : nthpredictedCPU burstlength tn : nthactualCPU burstlength  : setto0.5 (onetimer interruptmeansCPU burstplus1)

  12. Begin Running Invoke Sleep(x) Per timer interrupt: 1.Record actual CPU burst 2.Wakeupnextthreads 1.Set next predicted CPU burst 2.Insert this thread to Sleeping thread lists 3.Invoke thread->Sleep SJF Hint

  13. Invoke Sleep(x) Begin Running Per timer interrupt: 1.Record actual CPU burst 2.Wakeupnextthreads 1.Set next predicted CPU burst 2.Insert this thread to Sleeping thread lists 3.Invoke thread->Sleep SJF Hint • Youneedtomodifyschedule.cc, alarm.cc andtheotherrelatedfiles,andyoumayaddanewclasstomanagerthosethreadsthatblockedbycallingSleep(x).

  14. Assignment Requirements • 1.Implement system call “Sleep” • 2.Implement Shortest-Job-First scheduling • 3.Design several test case to proof your result

  15. Assignment Requirements • Assignment Report (12/23 on the class) • Please compress the following in a .zip. • modified source code(s) with path • presentation power-point • final report • E-mail your .zip (project1_b99901000_b99901001.zip) to TA. • Deadline: 2010/12/23 23:59

  16. Grading Policy • Correct Result 50% • Report 50%

More Related