Discrete Events Modelling on Simula September 30, 2015 Reading time ~1 minute Example BEGIN EXTERNAL CLASS demos = "demos.atr"; demos BEGIN REF(RDist) nextSendPacket; REF(RDist) nextServePacket; REF(WaitQ) networkQ; REF(Bin) totalPackets; REF(Sender) sender1, sender2, sender3; REF(tally) sojournTime; REF(histogram) sojournHistogram; REF(tally) waitTime; REF(histogram) waitHistogram; REF(tally) sessionDuration; REF(tally) winSize; REF(histogram) winHisogram; Integer pTotal; Real forever; ENTITY CLASS Packet(sender); REF(Sender) sender; BEGIN Real tStart; tStart := time;; networkQ.wait; END *** packet ***; Entity class Sender; BEGIN Real dMax, sessionTime; Integer i, wWidth, count; i := 1; wWidth := 3; count := 0; dMax := 100; WHILE i <= pTotal DO BEGIN IF count < wWidth THEN BEGIN count := count + 1; NEW Packet("packet", this sender).schedule(now); Hold(nextSendPacket.sample); i := i + 1; END ELSE BEGIN Hold(forever); IF interrupted = 1 THEN BEGIN count := count - 1; END; END; END; LOOP: Hold(forever); REPEAT; END *** sender ***; ENTITY CLASS Network; BEGIN REF(Packet) packet_; LOOP: packet_ :- networkQ.coopt; IF time - packet_.tStart <= packet_.sender.dMax THEN BEGIN packet_.sender.wWidth := packet_.sender.wWidth + 1; END ELSE BEGIN packet_.sender.wWidth := entier((packet_.sender.wWidth + 1)/2); END; waitTime.update(time - packet_.tStart); winSize.update(packet_.sender.wWidth); packet_.sender.interrupt(1); Hold(nextServePacket.sample); sojournTime.update(time - packet_.tStart); packet_.sender.sessionTime := time; totalPackets.give(1); REPEAT; END *** network ***; nextSendPacket :- NEW NegExp("nextSendPacket", 50); nextServePacket :- NEW NegExp("nextServePacket", 60); networkQ :- NEW WaitQ("networkQ"); totalPackets :- new Bin("totalPackets", 0); sojournTime :- NEW tally("packet delay"); waitTime :- NEW tally("wait time"); winSize :- NEW tally("windows size"); sessionDuration :- NEW tally("session duration"); pTotal := 10000; forever := 1000000000.0; sender1 :- NEW Sender("sender1");sender1.schedule(now); sender2 :- NEW Sender("sender2");sender2.schedule(now); sender3 :- NEW Sender("sender3");sender3.schedule(now); NEW Network("network").schedule(0.0); !Trace; totalPackets.take(pTotal * 3); sessionDuration.update(sender1.sessionTime); sessionDuration.update(sender2.sessionTime); sessionDuration.update(sender3.sessionTime); END demos; END; 竟然无法拒绝你的打赏 Read More 专业处理中国护照照片一次通过 专业处理中国护照照片一次通过 Continue reading Python Notes Published on April 01, 2021 Scrum Training Notes Published on December 01, 2020