Skip to content

122B ReserveResource

Validated   MON 122B (82 decimal) · Mnemonic RESRV · Group: File Operations (manual section 2.4)

Available from: All programs (manual compatibility box)

Emulation source: src/handlers/mon_122B_ReserveResource.c

Description

Reserves a device or file for your program only. You release it with ReleaseResource. Some devices, e.g. terminals, have both an input and output part. You can only reserve one part with each ReserveResource call.

  • A normal termination of an RT program releases all resources.
  • Release the device with ReleaseResource or ForceRelease.
  • A background program does not release a resource when you press the ESCAPE key.

Parameters

Name Type Direction Description
DeviceNo INTEGER2 In Logical device number. See appendix B.
IOFlag INTEGER2 In Input/output flag. 0=input part, 1=output part.
WaitFlag INTEGER2 In Wait flag. 0=wait if reserved, 1=return status value.
Status INTEGER2 Out Return status (output). Only used if WaitFlag=1. Negative=already reserved.

Direction: In = the program supplies the value, Out = the call returns it, In/Out = both.

See also

ForceReserve, ReserveDir, @RESRV, @RESERVE-FILE, and @RESERVE-DEVICE-UNIT

Compatibility

Machines Users Programs
ND-100 and ND-500 All users All programs

The manual's compatibility box for this call, word for word.

Yes/no fields from the YAML extraction (not in the manual's words):

ND-100 ND-500 User programs RT programs System programs
Yes Yes Yes Yes No

Examples

From the manual (OCR text, not corrected).

INTEGER: DeviceNo, IOFlag, WaitFlag, ReturnStatus
...
Monitor_Call('ReserveResource', DeviceNo, IOFlag, WaitFlag, ReturnStatus)
INTEGER DevNo, IOFlag, WaitFlag, ReturnStatus
...
Monitor_Call('ReserveResource', DevNo, IOFlag, WaitFlag, ReturnStatus)
DeviceNo, IOFlag, WaitFlag, ReturnStatus : INTEGER2;
...
ReserveResource(DeviceNo, IOFlag, WaitFlag, ReturnStatus);
01 DevNo COMP.
01 IOFlag COMP.
01 WaitFlag COMP.
01 RetStatus COMP.
...
MONITOR-CALL "ReserveResource" USING DevNo, IOFlag, WaitFlag, RetStatus.
DeviceNo : W BLOCK 1
IOFlag : W BLOCK 1
WaitFlag : W BLOCK 1
Status : W BLOCK 1
ReserveResource : EQU 37B9 + 122B
...
CALLG ReserveResource, 3, DeviceNo, IOFlag, WaitFlag
W1 =: Status
LDA (PAR %Load register A with address of parameter list.
MON 122 %Monitor call ReserveResource.
...
PAR, DEVNO %Logical device number.
IOF %Input/output flag.
WFLAG %Wait flag
STAT %Status

| DEVNO, ... |   |
|------------|---|
| IOF, ...   |   |
| WFLAG, ... |   |
| STAT, ...  |   |

ndmonlib implementation

Validated Registered MON_STATUS_VALIDATED in src/core/mon_registry.c: implemented, tested and working.

Handler mon_122B_ReserveResource
Code lines 35 (non-blank, non-comment lines in the file)

Emulation research

Source

This section comes from the emulation: block of the call's YAML file in the NDInsight repo. It records what was learned while implementing the call in nd500x; its status is nd500x's, not ndmonlib's.

Status (nd500x) implemented
nd500x handler nd500x/src/libmon/handlers/mon_122B_ReserveResource.c
Last updated 2026-07-17

Note

Real bookkeeping against the nd500x device-reservation table (mon_reserve_device in src/libmon/mon_file_table.c), not a stub. There is no other process in the emulator, so a reservation can only ever collide with the caller's own earlier reservation.

Parameter notes

1. Status

Field Value
Note OUT parameter, and CONDITIONAL: the manual says it is only used when WaitFlag=1, and nd500x writes it only when WaitFlag != 0 AND a 4th argument was supplied. OUT-PARAMETER DEFECT CLASS - if you take the WaitFlag=1 path and return without writing this word, the caller reads a stale cell and the failure surfaces far away and much later (the shape of the 412B FSCNT bug, commit 73ac594, and the 144B MAGTP function-0 bug, commit 6ad9c09). Writing it is part of the contract.
Verified Yes

2. WaitFlag

Field Value
Note 0 = wait if busy, 1 = return status immediately. nd500x passes (wait_flag == 0) as its "may block" argument to mon_reserve_device.
Verified Yes

3. IOFlag

Field Value
Note 0 = input part, 1 = output part. One part per call.
Verified Yes

4. DeviceNo / IOFlag / WaitFlag / Status

Field Value
Note On ND-500 every one of these INTEGER parameters is a 32-bit word (W BLOCK), read with mon_read_param_word. The manual types them INTEGER2 for the ND-100 16-bit form.
Verified Yes

Return contract

  • Success: K flag cleared; the device part is marked reserved.
  • Errors

    Code Octal Meaning
    111 157B Missing parameter (fewer than 3 arguments supplied)
    133 205B Device already reserved

Verified

1. MON 122B dispatches via MCTAB to the L07 worker RESRV in segment 003-S3CP.

Field Value
Evidence Carve L-VSX-500 122B-ReserveResource/README.md: MCTAB slot (segment 044-S3IDPIT, byte offset 1988) = 037103B = RESRV; RESRV worker body carved at 037103B-037155B in 003-S3CP (byte offset 7302). Reproduced: dd if=044-S3IDPIT.bin bs=1 skip=1988 count=2 -> 3e 43.

2. Error 133 decimal = 205B "Device already reserved" is a real SINTRAN code.

Field Value
Evidence Commit 6b57202 replaced invented codes with the manual's Appendix A table (ND-60.228.2 EN, "Error Returns from SINTRAN III Background Programs"); mon_errors.h records MON_ERR_DEVICE_ALREADY_RESERVED = 133 (205B). Note the emulator stores the DECIMAL column in W1 while SINTRAN returns the octal number.

Unverified

  • NO WAITING IS IMPLEMENTED. With WaitFlag=0 the manual says the program waits until the resource is free; nd500x never blocks - it returns error 133 either way. Unobserved so far because nothing else contends.
  • The SIGN of the Status output. The manual and the nd500x registry say "negative = already reserved"; the handler writes through whatever mon_reserve_device returned (negative on failure) without normalising it to a documented value. The exact value SINTRAN returns is not read from a manual or the carve.
  • The RESRV worker body is carved but was NOT decoded for this note, so the real reservation semantics (queueing, RT priority, what "device" means for an open file) are unread.
  • "A normal termination of an RT program releases all resources" and "a background program does not release a resource when you press ESCAPE" are not modelled - nd500x's 0B LEAVE only halts the CPU.

Sources

Doc Note
NDInsight/tools/sintran-segment-carver/versions/L-VSX-500/re/mon-analysis/122B-ReserveResource/README.md MCTAB[122B] = RESRV = 037103B, worker carved in 003-S3CP.
SINTRAN III Monitor Calls (ND-60.228.2 EN) Appendix A error table - the source of 205B/133. See src/libmon/mon_errors.h.

Source

SINTRAN III Monitor Calls (ND-860228.2 EN), page 419.