QDOS vs Other Operating Systems

Author(s): David Burns
Publication: ZX-Appeal
Pub Details: ZX-Appeal Summer 90
Date: Summer 1990
Pages: 25

QL Australia June 1990

The QL is over seven years old now and many of you well be labouring under the belief that the QL’s operating system, QDOS (QL Disk Operating System), may be a little lacking in capability and features. It is certainly true that it doesn’t have that many bells and whistles when compared with the latest offerings in the microcomputer world, but the basic system was very impressive for its time. Over the next few months I’ll be looking at some of QDOSs features in detail.

So what does QDOS have to offer? The first amazing feature is (I’ll be using present tense throughout this entire article) multitasking. Some of you no doubt are asking… what is multitasking?

It will not surprise any of you that a computer’s CPU is capable of only doing one thing (or instruction) at any one instant… [For the pedants out there, I’ll only be considering single processor systems in this article.] However a microprocessor can operate at speeds usually measured in hundreds of thousands (or even millions) of instructions per second, and thus it is possible to make it seem (to the user, or maybe even users) that the CPU is doing more than one thing at a time. This is achieved by time-slicing the CPU.

At a fixed interval, which on the QL is at the TV/monitor vertical sync rate, 50 Hz (in the US it is 60 Hz), the CPU is interrupted. A special piece of code, known as the scheduler, looks at all of the jobs in the machine and determines (using priorities) which one should get the next time slice. [If there is only one job then this job will get the CPU all to itself.] If the scheduler decides that another job should have a turn, then it performs a context switch. This means that the operating system will save the contents of all registers for the current job somewhere in memory, and then reload the registers with the previously saved state of the other job that is about to be run. Each job proceeds as though it has the CPU all to itself, and it is the responsibility of the operating system to perform all of the necessary housekeeping to keep everything running smoothly.

This setup would be fine if each job only required the CPU and did not have any real world contact, ie input/output. What should happen when a job is waiting for input (or even output, eg. microdrives)? Should the CPU go into a loop waiting for the input to appear, or is it possible to let the CPU get on with something constructive. What most proper operating systems (including QDOS) will do is mark the job as ‘waiting for I/O’. This means that the scheduler will not consider the job at the next interrupt. The job will be reconsidered for a time-slice only when the I/O is ready (ie for reads: the data is waiting, and for writes: the data has been written). This method of operation ensures that the CPU is always being used for real work…

There are other problems as well… Should a job be able to access memory (ie RAM) apart from the area directly used by itself? In most cases the answer will be no and so we need some way of stopping such illegal accesses. This requires hardware, typically in the CPU. The operating system, before passing execution back to a user program (the one which is about to get the next time-slice), sets up the memory limits for the job. Should the job attempt to access memory outside of these limits then a special interrupt, usually called a Illegal Access Exception (or perhaps a Segmentation Violation), will occur. At this point the operating system will intervene and remove the offending job… It is not possible for the job to change the memory limits because this is something that only the operating system can do. [In fact an attempt to do so would cause another special interrupt – a Privilege Violation!] The QL does NOT contain this special hardware and thus it is possible to do naughty things to other jobs in the QLs memory! It also means that faulty jobs can crash the machine…

What are the benefits of multitasking? It really is quite useful to be able to do more than one thing at once… For example it is possible to edit one file whilst compiling another… Another example is that you can print a file out on the printer while doing something else… [It is true that it is possible to print out a file on a MS-DOS computer (a non multitasking operating system) while doing something else; but this requires trickery in the form of interrupt catching. The solution is nowhere near as elegant as the multitasking solution…]

There is another big feature of multitasking – the ability to create pipes. The idea behind pipelines is that to perform some task you use a number of programs; the data passes through all programs in turn. The alternative is to just have one BIG program which does everything; the problem with big programs is that they are difficult/costly to write and/or maintain… I’ll talk more about pipes when I have covered input and output, which I’ll probably talk about next month.

Lastly, it must be said that multitasking is viewed by software writers as being important enough to require a new operating system to be released… OS/2 was developed for two reasons… (a) multitasking, and (b) a more standard windowing environment.

David Burns