-- CountPinnedPages.mesa
-- Last Modified On 30-Apr-81 19:00:02 By Roy Levin

DIRECTORY
  CachedRegion, CachedRegionImplA, Runtime, SpecialSpace, VM;
  
CountPinnedPages: PROGRAM IMPORTS Runtime, SpecialSpace SHARES CachedRegionImplA
 = { 
      -- call: PGCount[14314B]
     PGCount: PROC[pf: UNSPECIFIED] RETURNS[pgCount: VM.PageCount ← 0] =
      { OPEN LOOPHOLE[pf, POINTER TO FRAME[CachedRegionImplA]];
        FOR pd: PDesc ← pDescFirst, pd+SIZE[CachedRegion.Desc] UNTIL pd > pDescLast DO
          OPEN d:baseDesc[pd];
          IF d.state = inPinned THEN pgCount ← pgCount+d.interval.count;
         ENDLOOP;
      }; 
  SpecialSpace.MakeCodeResident[Runtime.GlobalFrame[PGCount]];
}.