Esempio n. 1
0
int main(int argc, char ** argv) {
  init_x();
  init_term();
  pthread_t thread_term, thread_gui;
  pthread_create(&thread_gui, NULL, x_main_loop, NULL);
  pthread_create(&thread_term, NULL, term_main_loop, NULL);
  pthread_join(thread_gui, NULL);
  pthread_cancel(thread_term);
  close_term();
  close_x();
}
Esempio n. 2
0
/**
 *  @brief Exit Subroutine.
 *
 *    This function is called when the program is signalled to close.
 *    It performs tidy-up operations, such as killing threads and
 *    clearing the last value on the 7 Segment display.
 *
 *  @param Void.
 *  @return Void.
 */
void closing_time(void){
  alive = FALSE;
  extern int sockfd; //close the recv functions file descriptor

  pthread_mutex_lock(&state_Mutex);
  button_thread_state = STATE_KILL;
  pthread_cond_broadcast(&state_Signal);
  pthread_mutex_unlock(&state_Mutex);

  pthread_mutex_lock(&button_Mutex);
  pthread_cond_broadcast(&button_Signal);
  pthread_mutex_unlock(&button_Mutex);
  
  close(sockfd);
  pthread_mutex_lock(&network_Mutex);
  pthread_cond_broadcast(&network_Signal);
  pthread_mutex_unlock(&network_Mutex);

  pthread_join(keypad_thread, NULL);
  pthread_join(state_machine_thread, NULL);
  printf("Signalled threads to close\n");

  //pthread_join(network_thread, NULL);
  //pthread_join(receive_thread, NULL);
  

  write_to_port(C, 0);      /* Last LED off */
  close_term();


  pthread_mutex_destroy(&button_Mutex);
  pthread_mutex_destroy(&state_Mutex);
  pthread_mutex_destroy(&display_Mutex);

  pthread_mutex_destroy(&network_Mutex);
  pthread_mutex_destroy(&request_Mutex);
  
  pthread_cond_destroy(&button_Signal);
  pthread_cond_destroy(&state_Signal);
  pthread_cond_destroy(&display_Signal);

  pthread_cond_destroy(&network_Signal);
  pthread_cond_destroy(&request_Signal);
  printf("Closing\n");
  exit(0);
}
Esempio n. 3
0
int main(int argc, char *argv[]) {
  mpz_t _t_1, _C, _s_1;

  mpz_init(_t_1);
  mpz_init(_C);
  mpz_init(_s_1);

  init_term(argv[1]);
  init();
  
  Round0();
  
  Round1(_t_1);
  
  gmp_printf("Round1 output: %Zd\n", _t_1);
  
  send_term(_t_1);

  gmp_printf("Round2 input: ");
  
  receive_term(_C);

  gmp_printf("%Zd\n", _C);

  Round2(_s_1, _C);

  gmp_printf("Round2 output: %Zd\n", _s_1);

  send_term(_s_1);

  clear();

  close_term();
  
  mpz_clear(_t_1);
  mpz_clear(_C);
  mpz_clear(_s_1);

  return 0;
}
Esempio n. 4
0
File: execute.c Progetto: kedric/42
t_cmd	*sh_wait_new_commande(t_env *env, t_cmd *cmd)
{
	int		ret;
	t_term	*term;
	char	buff[6];

	ret = 0;
	init_term();
	term = recup_term();
		parse_ps1(env);
	term->ps1_len = env->ps1_len;
	term->hist = add_or_clean(term->hist);
	ft_bzero(buff, 5);
	while (ft_stomp(buff, term))
	{
		ft_bzero(buff, 5);
		ret = read(term->fd, buff, 5);
		buff[ret + 1] = '\0';
	}
	cmd = ft_parse_cmd(term->hist->buff);
	close_term();
	return (cmd);
}