COSC 125 Operating Systems

Spring 2006

Homework Assignment #5

Priority Scheduling and Process Termination

Due: Wednesday, March 08, 1:00PM CST
Submit: E-mail tar-ball (see below) of operating system code to professor, with a subject header "COSC 125 HW#4, Team ???".
Work may be completed in pairs. Each team should submit only once. Be certain to put both team member names on work submitted. It would be courteous to carbon-copy your partner when e-mailing the final submission.
Preparation

First, make a fresh copy of your work thus far.
   cp -R xinu-hw4 xinu-hw5

Untar the new project files on top of this directory:
   tar xvzf ~brylow/cosc125/xinu-hw5.tar.gz

You should now see the new project files in with your old files. Be certain to make clean before compiling for the first time.
Priority Scheduling

Add priority scheduling to your operating system. This can be done in 4 easy steps:

  • Add a priority field into PCB structure defined in include/proc.h.
  • Add priority parameter to create(), and properly initialize the priority field in each new PCB created.
  • Complete the new function in system/insert.c to implement a priority sorted ready queue. This does not require making any modifications to the primary queue maintenance functions already in system/queue.c.
  • Modify the ready() and resched() functions to properly use your new priority scheduler.
  • New testcases are in system/main.c, which should demonstrate priority-order execution once your new scheduler is operational. You will need to create others to fully test your implementation.
    Termination

    Our implementation of process creation and context switching contains a subtle bug that only appears when a process terminates. When the main() program exits, for example, we expect it to return to the userret() function defined at the bottom of system/create.c, which in turn calls kill(), which should end the process, clean up its resources, and call resched() to transfer control to another process in the ready queue.

    Uncomment the kill() line in userret(), at bottom of system/create.c, and repair the bug that prevents a terminating process from reaching kill().


    The new source files also include:

  • system/initialize.c Updated initialization for Project 5.
  • system/main.c A new "main program" for testing scheduling.
  • system/getpid.c A function that returns the current PID.
  • system/kill.c Kills a given PID, and cleans up its PCB.
  • system/xdone.c A function that is run only when all other XINU user processes have exited.
  • compile/Makefile Updated rules for compiling XINU.

  • Back