This assignment is due on Wednesday, 11 October, no later than 2:00 p.m.
This assignment implements a simple batch-oriented operating system, which behaves as follows:For simplicity, you may assume the programs are to be run in the order they're read from the batch disk. That is, it is not required that the operating system scan the batch disk with the idea of packing primary storage with as many programs as possible; first-come, first-serve scheduling is good enough for this assignment.
- After the operating system boots up, it reads programs from the batch disk and executes them.
- The operating system supports multiprocessing; that is, whenever possible, there may be more than one program executing at the same time.
- When all programs have been read and executed, the operating system terminates.
The operating system should execute as many programs as possible. In particular, if one program fails due to some error condition, the operating system should throw it out and read the next program. Under no circumstances should a failing program cause the operating system itself to fail.
A batch disk is a disk containing a set of programs to be run. The first block (block 0) of a batch disk is the program index; the program index gives the list of programs to be run. If a batch disk contains n program, the program index for the batch disk has the following structure:The value sizej gives the size of the j-th program in disk blocks; sizej will always be greater than zero. The program-index list always ends in zero, which means that 0 <= n <
word 0: size1 word 1: size2 . . . . . . word n - 1: sizen word n: 0 disk_block_size
, where n is the number of programs in the batch disk.Programs occupy consecutive disk blocks starting with disk-block 1, the block following the program-index block. A program always occupies a positive number of blocks, and each program follows the next with no wasted disk blocks between them.
For example, this diagram
shows a batch disk containing three programs. The first program has size 3; that is, the first program occupies three disk blocks. The second program has size 1 and the third program has size 2.![]()
A program is laid out on disk as a sequence of disk blocks. The order of the program's contents on disk must be preserved in primary storage when a program is loaded into primary storage for execution. The program's disk-block contents must not be re-arranged in primary storage, and all the program's disk blocks must be read into primary storage before the program can be run.The program is loaded in primary storage in increasing address order. The contents of the program's first disk block is loaded into primary storage starting at location i; the contents of the program's second disk block is loaded into primary storage starting at location i +
disk_block_size
; and so on.Once loaded into primary storage, the program's first instruction has address i, the address of the first word of the program. The program counter should be set to i when the program first executes.
The test programs your operating system will execute make two system calls: sleep and exit; part of this assignment is to implement these system calls. These are the first two of many system calls you will be implementing in these assignments, so you might want to give some though to designing an easily changeable system-call implementation (or, you have to be willing to throw-away and rewrite your system-call implementation several times, which is probably the better approach to take anyway).
You will need to implement four interrupt handlers for this assignment: the reboot interrupt handler, the disk interrupt handler, the countdown interrupt handler, and the system-call interrupt handler. The reboot interrupt handler installs your operating system in the hardware; the disk interrupt handler takes care of interrupts from the disk; the countdown interrupt handler deals with clock interrupts; and the system-call interrupt handles system calls from the executing process. As with system calls, you'll be implementing and re-implementing several other interrupt handlers in later assignments, so some thought now may save you some pain later.
There are two batch disks available you can use to test your operating system. The first batch disk,pa1-nosleep.dsk
, contains programs that call only the exit system call. The second batch disk,pa1.dsk
, contains programs that call both the exit and sleep system calls. As a general plan of attack, you could get your system working withpa1-nosleep.dsk
and then move on to get it working withpa1.dsk
.I will eventually make the assembler and loader I use to create the batch disk available so you can create your own test disks. If enough people clamor for them, I'll make them available sooner rather than later.
This page last modified on 2 October 2000.