int main(int argc, char** argv) { pthread_t threads[NUM_CONTROLLERS]; if (argc != 3) { fprintf(stderr, "Usage: parque <N_LUGARES> <T_ABERTURA>\n"); exit(1); } if (convert_str_to_int(argv[1], &numLugares) != 0) { fprintf(stderr, "Invalid entry for N_LUGARES\n"); exit(2); } if (convert_str_to_int(argv[2], &tAbertura) != 0) { fprintf(stderr, "Invalid entry for T_ABERTURA\n"); exit(3); } if ( (fp_logger = init_logger(LOGGER_NAME)) == NULL ) { fprintf(stderr, "Error opening %s\n", LOGGER_NAME); exit(4); } if ( (sem = init_sem(SEM_NAME)) == SEM_FAILED ) { exit(5); } start = clock(); int i; for (i = 0; i < NUM_CONTROLLERS; i++) { pthread_create(&threads[i], NULL, controlador, controller_name[i]); } sleep(tAbertura); /* Zona Critica */ sem_wait(sem); notify_controllers(FINISH_STR); for (i = 0; i < NUM_CONTROLLERS; i++) pthread_join(threads[i], NULL); sem_post(sem); /***************/ destroy_sem(sem, SEM_NAME); fclose(fp_logger); pthread_exit(0); }
static void obtain_content_length (scloud_prc_t * ap_prc, char * ap_info) { char * p_end = NULL; assert (ap_prc); assert (ap_info); ap_prc->content_length_bytes_ = convert_str_to_int (ap_prc, ap_info, &p_end); ap_prc->bytes_before_eos_ = ap_prc->content_length_bytes_; }