This is a continuation of my series of articles on CP/M. It follows my fourth CP/M article.
The series starts with my first CP/M article. If you have not read the previous articles, I recommend that you read them first.
Multi-Programming Control Program
MP/M is a multitasking and multi-user version of CP/M. It uses serial ports to communicate with up to seven VT100 terminals.
Using altairz80 the serial terminals can be emulated by telnet connections.
$ sudo altairz80 mpm
Using another terminal window, connections can now be made using telnet.
$ telnet localhost
The current configuration is a single-user CP/M 2.2. But MP/M adds more functionality. Apparently MP/M is started as a transient CP/M program named MPM.COM. (To disconnect the telnet session send the group-separator symbol, i.e. ctrl-].).
Starting MPM.COM replaces CP/M in memory with MP/M.
MP/M uses banked memory, switching between physical banks of memory when switching between users and processes. (Incidentally, MP/M returns a version number 3.0 even when run on what appears to be CP/M 2.2.)
There are up to eight memory banks supported and at least two must be present. Each bank is, in this emulated system, 44 KB in size, going from address 0000h to address B000h. The operating system, as visible from a programm running in one bank is located at address 8Fooh and goes to the end of memory at FFFFh. The operating system also uses bank 0. Banks 1 to 7 are used by transient programs run by different users.
According to the MP/M handbook, each bank can be up to 48 KB in size with 16 KB of common memory at the top of memory. This means MP/M can use up to 400 KB (8*48 KB + 16 KB) of memory, which is quite a lot for an operating system released in 1979 when microcomputers typically had 16 or 32 KB of memory, with 64 KB being reserved for high-end systems.
Recall the memory configuration on single-user CP/M:
MP/M organises memory differently. The operating system switches between several banks of memory. The CPU sees exactly one of those banks at a time.
Bank 0 contains the main portion of the operating systems. Banks 1 to n (with n being 7 at max) contain only enough of the common memory so that transient programs can call the operating system which will then bank-switch to bank 0 and execute the operating system function before returning to the calling bank.
Apparently a common use scenario of MP/M was not in multi-user environments but as a single-user multitasking operating system.
The user can detach from a running program by sending an end-of-transmission (ctrl-d) and re-attach by using the ATTACH command.
Alternatively the transient program itself can attach and detach the console using BDOS calls 92h and 93h. I try to demonstrate this in the program below.
A copy-and-pastable version of the program can be seen here.
Note that msg1 is displayed before the console detaches. The program then copies msg2 into msg3 and then calls the attach BDOS call (92h) to wait for the user to attach a console. Note that attach does not actually attach the console but waits the program until the user runs the ATTACH command.
Calling attach is not actually necessary (or even useful) since it will be called automatically by the operating system when the transient program attempts to write to the console, which it here does after calling attach.
I am copying msg2 to msg3 after calling detach to demonstrate that the program is actually running while the console is detached.
Note that a program using the attach and detach calls will not run on single-user CP/M or other single-user operating systems that are otherwise compatible.
Since attach is called automatically whenever the program tries to write to the console (or read from it) all clean CP/M programs should work on MP/M even when sent to the background and the multitasking will be useful if the program is able to process data without logging to the console what it is doing. I assume that generally specific programs were written for MP/M and existing CP/M programs were not usually run in the background.
The new features of MP/M were later included in single-user versions of CP/M as well.
Banked memory was first introduced in CP/M Plus (aka CP/M 3.0) in 1981. And multi-tasking finally arrived in single-user CP/M a few years later in Concurrent CP/M-86 for 16 bit computers in 1984.