CP/M-86 4.1 Process Table

In CP/M-86 4.1, the process table is at 08E0h in the CP/M data segment. Each entry is 0160h bytes long. Although entries are contiguous (and CP/M-86 assumes they always are contiguous) each entry contains a pointer to the next, as if they were on a linked list. Perhaps this is for compatibility with Concurrent CP/M.

Process table entries must be segment-aligned, because CP/M-86 accesses an entry by pointing ES at its base and treating it as a separate segment (though it is in fact contained within the CP/M data segment).

In keeping with this approach, CP/M-86 stores addresses of process table entries as segments rather than offsets. Three addresses within its data segment are:

004Ah
Foreground process (the one that owns the screen and keyboard).
004Eh
Active (running) process.
0050h
Process table base.
(note that all the above addresses hold segments, not offsets. The system file contains offsets, but these are converted to segments at a very early point in system startup).
Offset  Size    Data            Description
============================================================================
00	DW	nextready	; Next runnable process.
02	DW	next		; Next process in the table. This
				; never changes. In the system file this
				; field is an offset; it is converted
				; to a segment at system startup. 
04	DB	state		; Process state
				;   0 = Process is runnable
				;   1 = Process is waiting on timer
				;   2 = Entry is free (no process)
				;   3 = Process is waiting on system flag
05	DB	pid		; Process ID 0-3
06	DW	flags		; Process flags, bitmapped.
				; Bit 0: Process has been told to terminate
				;       and will do so when next scheduled.
				; Bit 1: Process is using the 8087
				; Bit 2: To do with process loading?
				; Bit 3: Process is still being
				;        loaded (in the P_LOAD call)
				; Bit 15: console mode is non-default value
08	DB	name		; Process name, 8 bytes.
10	DB	incpm		; InCPM flag for process - set if the
				; process is currently in a CP/M call
11	DW	dirname		; Offset of current directory
				; structure for this process in the CP/M data 
				; segment
13	DB	indiskbdos	; Set if the process is currently in a
				; CP/M call using the disk system.
14	DW	errorcode	; Error return code for this program
16	DW	consolemode	; Console flags for this program
18	DB	background	; Nonzero if this is a background process
19	DB	delimiter	; String delimiter used by CP/M function 9
				; (usually '$') 
1A	DW	sp		; Process's registers
1C	DW	ss		; (if process is not running)
1E	DW	ax
20	DW	bx
22	DW	cx
24	DW	dx
26	DW	di
28	DW	si
2A	DW	bp
2C	DW	es
2E	DW	xds		; If process is in a BDOS call, these are
30	DW	xes		; the caller's DS, ES and SS:SP.
32	DW	xsp
34	DW	xss
36	DB	drive		; Current drive for process
37	DB	uid		; Current user number for process
38	DD	dma		; DMA address for process

; The next 20 bytes hold BDOS state for this process.

3C	DB	fx		; CP/M function number of current BDOS call
3D	DB	?
3E	DD	find1st;	; FCB parameter for last "FindFirst" call
42	DW	?		
44	DW	?		
46	DB	errmode		; Action on fatal errors:
				;  0FFh, report to program
				;  0FEh, report to program and display error
				;  Others: Terminate program and display error
47	DB	multisec	; Number of 128-byte records to read/write
48	DB	passwd		; Default password to use for file access
				; (8 bytes)
; end of BDOS state

50	DW	countdown	; Number of ticks before process becomes
				; runnable (if state == 1)
				; System flag process is waiting on 
				; (if state == 3)
52	DD	bdos		; Segment:offset address of the BDOS entry
				; point used by this process
56	DD	int0		; INT 0 vector for this process
5A	DD	int1		; INT 1 vector for this process
5E	DD	int3		; INT 3 vector for this process
62	DD	int4		; INT 4 vector for this process
66	DD	inte0		; INT E0 vector for this process
6A	DD	inte1		; INT E1 vector for this process	
6E	DW	drives		; Bitmap of drives this process has logged in
70	DD	onblock		; Code to call when this process wants to 
				; block.
74	DW	?		; Segment of ? 
76	DD	?		; Far pointer to ?
7A	DS	86h		; ? includes stack for error abort
100	DS	60h		; Process's stack when in the BDOS
};
John Elliott 18-9-2000