:TITLE[MesaPDefs];
%Edit by Ed Fiala 18 September 1981: Eliminate MP code defs.
Edit by Ed Fiala 21 April 1981: Cosmetic changes.
Created from MesaP.mc by Ev Neely February 19, 1981 12:38 PM.;
because MesaP.mc had become too large to edit in bravo.
%
* Psb (Process State Block -- Kathy Calls it Pacific States Baloney) format.
MC[psbLink,0];*Word 0: PsbLink (defined below).
MC[psbFlags,1];*Word 1: PsbFlags (defined below).
MC[psbContext,2];*Word 2: Pointer to State Vector or pointer to frame.
MC[psbTimeout,3];*Word 3: Number of ticks until timeout when waiting on Condition Variable. Zero if no timeout.
MC[PsbSize,4];
* PsbLink format.
MC[enterFailed,100000];*Bit 0: = 1 if entry to monitor failed. This means the Psb is on a Monitor queue.
MC[priority,70000];*Bits 1..3: priority of Psb
Set[priBitPos,1];*Bit position of priority field for LDF inst..
Set[priFldSize,3];*Size of priority field for LDF inst..
Set[next,7774];*Bits 4..15B: PsbIndex of next Psb in the queue.
MC[linkReserved,2];*Bit 16B: Currently not used.
MC[vector,1];*Bit 17B: = 1 if if psbContext points to a StateVector.
* PsbFlags format.
MC[softwareState,140000];*Bits 0..1: used only by software.
MC[flagsReserved,34000];*Bits 2..3: Currently not used.
Set[cleanup,7774];*Bits 4..15B: PsbIndex of cleanup link.
MC[waiting,2];*Bit 16B: = 1 if process waiting on a condition queue.
MC[abortPending,1];*Bit 17B: = 1 if process will be aborted at the next wait.
* Condition format. A process is moved to a condition variable queue when it executes a WAIT statement.
MC[conditionReserved,170000];*Currently not used, = zero.
Set[conditionTail,7774];*Bits 4..15B: PsbIndex of tail of condition queue.
MC[abortable,2];*Bit 16B: = 1 if abortable.
MC[wakeup,1];*Bit 17B: This is set by NakedNotify if the queue is empty.
* Monitor format. A process is moved to a montior lock queue when it has failed to enter a monitor because some other process is already inside the monitor.
MC[monitorReserved,170000];*Currently not used, = zero.
Set[monitorTail,7774];*Bits 4..15B: PsbIndex of tail of monitor queue.
MC[monitorLock,1];*Bit 17B: = 1 if monitor is locked, = 0 if monitor is unlocked.
* State Vector format.
MC[svNext,0];*Word 0 is a pointer to the next StateVector (0 if none) when StateVectors are not being used.
MC[svStack,0];*Word 0..15: contents of stack.
MC[svStack4,4];*Word 4 of stack.
MC[svStack8,10];*Word 8 of stack.
MC[svStack12,14];*Word 12 of stack.
MC[svWord,16];*Word 16B: StateWord [break : BYTE, stkptr : Byte].
MC[svFrame,17];*Word 17B: used to save Local.
MC[svData,20];*Word 20B..21B: Unspecified.
%
REGISTER USAGE:
The following registers are preserved across opcodes:
CurrentPsbContains PsbIndex of the current Psb. This points to the front of the ready queue.
Pda,PdaHiThis base register pair points to the Pda. The Pda is assigned to location 200000. The register pair RZero and R400 are used to point to the Pda. 400 in the high byte works because the Pda will not cross a page boundary.
PsbIndexMaskThis contains a mask for the PsbIndex
TicksCurrent tick count for timeout clock.
TimeThis gets decremented by one at each scan line 0. When this gets to zero, we set it back to TickSize (3) and add one to Ticks.
The following registers are preserved across the Process operations:
ConditionContains ConditionQ↑.
ConditionQ,HiThis base register pair is used to point to a condition queue.
FlagsHolds OpCode dispatch values and general flags (described below)
bit 00 =>Notify
1 =>Broadcast
bits 1-2Source Queue:
0 =>Ready Queue
1 =>Monitor Queue
2 =>Condition Queue
bits 3-4Source Queue:
0 =>Ready Queue
1 =>Monitor Queue
2 =>Condition Queue
bits 5-10Op Code Dispatch:
0 =>Monitor Entry
2 =>Monitor ReEntry
4 =>Monitor Exit&Wait
10 =>Monitor Exit&Depart
12 =>Notify and Broadcast
16 =>Requeue
bit 110 =>Requeue not done
1 =>Requeue done
bits 12-15Not used
bit 161 =>Reschedule called from Interrupt
Save stack
0 =>Don’t save stack.
bits 171 =>Source queue not nil
0 =>Source Queue nil
MonitorContains MonitorQ↑
MonitorQ,HiThis base register pair is used to point to a monitor queue.
TimeoutUsed by MXWait to save timeout parameter.
The following temporary registers are shared between Requeue, CleanUpCondition, and ReSchedule. The first four registers are together and quadword aligned. This permits us to fetch and store an entire Psb at the same time:
The first four registers are together and quadword aligned. This permits us to fetch and store an entire Psb at the same time.
PsbLinkContains PsbLink.
PsbFlagsContains PsbFlags
PsbStateContains PsbState (frame pointer)
PsbTimeoutTimeout word of Psb
ConditionTailUsed by CleanUpCondition.
FrameUsed by ReSchedule to save the local frame pointer in the State Vector.
NextPsbUsed by RequeueSub to enqueue a Psb.
PsbIndexPoints to PsbLink.
PrevPsbIndexUsed by requeue subroutine to point to PrevPsbLink.
PrevPsbLinkUsed by requeue subroutine to chain and unchain Psbs.
PsbPriorityUsed by RequeueSub to contain priority of Psb to be requeued.
PsbLink.nextUsed by RequeueSub to save PsbLink.next.
QueueUsed by Requeue subroutine to contain SourceQueue↑ and DestQueue↑.
QueueTailUsed by CleanUpCondition to save ConditionQueue.tail.
QTemp, hiThis base register pair is used by RequeueSub to point to the SourceQ and DestQ. It is used by ReSchedule for LoadState and SaveState.
ReturnLinkUsed by all subroutines save return.
StackPointerUsed by ReSchedule to save and restore the stack pointer.
State, hiBase register pair used by ReSchedule to point to a State Vector.
%
* DISPATCH TABLES:
Set[ProcessDisp,Lshift[prPage,10]];
Set[QueueDisp,ADD[Lshift[prPage,10],20]];
* Flag values:
Set[ReadyQbits,0];
Set[MonitorQbits,1];
Set[ConditionQbits,2];
Set[SourceQbit,1];
Set[DestQbit,3];
Set[SourceIsReadyQ,LSHIFT[ReadyQbits,15]];
Set[SourceIsMonitorQ,LSHIFT[MonitorQbits,15]];
Set[SourceIsConditionQ,LSHIFT[ConditionQbits,15]];
Set[DestIsReadyQ,LSHIFT[ReadyQbits,13]];
Set[DestIsMonitorQ,LSHIFT[MonitorQbits,13]];
Set[DestIsConditionQ,LSHIFT[ConditionQbits,13]];
Set[ReadyQtoMonitorQ,OR[SourceIsReadyQ,DestIsMonitorQ]];
Set[MonitorQtoReadyQ,OR[SourceIsMonitorQ,DestIsReadyQ]];
Set[ReadyQtoConditionQ,OR[SourceIsReadyQ,DestIsConditionQ]];
Set[ConditionQtoReadyQ,OR[SourceIsConditionQ,DestIsReadyQ]];
Set[MonitorQtoConditionQ,OR[SourceIsMonitorQ,DestIsConditionQ]];
*The following locations must be at even numbers. The last bit is truncated in the Flags constant, and the Dispatch picks up 4 bits with a zero in the last bit.
Set[MEloc, 0];
Set[MREloc, 2];
Set[MXWloc, 4];
Set[MXDloc, 10];
Set[NotifyBroadcastLoc, 12];
Set[REQloc, 16];
Set[MEdisp,LSHIFT[MEloc,7]];*Dispatch bits in bits 5-10
Set[MREdisp,LSHIFT[MREloc,7]];
Set[MXWdisp,LSHIFT[MXWloc,7]];
Set[MXDdisp,LSHIFT[MXDloc,7]];
Set[NotifyBroadcastdisp,LSHIFT[NotifyBroadcastLoc,7]];
Set[REQdisp,LSHIFT[REQloc,7]];
Set[BroadcastBit,100000];
Set[SaveStackBit,2];
MC[MEFlags, ADD[MEdisp,ReadyQtoMonitorQ]];
MC[MREFlags, ADD[MREdisp,ReadyQtoMonitorQ]];
MC[MXWFlags, ADD[MXWdisp,MonitorQtoReadyQ]];
MC[MXDFlags, ADD[MXDdisp,MonitorQtoReadyQ]];
MC[NOTIFYFlags, ADD[NotifyBroadcastDisp, ConditionQtoReadyQ]];
MC[BCASTFlags, ADD[NotifyBroadcastDisp, ConditionQtoReadyQ,BroadcastBit]];
MC[REQFlags, ADD[REQdisp,MonitorQtoConditionQ]];
MC[FaultFlags,ReadyQtoConditionQ];
MC[RequeueOccurred, 100];
MC[TimeoutFlags, ConditionQtoReadyQ];
MC[RequeueReadyQtoConditionQ,ReadyQtoConditionQ];
MC[InterruptFlags, ConditionQtoReadyQ];
MC[SourceQNil,1];
MC[SaveStack,SaveStackBit];