An Operating System (OS) is a collection of software services, designed to close gaps between the computer's hardware and application software. For example, if you use a high-level langauge to write a program that prompts the user to enter some data using the keyboard, the code generated by the compiler will include (among other things) calls to OS routines that handle keyboard inputs. Therefore, the OS can also be viewed as an extension of a high-level programming language. This is a rather simplistic view of operating systems, but it will suffice for our purpose.
Implement the Jack OS specified in Chapter 12. In the process of building this OS, you will implement a modular collection of some beautiful algorithms in applied computer science. Thus, you will also be exposed, hands-on, to some cool computer science stuff.
Write a Jack OS implementation and test it using the programs and testing scenarios described below.
Chapter 12 includes the Jack OS API, which has to be implemented in this project. The main tool needed is Jack,the high-level programming language with which you will build the OS (just like Unix is built in C). You will also need the supplied Jack compiler, to compile your OS implementation as well as the supplied test programs, and the supplied VM Emulator, to run and test the compiled code.
The OS is implemented as a collection of 8 Jack classes. Each class can be implemented and unit-tested in isolation, and in any desired order. To develop, compile, and test each OSClass.jack class in isolation, follow this procedure:
-
Put the OSClass.jack that you are developing in the same directory that includes the supplied test program designed to test it;
-
Compile the directory using the supplied Jack compiler. This will result in compiling your OSClass.jack as well as the supplied test class files. In the process, a new OSClass.vm file will be created;
-
Load the directory into the supplied VM Emulator;
-
Execute the code and check if the OS services are working properly, according to the guidelines given below.
Recall that the supplied VM Emulator features a built-in implementation of the entire Jack OS. With that in mind, the rationale of the above procedure is as follows. Normally, when the supplied VM Emulator encounters a call to an OS function, it handles the call by invoking a built-in implementation of that function. However, if the compiled directory contains a .vm file that includes a VM implementation of the function, this implementation will be executed, short-cutting the built-in implementation. This practice follows the reverse engineering spirit of GNU Unix and Linux: it allows you to build and test different OS modules in isolation, as if all the other OS modules are implemented properly and operating side-by-side with the currently-developed module. That's important, since the OS class that you are presently developing may well include calls to the services of other OS classes.
There are eight OS classes: Memory, Array, Math, String, Screen, Keyboard and Sys. For each OS class Xxx we supply a skeletal Xxx.jack class file with all the required subroutine signatures, corresponding test class named Main.jack, and related test scripts.
OS Module
Test Programs
Guidelines
The test programs supplied above don't entail a full test of the Memory.alloc and Memory.deAlloc functions. A complete test of these memory management functions requires inspecting internal implementation details not visible in user-level testing. This can be done via step-by-step debugging in the supplied VM Emulator.
The remaining test programs include no test scripts. They should be compiled and executed on the supplied VM Emulator as follows:
OS Module
Test Programs
Desired Test Results (Actual Screen Shots)
After testing successfully each OS class in isolation, test your entire OS implementation using the Pong game, whose source code is available in your projects/11/Pong directory. Put all your OS .jack files in this directory, compile it, and execute the game in the supplied VM Emulator. If the game works, then congratulations: you are the proud owner of an operating system written entirely by you. And, by the way, you've just completed the construction of a complete general-purpose computer system. Go celebrate!