DIRECTORY BasicTime, Commander, CommanderOps, Convert, ForkOps, ForkOpsMonitor, IO, Process, Rope, TerminalIO; ForkOpsTest: CEDAR MONITOR IMPORTS BasicTime, Commander, CommanderOps, Convert, ForkOps, ForkOpsMonitor, IO, Process, TerminalIO ~ BEGIN last: REF Desc ¬ NIL; lastNumber: INT ¬ 0; GetNumber: ENTRY PROC [] RETURNS [n: INT] = { n ¬ lastNumber; lastNumber ¬ lastNumber+1; }; Now: PROC [] RETURNS [ms: CARD] = { p: BasicTime.Pulses ¬ BasicTime.GetClockPulses[]; ms ¬ (BasicTime.PulsesToMicroseconds[p]+500)/1000 }; Desc: TYPE = RECORD [ index: INT, start: CARD, ms: INT, times: INT ¬ -1, pause: INT ¬ 0 ]; ForksPending: Commander.CommandProc ~ { TerminalIO.PutF1["%g forks pending\n", IO.card[ForkOpsMonitor.Pending[]]]; }; RealReturns: Commander.CommandProc ~ { TerminalIO.PutF1["%g real returns\n", IO.card[ForkOpsMonitor.RealReturns[]]]; }; RealForks: Commander.CommandProc ~ { TerminalIO.PutF1["%g real forks\n", IO.card[ForkOpsMonitor.RealForks[]]]; }; YieldCount: Commander.CommandProc ~ { TerminalIO.PutF1["%g yields to reduce peek congestions\n", IO.card[ForkOpsMonitor.YieldCount[]]]; }; AbortFork: Commander.CommandProc ~ { ForkOps.Stop[Forkee, last, TRUE]; }; ForkSlow: Commander.CommandProc ~ { ENABLE Convert.Error => CommanderOps.Failed["needs integer milliseconds"]; d: REF Desc ¬ NEW[Desc]; d.start ¬ Now[]; d.index ¬ GetNumber[]; d.pause ¬ Convert.IntFromRope[CommanderOps.NextArgument[cmd]]; TerminalIO.PutF["Forking no %g for: %g milliseconds\n", IO.int[d.index], IO.int[d.pause]]; last ¬ d; ForkOps.Fork[Forkee, d]; }; ForkDelayed: Commander.CommandProc ~ { ENABLE Convert.Error => CommanderOps.Failed["needs integer milliseconds"]; d: REF Desc ¬ NEW[Desc]; d.start ¬ Now[]; d.index ¬ GetNumber[]; d.ms ¬ Convert.IntFromRope[CommanderOps.NextArgument[cmd]]; TerminalIO.PutF["Forking no %g in: %g milliseconds\n", IO.int[d.index], IO.int[d.ms]]; last ¬ d; ForkOps.ForkDelayed[d.ms, Forkee, d]; }; ForkPeriodically: Commander.CommandProc ~ { ENABLE Convert.Error => CommanderOps.Failed["needs integer milliseconds and integer times"]; d: REF Desc ¬ NEW[Desc]; d.start ¬ Now[]; d.index ¬ GetNumber[]; d.ms ¬ Convert.IntFromRope[CommanderOps.NextArgument[cmd]]; d.times ¬ Convert.IntFromRope[CommanderOps.NextArgument[cmd]]; TerminalIO.PutF["Periodically forking no %g %g times using: %g milliseconds\n", IO.int[d.index], IO.int[d.times], IO.int[d.ms]]; last ¬ d; ForkOps.ForkPeriodically[d.ms, Forkee, d]; }; Forkee: PROC [x: REF] ~ { ENABLE ABORTED => TerminalIO.PutRope["ABORTED\n"]; d: REF Desc ¬ NARROW[x]; now: CARD ¬ Now[]; time: CARD ¬ now-d.start; d.start ¬ now; IF d.pause>0 THEN { Process.PauseMsec[d.pause]; }; TerminalIO.PutF["Perform: %g required %g used %g\n", IO.int[d.index], IO.int[d.ms], IO.card[time]]; IF d.times>=0 THEN { IF d.times=0 THEN { TerminalIO.PutRope["calling Stop\n"]; ForkOps.Stop[Forkee, d]; } ELSE d.times ¬ d.times -1 }; }; Commander.Register["ForkOps-ForkSlow", ForkSlow, "Test of ForkOps"]; Commander.Register["ForkOps-ForkDelayed", ForkDelayed, "Test of ForkOps"]; Commander.Register["ForkOps-ForkPeriodically", ForkPeriodically, "Test of ForkOps"]; Commander.Register["ForkOps-Pending", ForksPending, "Test of ForkOps"]; Commander.Register["ForkOps-RealForks", RealForks, "Test of ForkOps"]; Commander.Register["ForkOps-RealReturns", RealReturns, "Test of ForkOps"]; Commander.Register["ForkOps-YieldCount", YieldCount, "Test of ForkOps"]; Commander.Register["ForkOps-AbortFork", AbortFork, "Test of ForkOps"]; END. ά ForkOpsTest.mesa Copyright Σ 1993 by Xerox Corporation. All rights reserved. Created by Christian Jacobi, April 13, 1993 Christian Jacobi, May 17, 1993 12:14 pm PDT This is used to debug the ForkOps package. Κͺ•NewlineDelimiter –(cedarcode) style™code•Mark outsideHeader™Kšœ Οeœ1™Kšœ8žœžœ˜ZK˜ K˜K˜K˜—šŸ œ˜&KšžœD˜JKšœžœžœ˜K˜K˜K˜;Kšœ7žœžœ ˜VK˜ K˜%K˜K˜—šŸœ˜+KšžœV˜\Kšœžœžœ˜K˜K˜K˜;K˜>KšœPžœžœžœ ˜€K˜ K˜*K˜K˜—šŸœžœžœ˜Kšžœžœ$˜2Kšœžœžœ˜Kšœžœ ˜Kšœžœ˜K˜šžœ žœ˜K˜K˜—Kšœ5žœžœ žœ ˜cšžœ žœ˜šžœ ˜ šžœ˜K˜%K˜K˜—Kšžœ˜—K˜—K˜K˜—K˜DK˜JK˜TK˜GK˜FK˜JK˜HK˜FKšžœ˜—…— ͺ0