// Προς υλοποίηση int main(int argc, char **argv) { pthread_t table[TABLE]; int i; queue = fifoInit(TABLE/2); for (i = 0; i < TABLE; i++) { pthread_mutex_init(&(forks[i]), NULL); } for (i = 0; i < TABLE; i++) { pthread_create(&table[i], NULL, philosopher, (void *) i); } for (i = 0; i < TABLE; i++) { pthread_join(table[i], NULL); } fifoDelete(queue); return 0; }
int main (int argc, char **argv) { pthread_t p[TABLE]; int i; if (argc < 2) return 1; srand(atoi(argv[1])); queue = fifoInit (TABLE / 2); printf ("Begin %d-diners\n", TABLE ); pthread_cond_init (&newfork, NULL); for (i = 0; i < TABLE; i++) pthread_mutex_init (&(forks[i]), NULL); for (i = 0; i < TABLE; i++) pthread_create (&p[i], NULL, philosopher, (void *)i); for (i = 0; i < TABLE; i++) pthread_join (p[i], NULL); printf ("End %d-diners\n", TABLE / 2); fifoDelete (queue); return 0; }