CSE 430 - Operating Systems
Spring 2009
Project #1
Due Date: April 20 2009
Overview:
For this project you are to write routines that will allow a program to run, with multiple threads, using NON-preemptive scheduling on most Unix operating systems.
Files:
We are providing 2 files, one is called 430-proj-01.h (bug fix added). This is a standard header that you will need to write the code. The other one is called 430-proj-skeleton.txt that contains pseudo-code depicting what the completed project *may* look like. Also, the slides used in class to describe the projects are here.
Details:
The main data structure used is the PCB which has a fixed type definition, as provided in the .h file. Also, to initialize the PCB you will use the "init_context" routine, which is provided in the .h file.
There are three system calls in Unix/Linux that are to be used, these are "getcontext", "swapcontext", and "sleep". Read the man pages for these and also read articles on the web about these, for example, this page has interesting thread development code.
The first thing you write are queuing routines. The routines take a pointer to the PCB and the header of the Queue (which is also a pointer to a PCB) and inserts the PCB into the queue. The queue is a doubly linked circular list.
The routines are:
Now implement the routines "yield" and "run". The routines are almost completely there in the skeleton file.
Next step, implement the functions to be run as threads. There should be at least 3 functions, each consisting of an infinite loop. Each prints several lines of text, but have "sleep"s embedded between prints to slow things down. At the end of each iteration through the loop, just call "yield()" to switch to the next thread.
Finally, the main routine. This is exactly as shown in the skeleton file.
Compile, run and maybe debug!
Submission:
Source code printout, with comments and proper formatting.
--good luck