-- Copyright (C) 1983  by Xerox Corporation. All rights reserved. 
-- MoreBuffers.mesa, HGM, 21-Dec-83 22:24:56

DIRECTORY
  PSB USING [InterruptLevel, PDA],
  Process USING [EnableAborts, Pause],
  
  CommunicationInternal USING [NSPackageMake, NSPackageDestroy],
  Driver USING [GetDeviceChain, Network];

MoreBuffers: PROGRAM
  IMPORTS Process, CommunicationInternal, Driver =
  BEGIN

  AddMoreBuffers: PROCEDURE =
    BEGIN
    first: Driver.Network ← Driver.GetDeviceChain[];  -- Glitches if off
    Poker: PROCEDURE =
      BEGIN
      UNTIL off DO
        FOR int: PSB.InterruptLevel IN PSB.InterruptLevel DO
	  Process.EnableAborts[LOOPHOLE[@PSB.PDA.interrupt[int]]];
	  ENDLOOP;
	Process.Pause[1];
	ENDLOOP;
      END;
    off: BOOLEAN ← FALSE;
    poker: PROCESS ← FORK Poker[];
    CommunicationInternal.NSPackageDestroy[];
    off ← TRUE;
    JOIN poker;
    FOR network: Driver.Network ← first, network.next UNTIL network = NIL DO
      SELECT network.device FROM
        ethernet, ethernetOne => network.buffers ← 10;
	ENDCASE;
      ENDLOOP;
    CommunicationInternal.NSPackageMake[];
    END;

  -- START traps do all the work
  AddMoreBuffers[];
  END..