OS/Pintos Project

[Pintos] Assignment 3 – Implement Priority Scheduling in Pintos

Binceline 2014. 4. 20. 05:41

http://pintosiiith.wordpress.com/2012/10/15/assignment-priority-scheduling-pintos/


This post will guide you how to implement priority scheduling in Pintos.

Background:

When a new thread is created, you can specify the priority for the thread as an argument to thread_create() which is ignored currently. You need to use that priority to handle the scheduling.

Requirements:

Priority scheduling’s scope for this assignment is reduced as compared to original assignment created by Stanford. You can check the complete scope here.

There are two cases:

1. When a thread enters ready queue with priority higher than running thread, then lower priority thread must yield the CPU and higher priority thread must be scheduled.

2. A thread may raise or lower its own priority at any time, but lowering its priority such that it no longer has the highest priority must cause it to immediately yield the CPU making way for the higher priority thread in the ready queue.

Priority range:

PRI_MIN           – 0 – lowest

PRI_DEFAULT – 31 – default

PRI_MAX           – 63 – highest

Code changes:

You need to implement thread_set_priority and thread_get_priority declared in threads/thread.c to simulate the scenario mentioned above.

Approach:

1. As you are familiar with thread structure from previous assignment, it will be easy for you to find the code you need to understand and change.

2. If not already understood, please go through the thread structure defined in thread.h that has the priority field that will help you implement the assignment.

3. Identify the changes and implement them.

Test cases:

  • alarm-priority
  • priority-change

Other test cases provided in Pintos for priority scheduling won’t pass as the scope of priority scheduling in original assignment is much higher.

To test your implementation further, write small programs that create threads with different priorities. Add this file to Pintos kernel as you did in 1st assignment and run it to verify your implementation.

Happy Coding!!!

- Rasesh Mori

반응형