--- rpl/src/interruptions.c 2012/05/21 17:25:45 1.98 +++ rpl/src/interruptions.c 2012/07/04 13:02:49 1.99 @@ -88,7 +88,7 @@ thread_surveillance_signaux(void *argume attente.tv_sec = 0; attente.tv_nsec = GRANULARITE_us * 1000; -# ifndef SEMAPHORES_NOMMES +# if defined(SEMAPHORES_NOMMES) || defined(IPCS_SYSV) if (sem_wait(&(*s_queue_signaux).signalisation) == 0) # else if(sem_wait(semaphore_signalisation) == 0) @@ -99,7 +99,7 @@ thread_surveillance_signaux(void *argume break; } -# ifndef SEMAPHORES_NOMMES +# if defined(SEMAPHORES_NOMMES) || defined(IPCS_SYSV) sem_post(&(*s_queue_signaux).signalisation); # else sem_post(semaphore_signalisation); @@ -112,7 +112,7 @@ thread_surveillance_signaux(void *argume // affectée au processus courant pour vérifier s'il y a quelque // chose à traiter. -# ifndef SEMAPHORES_NOMMES +# if defined(SEMAPHORES_NOMMES) || defined(IPCS_SYSV) sem_wait(&(*s_queue_signaux).semaphore); # else sem_wait(semaphore_queue_signaux); @@ -125,7 +125,7 @@ thread_surveillance_signaux(void *argume raise(SIGALRM); } -# ifndef SEMAPHORES_NOMMES +# if defined(SEMAPHORES_NOMMES) || defined(IPCS_SYSV) sem_post(&(*s_queue_signaux).semaphore); # else sem_post(semaphore_queue_signaux); @@ -325,7 +325,7 @@ retrait_thread(struct_processus *s_etat_ (*l_element_courant).donnee)).s_etat_processus) .pointeur_signal_lecture) { -# ifndef SEMAPHORES_NOMMES +# if defined(SEMAPHORES_NOMMES) || defined(IPCS_SYSV) sem_wait(&((*s_queue_signaux).signalisation)); # else sem_wait(semaphore_signalisation); @@ -1622,7 +1622,7 @@ deverrouillage_gestionnaire_signaux(stru if (signal_test == SIGTEST) { signal_test = signal; return; } // Récupération des signaux -// - SIGINT (arrêt au clavier) +// - SIGINT (arrêt au clavier) // - SIGTERM (signal d'arrêt en provenance du système) void @@ -2397,7 +2397,7 @@ scrutation_interruptions(struct_processu // à lire. Les pointeurs d'écriture pointent sur les prochains éléments à // écrire. -# ifndef SEMAPHORES_NOMMES +# if defined(SEMAPHORES_NOMMES) || defined(IPCS_SYSV) if (sem_trywait(&((*s_queue_signaux).semaphore)) == 0) # else if (sem_trywait(semaphore_queue_signaux) == 0) @@ -2417,14 +2417,14 @@ scrutation_interruptions(struct_processu ((*s_queue_signaux).pointeur_lecture + 1) % LONGUEUR_QUEUE_SIGNAUX; -# ifndef SEMAPHORES_NOMMES +# if defined(SEMAPHORES_NOMMES) || defined(IPCS_SYSV) sem_wait(&((*s_queue_signaux).signalisation)); # else sem_wait(semaphore_signalisation); # endif } -# ifndef SEMAPHORES_NOMMES +# if defined(SEMAPHORES_NOMMES) || defined(IPCS_SYSV) sem_post(&((*s_queue_signaux).semaphore)); # else sem_post(semaphore_queue_signaux); @@ -2448,7 +2448,7 @@ scrutation_interruptions(struct_processu ((*s_etat_processus).pointeur_signal_lecture + 1) % LONGUEUR_QUEUE_SIGNAUX; -# ifndef SEMAPHORES_NOMMES +# if defined(SEMAPHORES_NOMMES) || defined(IPCS_SYSV) sem_wait(&((*s_queue_signaux).signalisation)); # else sem_wait(semaphore_signalisation); @@ -2560,7 +2560,7 @@ envoi_signal_processus(pid_t pid, enum s return(1); } -# ifndef SEMAPHORES_NOMMES +# if defined(SEMAPHORES_NOMMES) || defined(IPCS_SYSV) while(sem_wait(&((*s_queue_signaux).semaphore)) != 0) # else while(sem_wait(semaphore_queue_signaux) != 0) @@ -2581,7 +2581,7 @@ envoi_signal_processus(pid_t pid, enum s ((*s_queue_signaux).pointeur_ecriture + 1) % LONGUEUR_QUEUE_SIGNAUX; -# ifndef SEMAPHORES_NOMMES +# if defined(SEMAPHORES_NOMMES) || defined(IPCS_SYSV) if (sem_post(&((*s_queue_signaux).semaphore)) != 0) # else if (sem_post(semaphore_queue_signaux) != 0) @@ -2590,7 +2590,7 @@ envoi_signal_processus(pid_t pid, enum s return(1); } -# ifndef SEMAPHORES_NOMMES +# if defined(SEMAPHORES_NOMMES) || defined(IPCS_SYSV) if (sem_post(&((*s_queue_signaux).signalisation)) != 0) # else if (sem_post(semaphore_signalisation) != 0) @@ -2843,7 +2843,7 @@ envoi_signal_thread(pthread_t tid, enum return(1); } -# ifndef SEMAPHORES_NOMMES +# if defined(SEMAPHORES_NOMMES) || defined(IPCS_SYSV) if (sem_post(&((*s_queue_signaux).signalisation)) != 0) { return(1); @@ -2871,7 +2871,7 @@ envoi_signal_contexte(struct_processus * % LONGUEUR_QUEUE_SIGNAUX; pthread_mutex_unlock(&mutex_interruptions); -# ifndef SEMAPHORES_NOMMES +# if defined(SEMAPHORES_NOMMES) || defined(IPCS_SYSV) if (sem_post(&((*s_queue_signaux).signalisation)) != 0) { return(1); @@ -3142,7 +3142,7 @@ liberation_queue_signaux(struct_processu (*s_queue_signaux).requete_arret = d_vrai; -# ifndef SEMAPHORES_NOMMES +# if defined(SEMAPHORES_NOMMES) || defined(IPCS_SYSV) sem_post(&((*s_queue_signaux).signalisation)); # else sem_post(semaphore_signalisation); @@ -3201,6 +3201,18 @@ destruction_queue_signaux(struct_process unsigned char *nom; # endif + // Incrémenter le sémaphore pour être sûr de le débloquer. + + (*s_queue_signaux).requete_arret = d_vrai; + +# if defined(SEMAPHORES_NOMMES) || defined(IPCS_SYSV) + sem_post(&((*s_queue_signaux).signalisation)); +# else + sem_post(semaphore_signalisation); +# endif + + pthread_join((*s_queue_signaux).thread_signaux, NULL); + # ifdef IPCS_SYSV // SystemV # ifndef OS2 // Il faut commencer par éliminer le sémaphore.