void thread_routine() { threadid = ff_getThreadID(); if (barrier) barrier->doBarrier(tid); void * ret; do { init_error=false; if (svc_init()<0) { error("ff_thread, svc_init failed, thread exit!!!\n"); init_error=true; break; } else { ret = svc(NULL); } svc_end(); if (disable_cancelability()) { error("ff_thread, thread_routine, could not change thread cancelability"); return; } // acquire lock. While freezing is true, // freeze and wait. pthread_mutex_lock(&mutex); if (ret != EOS_NOFREEZE && !stp) { if ((freezing == 0) && (ret == EOS)) stp = true; while(freezing==1) { // NOTE: freezing can change to 2 frozen=true; pthread_cond_signal(&cond_frozen); pthread_cond_wait(&cond,&mutex); } } //thawed=true; //pthread_cond_signal(&cond); //frozen=false; if (freezing != 0) freezing = 1; // freeze again next time pthread_mutex_unlock(&mutex); if (enable_cancelability()) { error("ff_thread, thread_routine, could not change thread cancelability"); return; } } while(!stp); if (freezing) { pthread_mutex_lock(&mutex); frozen=true; pthread_cond_signal(&cond_frozen); pthread_mutex_unlock(&mutex); } isdone = true; }
/** * \brief The life cycle of FastFlow thread * * It defines the life cycle of the FastFlow thread. * */ void thread_routine() { if (barrier) barrier->doBarrier(tid); void * ret; do { init_error=false; if (svc_init()<0) { error("ff_thread, svc_init failed, thread exit!!!\n"); init_error=true; break; } else { ret = svc(NULL); svc_releaseOCL(); } svc_end(); if (disable_cancelability()) { error("ff_thread, thread_routine, could not change thread cancelability"); return; } // acquire lock. While freezing is true, // freeze and wait. pthread_mutex_lock(&mutex); if (ret != (void*)FF_EOS_NOFREEZE && !stp) { // <-------------- CONTROLLARE aggiunto !stp while(freezing==1) { // NOTE: freezing can change to 2 frozen=true; pthread_cond_signal(&cond_frozen); pthread_cond_wait(&cond,&mutex); } } thawed=true; // <----------------- CONTROLLARE !!!! era thawed = frozen; pthread_cond_signal(&cond); frozen=false; if (freezing != 0) freezing = 1; // freeze again next time pthread_mutex_unlock(&mutex); if (enable_cancelability()) { error("ff_thread, thread_routine, could not change thread cancelability"); return; } } while(!stp); if (init_error && freezing) { pthread_mutex_lock(&mutex); frozen=true; pthread_cond_signal(&cond_frozen); pthread_mutex_unlock(&mutex); } }