// ContextSchInit.bcpl -- initialization for ContextSched module
// Copyright Xerox Corporation 1979


external
[
//outgoing procedures
InitContextSched

//incoming procedures
SchedInterrupt; SchedFinish; Yield; SchedYield

//incoming statics
lvUserFinishProc; schedSavedUFP; schedMask
]

manifest active = #453
manifest interruptVector = #501
manifest displayInterrupt = #421


//-----------------------------------------------------------------
let InitContextSched() be
//-----------------------------------------------------------------
[
//initialize interrupt on lowest-priority available channel
let c, mask = 1, #40000
until (@active & mask) eq 0 do [ c = c+1; mask = mask rshift 1 ]
interruptVector!(15-c) = SchedInterrupt
@active = @active%mask
@displayInterrupt = @displayInterrupt%mask
schedMask = mask

//queue a user finish procedure
schedSavedUFP = @lvUserFinishProc
@lvUserFinishProc = SchedFinish

//cause Yield() to enter ContextSched module
Yield = SchedYield
]