Ejemplo n.º 1
0
void check_the_q(int next_customer){
	int i, flag_hot_seat = OCCUPIED, flag_wait_seat = OCCUPIED, max ;
	
	flag_hot_seat = check_if_free() ;
	
	if( flag_hot_seat == FREE ){
		flag_wait_seat = check_customer_q();
	
		if( flag_wait_seat == OCCUPIED ){
			pos = get_position();
			sleep(2);
			if( customer[pos].value != 0 )
			printf("\n\t\t\t\t\t^^^^^customer %d removed from queue and put in hot seat, cutting time = %d^^^^\n", customer[pos].pos, customer[pos].value);
			wake_up_barber(customer[pos].value);
			customer[pos].time = 0;
			customer[pos].value = 0;
			customer[pos].pos = 0;
		}
		if( next_customer != 0 && flag_hot_seat == FREE ){
			flag_wait_seat = check_customer_q();
	
			if( flag_wait_seat == FREE )
				wake_up_barber(next_customer);
	
			else{
				pos = get_free_position();
				if( pos >= 0 ){
					sleep(2);
					if( next_customer != 0 )
					printf("\t\t----customer %d moved to queue , cutting time = %d----\n", timer, next_customer);
					customer[pos].value = next_customer;	
					customer[pos].time = 1 ;
					customer[pos].pos = timer;	
				}
			}
		}
	}
	
	else if( flag_hot_seat != FREE ){
		pos = get_free_position();
		if( pos >= 0 ){
			sleep(2);
			if( next_customer != 0 )
			printf("\t\t----customer %d moved to queue , cutting time = %d----\n", timer, next_customer);
			customer[pos].value = next_customer;
			customer[pos].time = 1 ;
			customer[pos].pos = timer;
		}
	}
	
	else{
		sleep(2);
		printf("\n\t\t--------->customer %d left, cutting time = %d\n",timer,next_customer);
	}
}		
Ejemplo n.º 2
0
void handle_maprequest_event(XEvent *e)
{
	XMapWindow(display, e->xmaprequest.window);
	XMoveResizeWindow(display, e->xmaprequest.window, PADDING_WEST, PADDING_NORTH, SCREEN_WIDTH - PADDING_WEST - PADDING_EAST, SCREEN_HEIGHT - PADDING_NORTH - PADDING_SOUTH);
	XRaiseWindow(display, e->xmaprequest.window);
	XSetInputFocus(display, e->xmaprequest.window,RevertToParent, CurrentTime);
	selected = e->xmaprequest.window;
	windows_container[get_free_position()] = selected;
}