Beispiel #1
0
static void *user_thread(void *unused)
{
	int current_passenger_id = 0;
	pthread_t passenger_thread_handle[MAX_N_PERSONS];

	for(current_passenger_id = 0; current_passenger_id < MAX_N_PERSONS; current_passenger_id++){
		pthread_create(&passenger_thread_handle[current_passenger_id],NULL, passenger_thread,(void *) &current_passenger_id);
		sem_wait(&(Lift->sem));
	}
	
	while(1){
		sem_wait(&(Lift->sem_done));	
		if(all_done()){
			dump_outdata();
			lift_delete(Lift);
			int i;
			for(i=0; i < current_passenger_id; i++){
				//pthread_join(passenger_thread_handle[i], NULL); //Why is this!!!
			}
			exit(0);
		}
	}

	return NULL;
}
Beispiel #2
0
void receive_output () {
	int i;
	Head = init_node ();

	/* Allocating space in buffer structure to hold names of incoming connections */
	gRxUInfo.userid = (char *) malloc (20);

	while (!all_done()) {
		for (i = 1; i < 10; i++) {
			if (IS_DONE(i)) continue;

			MPI_Recv (output, 50, MPI_UNSIGNED_CHAR, i, 0, MPI_COMM_WORLD, &status);

			if (!output[0]) {
				DONE(i);
				continue;
			}

			Count++;

			sscanf (output, "%s %d %d", gRxUInfo.userid, &gRxUInfo.followers, &gRxUInfo.following);

			Head = insert (Head, name = gRxUInfo.userid, GATHER);
		}
	}

}
Beispiel #3
0
/* ARGSUSED1 */
void
keyboard(unsigned char key, int x, int y)
{
  switch (key) {
  case '\033':
    all_done();
    break;
  default:
    putchar('\007');
    fflush(stdout);
    break;
  }
}
Beispiel #4
0
static void handle_signal(const struct uuidd_cxt_t *uuidd_cxt, int fd)
{
	struct signalfd_siginfo info;
	ssize_t bytes;

	bytes = read(fd, &info, sizeof(info));
	if (bytes != sizeof(info)) {
		if (errno == EAGAIN)
			return;
		warn(_("receiving signal failed"));
		info.ssi_signo = 0;
	}
	if (info.ssi_signo == SIGPIPE)
		return;		/* ignored */
	all_done(uuidd_cxt, EXIT_SUCCESS);
}
Beispiel #5
0
void main(void){
	char i,joker_runtime,j1,j2;

	*(char*)0x0328 = 0xfc;	//block run/stop
	cputc(0x8);		//block shift-cbm

//	*(char*)0xd020 = 0x03;
//	cgetc();
	
	clrscr();
	setgfx(0x0428);
	revers(1);textcolor(15);cputsxy(5,11,"[l]oad or [r]eset highscores?");
	
	if (yesno()){
		load_hs();
	}
	else{
		for(i=0;i<10;++i){
			strcpy (highscore[i].name,"----------");
			highscore[i].level = 0;
			highscore[i].score = 0;
		}
	}

	while (1){
		ass_setup();
		memmove((char*)0xe000,&bmp_data,LINES*320);
		memmove((char*)0xcc00,(char*)(&bmp_data + LINES*320),LINES*40);
		title_screen();

		memset((char*)0xdbc0,15,40);
		
		level = score[0] = xpos1 = ypos1 = joker = time_out = no_more_moves_flag = 0;
		if (players){
			xpos2 = 1; ypos2 = score[1] = 0;
		}
		
		time1 = 160;
		animals = 7;

		while (1){
			if (time_out){
				stop = 1;
				vic->spr_ena = 0;
				init_msx(4);
				if (joker==0){
					check_moves();

					if (pm_x1 == pm_x2){
						clone(pm_y1+1,pm_x1,1);
						print3x3(EMPTY_SYMB,pm_x1,pm_y1+1);
					}
					else{
						clone(pm_y1,pm_x1+1,1);
						print3x3(EMPTY_SYMB,pm_x1+1,pm_y1);
					}
					clone(pm_y1,pm_x1,0);
					print3x3(EMPTY_SYMB,pm_x1,pm_y1);
					vic->spr_ena = 3;

					while (*(char*)0xdc00 != 111){
						vic->spr_ena ^= 3;
						delay(30);
					}
				}
				else{
					while(*(char*)0xdc00 != 111);
					//kill_joker();
				}
				broesel();
				time_out_screen();
				break;
			}

			//check for level up
			for (i=0;i<animals;++i){
				if (hits[i])
					break;
			}
			
			if (level == 0 || i == animals){
				stop = 1;
				kill_joker();
				init_msx(((level%2)>>1) + 3);
				if (++level != 1){
					broesel();
				}
				if (level == 5){
					animals = 8;
				}
				if (level == 17){
					all_done();
					time_out_screen();
					break;
				}

				xpos1 = 3; ypos1 = 3;
				vic->spr7_x = 39+3*24;
				vic->spr7_y = 50+3*24;
				if (players){
					xpos2 = ypos2 = 4;
					vic->spr6_x = 39+4*24;
					vic->spr6_y = 50+4*24;
				}
				else{
					vic->spr6_x = vic->spr6_y = 0;
				}
				memset(hits,(level+2),8);

				level_up_screen();
				init_msx(~level%2);
				print_matrix();
				timer_delay = level_time[level-1];
				memset((char*)0xdbc0,0x0f,40);
				stop = no_more_moves_flag = key = 0;
			}
			if (no_more_moves_flag){
				stop = 1;
				no_more_moves();
				print_matrix();
				stop = no_more_moves_flag = 0;
			}
			if (!isstop()){
				stop = 1;
				//kill_joker();
				memcpy(backup,matrix,64);
				broesel();
				pause_screen();
				memcpy(matrix,backup,64);
				print_matrix();
				stop = 0;
			}
			if (key == CH_F8){
				stop = 1;
				//kill_joker();
				key = 0;
				broesel();
				break;
			}
			// if a joker exists, check its runtime and destroy if needed
			if(joker == 1 && (clock() - jok1)/CLOCKS_PER_SEC >= joker_runtime){
				kill_joker();
				if (!check_moves()){
					stop = 1;
					no_more_moves();
					print_matrix();
					stop = no_more_moves_flag = 0;
				}
			}

					

			// if no joker exists, create one on random number
			if (joker == 0 && random() == 0xea && random() >= 0xff){
				joker = 1;
				random(); random();
				joker_x = random() & 7;
				joker_y = random() & 7;
				matrix[joker_y][joker_x] = JOKER_SYMB;
				while ((joker_runtime = random() & 7) < 3);				
				jok1 = clock();
			}
			
			// joystick
			if (demo){
				if (*(char*)0xdc00 == 111 || *(char*)0xdc01 == 239){
					//kill_joker();
					broesel();
					break;
				}
 				if (cue_max == 0){
					if (pm_x1 > xpos1){
						for (i=0;i<(pm_x1-xpos1);++i)
							put2cue(119);
					}
					else{
						for (i=0;i<(xpos1-pm_x1);++i)
							put2cue(123);
					}
					if (pm_y1 > ypos1){
						for (i=0;i<(pm_y1-ypos1);++i)
							put2cue(125);
					}
					else{
						for(i=0;i<(ypos1-pm_y1);++i)
							put2cue(126);
					}
				}
			       	while (cue_max);
				delay(50);
//				s_temp = score[0];
				swap (xpos1,ypos1,pm_x2-pm_x1,pm_y2-pm_y1);
				/*				
				if (score[0] == s_temp){
					vic->bordercolor++;
					while(1);
				}
				*/
				
				delay(50);
				continue;
			}
			if((j1 = *(char*)(0xdc00 + tt)&0x7f) != nothing){
				pl = 0;
				if (j1 == fire_up){
					if (ypos1) swap (xpos1,ypos1,0,-1);
				}
				if (j1 == fire_down){
					if (ypos1 < 7) swap(xpos1,ypos1,0,1);
				}
				if (j1 == fire_left){
					if (xpos1) swap (xpos1,ypos1,-1,0);
				}
				if (j1 == fire_right){
					if (xpos1 < 7) swap (xpos1,ypos1,1,0);
				}
				if (j1 == 111){
					if (matrix[ypos1][xpos1] == JOKER_SYMB){
						joker_hit(pl);
					}
				}
			}
			if (players){
				if((j2 = *(char*)0xdc01) != 255){
					pl = 1;
					if (j2 == 238){
						if (ypos2) swap (xpos2,ypos2,0,-1);
					}
					if (j2 == 237){
						if (ypos2 < 7) swap(xpos2,ypos2,0,1);
					}
					if (j2 == 235){
						if (xpos2) swap (xpos2,ypos2,-1,0);
					}
					if (j2 == 231){
						if (xpos2 < 7) swap (xpos2,ypos2,1,0);
					}
					if (j2 == 239){
						if (matrix[ypos2][xpos2] == JOKER_SYMB){
							joker_hit(pl);
						}
					}
				}
			}
		}	
	}
bool m_dispatch::all_done_ex(bool no_abort)
{ bool res=all_done(no_abort);
  if (last_error&&!user_continue()) throw MakeStringException(1, last_error);
  return res;
}