// IfsSpyRes.bcpl -- resident portion of IfsAllocSpy and IfsVmemSpy
// Copyright Xerox Corporation 1979

// Last modified July 28, 1977  7:57 PM by Boggs

get "Pup0.decl"
get "Pup1.decl"

external
[
// outgoing procedures
AllocSpyEvent; VMemSpyEvent

// incoming procedures
StartAllocSpy; VMemSpy
Free; QueueEvent

// incoming statics
allocSpySoc; vmemSpySoc; sysZone
]


//----------------------------------------------------------------------------
let AllocSpyEvent(ecb) be
//----------------------------------------------------------------------------
// Event called periodically when the allocator spy is not active.
// If a pbi has arrived on the socket, then tries to start up
//  the allocator spy;  if successful, stops generating events.
[
test allocSpySoc>>PupSoc.iQ.head ne 0
   ifso [ StartAllocSpy(); Free(sysZone, ecb) ]
   ifnot QueueEvent(ecb, 200)  //2 seconds
]


//----------------------------------------------------------------------------
and VMemSpyEvent(ecb) be
//----------------------------------------------------------------------------
// Event that checks for vmem spy requests and hands them off
//  to the swappable module when they arrive.
[
if vmemSpySoc>>PupSoc.iQ.head ne 0 then VMemSpy()
QueueEvent(ecb, 25)  //250 ms
]