コード例 #1
0
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
	
}
コード例 #2
0
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--;
        }
}
コード例 #3
0
ファイル: ex1cpp.cpp プロジェクト: jinyh99/NoC-sim
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
}
コード例 #4
0
			void stopListening( )
			{
				mQuit.set( );
			}
コード例 #5
0
			virtual void stop ( ) { mQuit.set( ); }