This is a cache of https://vccplus.brianholman.com/manuals/working-with-os9/modules/. It is a snapshot of the page as it appeared on 2026-11-21T00:01:40.973+0000.
Where does a program live? · Working with OS-9 — A Comprehensive Manual · VCC Plus
← Manual LibraryVCC Plus 3.7.1 · Reading on the web

Try the exercises in VCC Plus. Example links download files here; open them in the app to work beside the emulator.

The complete book · PDF editionBook 11: Working with OS-9 — A Comprehensive Manual

51 pages · VCC Plus 3.7.1 · Keep a copy to read or print.

Download PDF
Contents

Chapter 8 of 14

Where does a program live?

A copy of Echo is on disk. There is also an Echo in the running system’s module directory. Its instructions can serve one shell and then another. Each invocation still needs its own arguments, writable storage and stack.

Read a module’s identity

ident /dd/cmds/echo
mdir

ident examines the named disk file. In the supplied edition, look for the name Echo, size $0022 (34 bytes), execution offset $0012 and a good module CRC. Offset $0012 means the first instruction is 18 bytes from the start of the module. The header tells the loader where to begin. The CRC checks the module’s bytes against the check value recorded in the file.

mdir lists modules currently known to the kernel. The prepared boot loads a group of frequently used utilities, so Echo is already there. A file may contain several modules, each with its own header, name and entry in memory. A module can also be a file manager, driver or device descriptor. A name present in mdir alone tells you little about whether that name makes sense at a command prompt.

Count references you create yourself

Use a fresh practice boot with no other job using Cmp. Here Cmp is the small file-comparison program. Use the lowercase letters mp in the filter to match the ending of Cmp as it is printed.

load cmp
mdir -e ! grep mp
link cmp
mdir -e ! grep mp
unlink cmp
mdir -e ! grep mp
unlink cmp
mdir -e ! grep mp

Read the last number before the name. The four checks on our guest gave 1, 2, 1, and finally no Cmp row.

Four queries for Cmp show its use count climb from 1 to 2 and drop back to 1. The last query has no matching row.

load brought the program from the execution directory into memory and retained a reference. link found that named module in memory and retained a second reference. Each unlink released one. The disk file remains available after the module leaves memory. If other processes have acquired the module, their references also count. Release only the references you created. For boot modules, keep the system’s existing references intact.

Give each caller somewhere to write

A re-entrant program can serve multiple callers using one copy of its code. Position-relative addressing lets a reference inside that code keep pointing to the same item after the module is placed in memory. Per-process data and a private stack give different executions a place to store different answers. Code that stores a changing counter directly into its shared instructions or embedded constants would break that arrangement.

The directory of running processes therefore answers a different question from the directory of modules. In the preceding chapter you found several Shell processes. In the next chapter you will see several of them map the same physical code block. For the header layout and module CRC see The NitrOS-9 Project, NitrOS-9 Technical Reference, revision 0.1 (2004), chapter 3, pp. 26–32.

Original VCC Plus manuals © 2026 Brian K. Holman. Third-party references retain their authors’ copyrights and licenses. Artwork notices. Edition 3.7.1; source and export identity. Printable edition: PDF source and export identity.

A closer look

Open original