1 / 14

Nachos Assignment#2

Nachos Assignment#2. Priority Scheduling. Nachos scheduling policy :FIFO. Jobs run to completion in order of arrival. In interactive systems, run until I/O; after I/O completes, put back at end of queue . Response time poor . Scheduling is handled by routines in the Scheduler object:.

luisweaver
Télécharger la présentation

Nachos Assignment#2

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 Assignment#2 Priority Scheduling

  2. Nachos scheduling policy :FIFO • Jobs run to completion in order of arrival. • In interactive systems, run until I/O; after I/O completes, put back at end of queue . • Response time poor . • Scheduling is handled by routines in the Scheduler object:

  3. Scheduler • The scheduler is invoked whenever the current thread wishes to give up the CPU • For example, the current thread may have initiated an I/O operation and must wait for it to complete before executing further

  4. Implement priority scheduling • Add the method void Thread:SetPriority (int p) to set the priority of a thread. • When the scheduler makes a decision as to next thread to run from the readyList,it selects the thread with the highest priority. • The higher the value of p, the higher the priority.

  5. Thread introduction • Status: • READY: • RUNNING: • BLOCKED: • JUST_CREATED:

  6. Thread introduction • Some operations: • Fork(VoidFunctionPtr func, int arg) • Initialize the stack and put the thread on the ready queue • void Yield() • Suspend the calling thread and select a new one for execution

  7. Class “thread” • Add member data “priority” • Add member function • getPriority • setPriority

  8. Class “list” • Original: • void Prepend(T item); • void Append(T item); • Add following method (e.g.): • Void SortedPrepend(); • Void SortedAppend();

  9. void ReadyToRun(Thread *thread): • Make thread ready to run and place it on the ready list • It simply changes its state to READY and places it on the ready list • ReadyToRun is invoked, for example, by Thread::Fork() after a new thread has been created. • Modify: readyList->Append(thread);

  10. Thread *FindNextToRun(): • Select a ready thread and return it. • FindNextToRun simply returns the thread at the front of the ready list. • Modify: return readyList->RemoveFront() //If priority of selected thread is lower,put it back and return NULL

  11. void Run(Thread *nextThread): • Do the dirty work of suspending the current thread and switching to the new one. • Note that it is the currently running thread that calls Run(). A thread calls this routine when it no longer wishes to execute. • Change the state of newly selected thread to RUNNING

  12. Project grading policy • Primary requirement • Priority scheduling implementation :85% • Documentation :15% • Bonus • How to verify your work?: +20%

  13. Project Deadline • 6/25 24:00 • E-mail your project to r91050@im.ntu.edu.tw • Use student id as file name.(one of the two group member) Ex:R91725050

  14. Your files SHOULD include: • Modified files • Test files (Bonus) • 5 page-report • Do not put source code in your report. • Explain why you chose to modify these files. • Problems encountered and your solution • Anything else. • Package your files in .tar or .zip format.

More Related