Diff for /rpl/src/interruptions.c between versions 1.11 and 1.13

version 1.11, 2010/04/29 07:30:58 version 1.13, 2010/04/30 15:01:14
Line 82  insertion_thread(struct_processus *s_eta Line 82  insertion_thread(struct_processus *s_eta
     sigfillset(&set);      sigfillset(&set);
     pthread_sigmask(SIG_BLOCK, &set, &oldset);      pthread_sigmask(SIG_BLOCK, &set, &oldset);
   
 #   ifndef SEMAPHORES_NOMMES  
     while(sem_wait(&semaphore_liste_threads) == -1)  
 #   else  
     while(sem_wait(semaphore_liste_threads) == -1)  
 #   endif  
     {  
         if (errno != EINTR)  
         {  
             pthread_sigmask(SIG_SETMASK, &oldset, NULL);  
             sigpending(&set);  
   
             (*s_etat_processus).erreur_systeme = d_es_processus;  
             return;  
         }  
     }  
   
     if ((l_nouvel_objet = malloc(sizeof(struct_liste_chainee_volatile)))      if ((l_nouvel_objet = malloc(sizeof(struct_liste_chainee_volatile)))
             == NULL)              == NULL)
     {      {
 #       ifndef SEMAPHORES_NOMMES  
         sem_post(&semaphore_liste_threads);  
 #       else  
         sem_post(semaphore_liste_threads);  
 #       endif  
         pthread_sigmask(SIG_SETMASK, &oldset, NULL);          pthread_sigmask(SIG_SETMASK, &oldset, NULL);
         sigpending(&set);          sigpending(&set);
   
Line 113  insertion_thread(struct_processus *s_eta Line 92  insertion_thread(struct_processus *s_eta
         return;          return;
     }      }
   
     (*l_nouvel_objet).suivant = liste_threads;  
   
     if (((*l_nouvel_objet).donnee = malloc(sizeof(struct_thread))) == NULL)      if (((*l_nouvel_objet).donnee = malloc(sizeof(struct_thread))) == NULL)
     {      {
 #       ifndef SEMAPHORES_NOMMES  
         sem_post(&semaphore_liste_threads);  
 #       else  
         sem_post(semaphore_liste_threads);  
 #       endif  
         pthread_sigmask(SIG_SETMASK, &oldset, NULL);          pthread_sigmask(SIG_SETMASK, &oldset, NULL);
         sigpending(&set);          sigpending(&set);
   
Line 136  insertion_thread(struct_processus *s_eta Line 108  insertion_thread(struct_processus *s_eta
     (*((struct_thread *) (*l_nouvel_objet).donnee)).s_etat_processus =      (*((struct_thread *) (*l_nouvel_objet).donnee)).s_etat_processus =
             s_etat_processus;              s_etat_processus;
   
   #   ifndef SEMAPHORES_NOMMES
       while(sem_wait(&semaphore_liste_threads) == -1)
   #   else
       while(sem_wait(semaphore_liste_threads) == -1)
   #   endif
       {
           if (errno != EINTR)
           {
               pthread_sigmask(SIG_SETMASK, &oldset, NULL);
               sigpending(&set);
   
               (*s_etat_processus).erreur_systeme = d_es_processus;
               return;
           }
       }
   
       (*l_nouvel_objet).suivant = liste_threads;
   
     liste_threads = l_nouvel_objet;      liste_threads = l_nouvel_objet;
   
 #   ifndef SEMAPHORES_NOMMES  #   ifndef SEMAPHORES_NOMMES
Line 168  insertion_thread_surveillance(struct_pro Line 158  insertion_thread_surveillance(struct_pro
     sigfillset(&set);      sigfillset(&set);
     pthread_sigmask(SIG_BLOCK, &set, &oldset);      pthread_sigmask(SIG_BLOCK, &set, &oldset);
   
       if ((l_nouvel_objet = malloc(sizeof(struct_liste_chainee_volatile)))
               == NULL)
       {
           pthread_sigmask(SIG_SETMASK, &oldset, NULL);
           sigpending(&set);
   
           (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
           return;
       }
   
 #   ifndef SEMAPHORES_NOMMES  #   ifndef SEMAPHORES_NOMMES
     while(sem_wait(&semaphore_liste_threads) == -1)      while(sem_wait(&semaphore_liste_threads) == -1)
 #   else  #   else
Line 184  insertion_thread_surveillance(struct_pro Line 184  insertion_thread_surveillance(struct_pro
         }          }
     }      }
   
     if ((l_nouvel_objet = malloc(sizeof(struct_liste_chainee_volatile)))  
             == NULL)  
     {  
 #       ifndef SEMAPHORES_NOMMES  
         sem_post(&semaphore_liste_threads);  
 #       else  
         sem_post(semaphore_liste_threads);  
 #       endif  
         pthread_sigmask(SIG_SETMASK, &oldset, NULL);  
         sigpending(&set);  
   
         (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;  
         return;  
     }  
   
     (*l_nouvel_objet).suivant = liste_threads_surveillance;      (*l_nouvel_objet).suivant = liste_threads_surveillance;
     (*l_nouvel_objet).donnee = (void *) s_argument_thread;      (*l_nouvel_objet).donnee = (void *) s_argument_thread;
   
Line 289  retrait_thread(struct_processus *s_etat_ Line 274  retrait_thread(struct_processus *s_etat_
         (*l_element_precedent).suivant = (*l_element_courant).suivant;          (*l_element_precedent).suivant = (*l_element_courant).suivant;
     }      }
   
     free((void *) (*l_element_courant).donnee);  
     free((struct_liste_chainee_volatile *) l_element_courant);  
   
     if (pthread_setspecific(semaphore_fork_processus_courant, NULL) != 0)      if (pthread_setspecific(semaphore_fork_processus_courant, NULL) != 0)
     {      {
         (*s_etat_processus).erreur_systeme = d_es_processus;          (*s_etat_processus).erreur_systeme = d_es_processus;
Line 319  retrait_thread(struct_processus *s_etat_ Line 301  retrait_thread(struct_processus *s_etat_
         return;          return;
     }      }
   
       free((void *) (*l_element_courant).donnee);
       free((struct_liste_chainee_volatile *) l_element_courant);
   
     pthread_sigmask(SIG_SETMASK, &oldset, NULL);      pthread_sigmask(SIG_SETMASK, &oldset, NULL);
     sigpending(&set);      sigpending(&set);
     return;      return;
Line 381  retrait_thread_surveillance(struct_proce Line 366  retrait_thread_surveillance(struct_proce
         return;          return;
     }      }
   
       // l_element_courant->donnee n'est pas bonne lorsque ça part en vrille.
     if (l_element_precedent == NULL)      if (l_element_precedent == NULL)
     {      {
         liste_threads_surveillance = (*l_element_courant).suivant;          liste_threads_surveillance = (*l_element_courant).suivant;
Line 390  retrait_thread_surveillance(struct_proce Line 376  retrait_thread_surveillance(struct_proce
         (*l_element_precedent).suivant = (*l_element_courant).suivant;          (*l_element_precedent).suivant = (*l_element_courant).suivant;
     }      }
   
     free((struct_liste_chainee_volatile *) l_element_courant);  
   
     if (pthread_mutex_lock(&((*s_argument_thread).mutex)) != 0)      if (pthread_mutex_lock(&((*s_argument_thread).mutex)) != 0)
     {      {
   #       ifndef SEMAPHORES_NOMMES
           sem_post(&semaphore_liste_threads);
   #       else
           sem_post(semaphore_liste_threads);
   #       endif
         pthread_sigmask(SIG_SETMASK, &oldset, NULL);          pthread_sigmask(SIG_SETMASK, &oldset, NULL);
         sigpending(&set);          sigpending(&set);
   
Line 411  retrait_thread_surveillance(struct_proce Line 400  retrait_thread_surveillance(struct_proce
     {      {
         if (pthread_mutex_unlock(&((*s_argument_thread).mutex)) != 0)          if (pthread_mutex_unlock(&((*s_argument_thread).mutex)) != 0)
         {          {
   #           ifndef SEMAPHORES_NOMMES
               sem_post(&semaphore_liste_threads);
   #           else
               sem_post(semaphore_liste_threads);
   #           endif
             pthread_sigmask(SIG_SETMASK, &oldset, NULL);              pthread_sigmask(SIG_SETMASK, &oldset, NULL);
             sigpending(&set);              sigpending(&set);
   
Line 425  retrait_thread_surveillance(struct_proce Line 419  retrait_thread_surveillance(struct_proce
     {      {
         if (pthread_mutex_unlock(&((*s_argument_thread).mutex)) != 0)          if (pthread_mutex_unlock(&((*s_argument_thread).mutex)) != 0)
         {          {
   #           ifndef SEMAPHORES_NOMMES
               sem_post(&semaphore_liste_threads);
   #           else
               sem_post(semaphore_liste_threads);
   #           endif
             pthread_sigmask(SIG_SETMASK, &oldset, NULL);              pthread_sigmask(SIG_SETMASK, &oldset, NULL);
             sigpending(&set);              sigpending(&set);
   
Line 446  retrait_thread_surveillance(struct_proce Line 445  retrait_thread_surveillance(struct_proce
         return;          return;
     }      }
   
       free((struct_liste_chainee_volatile *) l_element_courant);
   
     pthread_sigmask(SIG_SETMASK, &oldset, NULL);      pthread_sigmask(SIG_SETMASK, &oldset, NULL);
     sigpending(&set);      sigpending(&set);
     return;      return;
Line 626  liberation_threads(struct_processus *s_e Line 627  liberation_threads(struct_processus *s_e
             close((*s_etat_processus).pipe_nombre_objets_attente);              close((*s_etat_processus).pipe_nombre_objets_attente);
             close((*s_etat_processus).pipe_nombre_interruptions_attente);              close((*s_etat_processus).pipe_nombre_interruptions_attente);
   
               liberation(s_etat_processus, (*s_etat_processus).at_exit);
   
             if ((*s_etat_processus).nom_fichier_impression != NULL)              if ((*s_etat_processus).nom_fichier_impression != NULL)
             {              {
                 free((*s_etat_processus).nom_fichier_impression);                  free((*s_etat_processus).nom_fichier_impression);
Line 1291  liberation_threads(struct_processus *s_e Line 1294  liberation_threads(struct_processus *s_e
         if (pthread_mutex_lock(&((*s_argument_thread).mutex)) != 0)          if (pthread_mutex_lock(&((*s_argument_thread).mutex)) != 0)
         {          {
             (*s_etat_processus).erreur_systeme = d_es_processus;              (*s_etat_processus).erreur_systeme = d_es_processus;
               sem_post(&semaphore_liste_threads);
             return;              return;
         }          }
   
Line 1305  liberation_threads(struct_processus *s_e Line 1309  liberation_threads(struct_processus *s_e
             if (pthread_mutex_unlock(&((*s_argument_thread).mutex)) != 0)              if (pthread_mutex_unlock(&((*s_argument_thread).mutex)) != 0)
             {              {
                 (*s_etat_processus).erreur_systeme = d_es_processus;                  (*s_etat_processus).erreur_systeme = d_es_processus;
                   sem_post(&semaphore_liste_threads);
                 return;                  return;
             }              }
   
Line 1316  liberation_threads(struct_processus *s_e Line 1321  liberation_threads(struct_processus *s_e
             if (pthread_mutex_unlock(&((*s_argument_thread).mutex)) != 0)              if (pthread_mutex_unlock(&((*s_argument_thread).mutex)) != 0)
             {              {
                 (*s_etat_processus).erreur_systeme = d_es_processus;                  (*s_etat_processus).erreur_systeme = d_es_processus;
                   sem_post(&semaphore_liste_threads);
                 return;                  return;
             }              }
         }          }

Removed from v.1.11  
changed lines
  Added in v.1.13


CVSweb interface <joel.bertrand@systella.fr>