Session 3220: ?$HX ) 1996 Annual Conference Proceedings .J M&L#
Session 3220: ?$HX ) 1996 Annual Conference Proceedings .J M&L#
John K. Estell
The University of Toledo
1. INTRODUCTION
One of the dilemmas facing instructors of introductory operating systems courses is the development of
suitable programming assignments. It is desirable to expose undergraduate students to realistic projects that
allow them to apply the theoretical concepts learned in lecture; however, great care must be taken not to
overwhelm the student enrolled in this course. Several methodologies have been discussed in the literature over
the years, one of which is the use of simulation. Various papers have described the use of generic simulators
being provided as a framework, writing a multitasking operating system in assembly language for use on a
2 ,
IBM Virtual Machine , developing an operating system for a provided virtual hardware simulator and
4
developing the simulation of the machine along with the operating system .One popular simulation package is
5
the Nachos system ,here
w one is provided with the code for a working instructional operating systetn along
with a machine simulator. The use of simulated machines allows for the avoidance of such potential problems
as architectural idiosyncrasies and programming in a complex and unfamiliar language.
Another dilemma is dealing with the abstract nature of a process. Students initially look at a process as
being the same as a program, for that is how it appears to them as a user when they are learning how to
program: same thing, different names. Now that they have to deal with the internals of a multitasking operating
system, students are left trying to cope with theoretical concepts that are not well defined. Additionally, the
dynamic and concurrent nature of processes on a multitasking system departs from the sequential concepts they
have been exposed to in their previous studies. In order to grasp an understanding of the nature of a process,
students need to work with processes, and the greater the immersion, the greater will be their comprehension.
This paper presents a group project used as a programming assignment for groups of three to four
students in a junior-level introductory operating systems course. The quarter-long assignment, written in C on
a UNIX platform, was broken down into four phases: the initial simulation of the specified computer
architecture and accompanying machine language with the incorporation of a process management model, the
development of process scheduling routines for handling the simultaneous execution of multiple processes, the
development of performance evaluation programs to filter data generated by the simulator, and an extension to
the simulator initiated and designed by each group. Test programs modelling various types of processes were
developed and executed using the simulation and evaluation programs. The results were used to examine the
performance of several process scheduling algorithms under a variety of conditions. Through the development
and implementation of this project, the students gained experience with processes, obtained insight into the
nature of an operating system, learned about simulation methods and furthered their understanding of how
computers operate at the machine instruction level.
Page 1.37.1
In order to allow groups to test their simulators an assembler program for the LS mnemonics was
needed; otherwise, object code would have to be hand-compiled. As this course had a honors section
associated with it which required extra work to be performed, it was decided that writing a simple assembler
would constitute the honors students’ project. The specifications called for a minimal number of assembler
directives: “byte” specifies data to be stored, “.blkb” reserves memory space, “ start” indicates the start of the
executable portion of the source file, and “stop” indicates the end of assembly. To simplify matters, a label
format consisting of a letter followed by a digit was adopted. This assignment was given to the honors students
at the beginning of the quarter. Its completion was scheduled such that a working assembler program would be
available to the groups for at least one week prior to the deadline for the first phase of the simulation program.
The object file generated by the assembler consists of ASCII hexadecimal characters, with each line
containing two characters to form one machine code. This format was chosen so that, if the need arose, object
files could be easily sight-verified. The LS system operates on a relative addressing scheme; therefore,
addressing begins at relative location 0000. The first word in the object file gives the offset, in low byte - high
byte order, to the first executable machine code in the file. This information is used by the LS loader to
properly adjust the PC for beginning the execution of the process created for this program. The remaining
bytes are the data and machine codes that make up the program.
A process is executed by specifying its program object file as a command line parameter when invoking
the simulator. A process control block and a PID are created for the process, the program’s object codes are
stored in the simulator’s memory, and memory is allocated for the process stack. The dispatcher begins the
execution by performing a context switch, giving the processor to the process. The dispatcher is a system-
owned process that executes the scheduling algorithm that controls the use of the processor. The basic
simulation uses the first-come, first-served (FCFS) scheduling algorithm. The process has control of the
processor until it either terminates or is blocked by an 1/0 request. When a process is blocked, it is assumed that
a fixed number of clock cycles will elapse before the request is serviced and the process is unblocked. The
output from the simulator is a trace in column form of the activity during the simulation. In order, the output
gives on each line the cumulative clock cycle time when the event occurred, the PID of the affected process,
and the reason for the context switch. A PID of zero indicates the dispatcher process.
Two scheduling algorithms were added to the simulation: round robin (RR), and shortest remaining
time (SRT). The RR algorithm is similar to the FCFS algorithm, but with the inclusion of preemption to allow
for switching between processes. Preemption is based upon allowing a process to execute in the Running state
only up to a specified maximum amount of time referred to as a time slice. When a process is preempted, it is
placed at the rear of the ready queue, and the next process to run is taken from the head of the ready queue. For
the simulation, the time slice was specified as a passed parameter expressing the time slice in terms of number
of clock cycles. By allowing the students to set the time slice value at run time, one sets the stage for
experimentation into the effect of varying time slices to be conducted later on in the course. The SRT algorithm
Page 1.37.3
7. RESULTS
Student comments obtained from both discussions and anonymous evaluations indicate that this
project was a positive experience. By developing the simulation students gained a greater understanding of
both the amount of work and the complexity involved in developing an operating system. The LS computer
simulation contained, on average, 3000 lines of code distributed over several modules. While this is minuscule
compared to the size of a modern operating system, students still experienced the frustration of yet another bug
cropping up during testing, and thereby appreciated the comment made at the beginning of the quarter that
operating systems are never fully debugged. While only about a third of the groups in the class had everything
working correctly, all of the remaining groups had most of their simulation working according to specifications.
The portions not working were minor flaws that did not properly execute one or two test programs.
The project, by itself, allowed the students to learn first hand about such things as what information is
necessary when performing a context switch, what things have to be done in order to fork a process, and how
one can implement interprocess communication. The students also experienced having to develop test
programs for the purpose of analyzing system performance. However, other lessons not directly related to the
project were learned as well. For many students this was the first “real” program that they have worked on -
Page 1.37.5
REFERENCES
1. M. Cartereau, “A Tool for Operating System Teaching,” SZGCSE Bulletin, Vol. 26, No. 3, pp. 51-57,
September 1994.
2, J. L. Donaldson, “Teaching Operating Systems in a Virtual Machine Environment,” SZGCSE Bulletin, Vol.
19, No. 1, pp. 206-211, February 1987.
3. T. Hayashi, “An Operating Systems Programming Laboratory Course,” SZGCSE Bulletin, Vol. 15, No. 1, pp.
31-35, February 1983.
4. C. Shub, “A Project for a Course in Operating Systems,” SIGCSE Bulletin, Vol. 15, No. 1, pp. 25-30,
February 1983.
5, A. Silberschatz and P. B. Galvin, Operating System Concepts, 4th edition, Addison-Wesley, Reading, MA,
1994.
6. W. Stallings, Operating Systems, 2nd edition, Prentice Hall, Englewood Cliffs, NJ, 1995.
JOHN K. ESTELL
Dr. Estell received his BS degree (summa cum laude) from The University of Toledo in 1984. Awarded
NSF Graduate and Tau Beta Pi Fellowships, he received his MS and PhD degrees in Computer Science from
the University of Illinois at Urbana-Champaign in 1987 and 1991. Dr. Estell is a member of ACM, ASEE,
IEEE, Eta Kappa Nu, Phi Kappa Phi, and Tau Beta Pi.
Page 1.37.6