--- rpl/src/gestion_objets.c 2011/09/01 12:14:56 1.63 +++ rpl/src/gestion_objets.c 2011/11/26 10:01:26 1.75 @@ -1,6 +1,6 @@ /* ================================================================================ - RPL/2 (R) version 4.1.3 + RPL/2 (R) version 4.1.5 Copyright (C) 1989-2011 Dr. BERTRAND Joël This file is part of RPL/2. @@ -772,9 +772,6 @@ liberation(struct_processus *s_etat_proc { logical1 drapeau; - sigset_t oldset; - sigset_t set; - struct_liste_chainee *l_element_courant; struct_liste_chainee *l_element_suivant; @@ -1144,15 +1141,9 @@ liberation(struct_processus *s_etat_proc case PRC : { - sigfillset(&set); - pthread_sigmask(SIG_BLOCK, &set, &oldset); - if (pthread_mutex_lock(&((*(*((struct_processus_fils *) (*s_objet).objet)).thread).mutex_nombre_references)) != 0) { - pthread_sigmask(SIG_SETMASK, &oldset, NULL); - sigpending(&set); - (*s_etat_processus).erreur_systeme = d_es_processus; return; } @@ -1180,16 +1171,10 @@ liberation(struct_processus *s_etat_proc if (pthread_mutex_unlock(&((*(*((struct_processus_fils *) (*s_objet).objet)).thread).mutex_nombre_references)) != 0) { - pthread_sigmask(SIG_SETMASK, &oldset, NULL); - sigpending(&set); - (*s_etat_processus).erreur_systeme = d_es_processus; return; } - pthread_sigmask(SIG_SETMASK, &oldset, NULL); - sigpending(&set); - if (drapeau == d_vrai) { pthread_mutex_destroy(&((*(*((struct_processus_fils *) @@ -1527,9 +1512,6 @@ struct_objet * copie_objet(struct_processus *s_etat_processus, struct_objet *s_objet, unsigned char type) { - sigset_t oldset; - sigset_t set; - struct_liste_chainee *l_element_base; struct_liste_chainee *l_element_courant; struct_liste_chainee *l_element_courant_ecriture; @@ -2234,19 +2216,8 @@ copie_objet(struct_processus *s_etat_pro case MTX : { - if (type != 'O') - { - incrementation_atomique(s_objet); - return(s_objet); - } - - if ((s_nouvel_objet = allocation(s_etat_processus, MTX)) == NULL) - { - return(NULL); - } - - (*((struct_mutex *) ((*s_nouvel_objet).objet))).mutex = - (*((struct_mutex *) ((*s_objet).objet))).mutex; + // La duplication d'un mutex renvoie le même objet. + incrementation_atomique(s_objet); break; } @@ -2300,15 +2271,9 @@ copie_objet(struct_processus *s_etat_pro case PRC : { - sigfillset(&set); - pthread_sigmask(SIG_BLOCK, &set, &oldset); - if (pthread_mutex_lock(&((*(*((struct_processus_fils *) (*s_objet).objet)).thread).mutex_nombre_references)) != 0) { - pthread_sigmask(SIG_SETMASK, &oldset, NULL); - sigpending(&set); - return(NULL); } @@ -2318,15 +2283,9 @@ copie_objet(struct_processus *s_etat_pro if (pthread_mutex_unlock(&((*(*((struct_processus_fils *) (*s_objet).objet)).thread).mutex_nombre_references)) != 0) { - pthread_sigmask(SIG_SETMASK, &oldset, NULL); - sigpending(&set); - return(NULL); } - pthread_sigmask(SIG_SETMASK, &oldset, NULL); - sigpending(&set); - if (type != 'O') { incrementation_atomique(s_objet); @@ -2514,6 +2473,8 @@ copie_objet(struct_processus *s_etat_pro return(NULL); } + (*((struct_semaphore *) (*s_nouvel_objet).objet)).semaphore = + (*((struct_semaphore *) (*s_objet).objet)).semaphore; strcpy((*((struct_semaphore *) (*s_nouvel_objet).objet)).nom, (*((struct_semaphore *) (*s_objet).objet)).nom); break; @@ -2831,16 +2792,12 @@ copie_etat_processus(struct_processus *s * n'ont aucune raison de changer. */ -# ifndef SEMAPHORES_NOMMES - sem_init(&((*s_nouvel_etat_processus).semaphore_fork), 0, 0); -# else - if (((*s_nouvel_etat_processus).semaphore_fork = sem_init2(0, sem_fork)) - == SEM_FAILED) - { - (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; - return(NULL); - } -# endif + pthread_mutexattr_init(&attributs_mutex); + pthread_mutexattr_settype(&attributs_mutex, PTHREAD_MUTEX_NORMAL); + + // Les sémaphores sont initialisés dans le nouveau thread. Il + // s'agit d'une limitation de l'implantation de l'émulation + // de sem_init(). initialisation_contexte_cas(s_etat_processus); @@ -3300,6 +3257,9 @@ copie_etat_processus(struct_processus *s * Copie des différents contextes */ + (*s_nouvel_etat_processus).pointeur_signal_lecture = d_faux; + (*s_nouvel_etat_processus).pointeur_signal_ecriture = d_faux; + (*s_nouvel_etat_processus).l_base_pile_contextes = NULL; l_element_lecture = (*s_etat_processus).l_base_pile_contextes; @@ -3964,22 +3924,10 @@ debug_fork() pthread_mutex_lock(&mutex_allocation); pid = fork(); -# ifdef OS2 - if (pid == 0) - { - sem_init(&semaphore_liste_threads, 0, 1); - sem_init(&semaphore_gestionnaires_signaux, 0, 0); - sem_init(&semaphore_gestionnaires_signaux_atomique, 0, 1); - sem_init(&((*s_etat_processus).semaphore_fork), 0, 0); - } -# endif - if (pid == 0) { -# ifdef _BROKEN_SIGINFO - liberation_fifos_signaux(s_etat_processus); - creation_fifos_signaux(s_etat_processus); -# endif + liberation_queue_signaux(s_etat_processus); + creation_queue_signaux(s_etat_processus); pthread_mutex_destroy(&mutex_allocation); debug_memoire_initialisation();