int main (void) { int i; ft_thread_t thread_array[MAX_THREADS]; in_sched = ft_scheduler_create(); out_sched = ft_scheduler_create(); new_input = ft_event_create(in_sched); new_output = ft_event_create(out_sched); ft_thread_create(in_sched, traceinstants, NULL, (void *)50); for (i=0; i<MAX_THREADS; i++) { thread_array[i] = ft_thread_create(in_sched, process, NULL, (void *) &i); } ft_thread_create(in_sched, produce, NULL, NULL); ft_thread_create(out_sched, consume, NULL, NULL); ft_scheduler_start(in_sched); ft_scheduler_start(out_sched); ft_exit(); return 0; }
int main(void) { ft_scheduler_t sched = ft_scheduler_create(); event1 = ft_event_create (sched); event2 = ft_event_create (sched); //ft_thread_create (sched,traceInstants,NULL,NULL); ft_thread_create(sched,waiter1,NULL,NULL); ft_thread_create(sched,waiter2,NULL,NULL); ft_scheduler_start(sched); ft_exit(); return 0; }
ft_thread_t ft_automaton_create (ft_scheduler_t sched, ft_automaton_t automaton, ft_executable_t cleanup, void *args) { ft_thread_t thread; if (!_scheduler_well_created (sched)) return NULL; pthread_once (&_once_self_key,_init_self_key); if (NULL == (thread = _make_thread (cleanup,args))) return NULL; _link_thread_to (thread,sched); thread->signal = ft_event_create (sched); thread->is_automaton = 1; thread->automaton = automaton; thread->autom_state = 0; thread->local = NULL; thread->special = NULL; thread->return_code = OK; thread->well_created = FT_MAGIC; // before registrating... if (OK != _register_as_runnable (thread)) return NULL; return thread; }
ft_thread_t ft_thread_create (ft_scheduler_t sched, ft_executable_t runnable, ft_executable_t cleanup, void *args) { ft_thread_t thread; if (!_scheduler_well_created (sched)) return NULL; pthread_once (&_once_self_key,_init_self_key); if (NULL == (thread = _make_thread (cleanup,args))) return NULL; _link_thread_to (thread,sched); thread->signal = ft_event_create (sched); thread->is_automaton = 0; thread->run = runnable; // create the pthread and wait until it is running _lock_thread (thread); if (OK == pthread_create (&thread->pthread,NULL,_standard_behavior,thread)) thread->well_created = FT_MAGIC; _wait_thread (thread); _unlock_thread (thread); return thread; }
int main(void) { ft_scheduler_t sched = NULL; if (NULL == ft_event_create (sched)){ fprintf (stdout,"cannot create an event before its scheduler\n"); } sched = ft_scheduler_create (); ft_scheduler_start (sched); exit (0); return 0; }
int main (void) { ft_scheduler_t sched = ft_scheduler_create (); evt = ft_event_create (sched); ft_thread_create (sched,trace_instant,NULL,NULL); ft_thread_create (sched,awaiter,NULL,NULL); ft_scheduler_start (sched); ft_exit (); return 0; }
int main(void) { ft_scheduler_t sched = ft_scheduler_create(); event = ft_event_create (sched); //ft_thread_create (sched,traceInstants,NULL,NULL); ft_thread_create(sched,waiter,NULL,NULL); ft_scheduler_start(sched); sleep (1); ft_scheduler_broadcast (event); ft_exit(); return 0; }
int main (void) { int i; ft_scheduler_t sched = ft_scheduler_create (); for (i=0;i<EVENT_NUM;i++){ ft_event_t evt = ft_event_create (sched); //fprintf (stdout, "new event %d\n",i); ft_thread_create (sched,waiter,NULL,(void*)evt); } ft_thread_create (sched,counter,NULL,NULL); ft_scheduler_start (sched); ft_exit (); return 0; }
int main(void) { int i; ft_thread_t ft; sched = ft_scheduler_create (); evt = ft_event_create (sched); table = (ft_thread_t*)malloc (max*sizeof (ft_thread_t)); for (i=0; i<max; i++) { table[i] = ft_thread_create(sched,fonc,NULL,NULL); } ft = ft_thread_create (sched,control,NULL,NULL); ft_scheduler_start(sched); ft_exit(); return 0; }
int main (void) { int i; ft_thread_t thread_array[MAX_THREADS]; file_sched = ft_scheduler_create (); new_elem = ft_event_create (file_sched); for (i=0; i<MAX_THREADS; i++){ thread_array[i] = ft_thread_create (file_sched,process,NULL,NULL); } ft_thread_create (file_sched,produce,NULL,NULL); ft_scheduler_start (file_sched); ft_exit (); return 0; }