COSC 125 Operating Systems

Spring 2006

Homework Assignment #4

Context Switch and Non-Preemptive Scheduling

Due: Wednesday, March 01, 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 fresh copy of your work thus far. Login to Morbius, and change to your working directory, the directory that contains your xinu-hw3/ subdirectory. To recursively copy the entire directory to a new directory,
   cp -R xinu-hw3 xinu-hw4
You should now find a xinu-hw4/ directory with copies of all of your driver files from the previous assignment. The name of this directory must be " xinu-hw4", or the next step will not work.

Untar the new project files on top of this directory:
   tar xvzf ~brylow/cosc125/xinu-hw4.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.
Context Switch

The new source files include two new headers, include/proc.h (definitions for Process Control Blocks and a process table,) and include/q.h (definition for a process ready queue,) as well as trivial updates to include/kernel.h.

The new source files also include:

  • system/initialize.c Updated initialization for Project 4.
  • system/main.c A "main program" for testing scheduling.
  • system/queue.c An implementation of the queue data structure.
  • system/create.c A partial function for creating a new process.
  • system/ctxsw.S An incomplete assembly routine for switching process contexts.
  • system/ready.c A function for adding a process to the ready queue.
  • system/resched.c The primary scheduling code, equivalent to yield().
  • system/getstk.c A rudimentary function for dynamically allocating new stacks for new processes.
  • compile/Makefile Updated rules for compiling XINU.

    The create() and ctxsw() functions are incomplete and must be filled in. The major locations are marked with "// TODO...". File system/initialize.c contains code to test your context switch with three processes, each of which print a process ID and then yield. Once your context switch and creation functions are working, you will see these three processes taking turns running.


    Back