void arr_cust()
{
	create("arr_cust");

	line.reserve();	// join the line and wait to be head
    vendingMachineRequested.set();    // i am the front of the line
    waitVendingMachineOpen.queue();   // wait for an open machine
    vendingMachineRequested.clear();  // vending machine is open and im taking it clear for next in line
    vendingMachineIsOpen.set(); // tell vending machine that i am about to use it.
    line.release();  // i am not the head of the line anymore pass it to next in line.
    doneWithMachine.wait(); // I am done after time to use machine is free and im leaving and dying.
    
    // set up shuttle process
	
}
void manageMachines(){
    create("manageMachines");

    double B,timeUsingMachine;
    
    while (1) {
        vendingMachineRequested.wait();
        
        B = uniform(10,60);
        timeUsingMachine = 150 + uniform((B/2),30);
        
        waitVendingMachineOpen.set();
        vendingMachineIsOpen.wait();
        numberOfMachinesBeingUsed++;
        hold(timeUsingMachine);
        doneWithMachine.set();
        numberOfMachinesBeingUsed--;
        }
}
Example #3
0
void customer()				// arriving customer
{
	float t1;

	create("cust");
	t1 = clock;			// record start time
	qtbl.note_entry();		// note arrival
	f.reserve();			// reserve facility
		hold(expntl(SRV_TM));	// service interval
	f.release();			// release facility
	tbl.record(clock - t1);		// record response time
	qtbl.note_exit();		// note departure
	if(--cnt == 0)
		done.set();		// if last customer, set done
}
Example #4
0
			void stopListening( )
			{
				mQuit.set( );
			}
Example #5
0
			virtual void stop ( ) { mQuit.set( ); }