コード例 #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
ファイル: 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
}
コード例 #3
0
bool newCustomer()	// function gives the number of customers in a group
{
	double B = uniform(10,60);
    
    double Q = line.qlength();
    
    double testStatistc = (40 + B)/(25 * (3+Q));
    double random = uniform(0,1);
    return random < testStatistc;
	
}