|
|
|
|
|
Explanation:
|
/* ==================================================== Simulate a "random arrival" of clients ==================================================== */ while( true ) { Hold( a random amount of time ); // Wait a random amount of time Generate( ClientProc ); // Create a client object } |
/* ==================================================== Simulate the "service" of clients in the queue ==================================================== */ while ( true ) { if ( queue is empty ) { sleep( ); // Process must be re-activated by a client } Client = Dequeue( ); // Remove first client from queue Hold( random "service" time ); // Simulate providing service !!! ReActivate( Client ); // Client has "finished" service } |
ArrivalTime = readSysTime( ); // Record the time that the client was created Enqueue( serverQueue ); // Enter the service queue ReActivate ( Server ); // Wake up the server Sleep( ); // Wait until service is complete /* ========================================================== Client will run again when the service is complete !!! ========================================================== */ CompleteTime = readSysTime( ); // Record the time that the client completes AccDelay = AccDelay + ( CompleteTime - ArrivalTime ); // Time to serve NClients = NClients + 1; // Note: AccDelay/NClient = the average service time of clients !! Terminate( ); |
cd demo/ProSim main1 arrivalRate servicerate SimulationLength (main1 1 2 1000) |