--- rpl/src/instructions_v1.c 2013/03/21 11:30:30 1.50 +++ rpl/src/instructions_v1.c 2019/01/01 09:03:12 1.76 @@ -1,7 +1,7 @@ /* ================================================================================ - RPL/2 (R) version 4.1.13 - Copyright (C) 1989-2013 Dr. BERTRAND Joël + RPL/2 (R) version 4.1.30 + Copyright (C) 1989-2019 Dr. BERTRAND Joël This file is part of RPL/2. @@ -132,8 +132,8 @@ instruction_var(struct_processus *s_etat return; } - if (((*s_objet_resultat).objet = variance_statistique((struct_matrice *) - (*s_objet_statistique).objet, 'E')) == NULL) + if (((*s_objet_resultat).objet = variance_statistique(s_etat_processus, + (struct_matrice *) (*s_objet_statistique).objet, 'E')) == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; @@ -500,7 +500,8 @@ instruction_version(struct_processus *s_ return; } - if (((*(*l_element_courant).donnee).objet = date_compilation()) == NULL) + if (((*(*l_element_courant).donnee).objet = + date_compilation(s_etat_processus)) == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; @@ -933,8 +934,8 @@ instruction_version(struct_processus *s_ return; } - if (((*(*l_element_courant).donnee).objet = conversion_majuscule(HOST)) - == NULL) + if (((*(*l_element_courant).donnee).objet = conversion_majuscule( + s_etat_processus, HOST)) == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; @@ -1034,7 +1035,7 @@ instruction_vars(struct_processus *s_eta return; } - liste_variables(s_etat_processus, tableau); + nb_variables = liste_variables(s_etat_processus, tableau); for(i = 0; i < nb_variables; i++) { @@ -1093,7 +1094,6 @@ instruction_vars(struct_processus *s_eta tableau[i].origine) == NULL) { // La variable partagée n'existe plus. - continue; } @@ -1122,6 +1122,12 @@ instruction_vars(struct_processus *s_eta } } + if (tableau[i].mutex != NULL) + { + // La variable est une variable partagée. On libère le mutex. + pthread_mutex_unlock(tableau[i].mutex); + } + (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; } @@ -1145,6 +1151,12 @@ instruction_vars(struct_processus *s_eta } } + if (tableau[i].mutex != NULL) + { + // La variable est une variable partagée. On libère le mutex. + pthread_mutex_unlock(tableau[i].mutex); + } + (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; } @@ -1171,6 +1183,12 @@ instruction_vars(struct_processus *s_eta } } + if (tableau[i].mutex != NULL) + { + // La variable est une variable partagée. On libère le mutex. + pthread_mutex_unlock(tableau[i].mutex); + } + (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; } @@ -1189,6 +1207,12 @@ instruction_vars(struct_processus *s_eta } } + if (tableau[i].mutex != NULL) + { + // La variable est une variable partagée. On libère le mutex. + pthread_mutex_unlock(tableau[i].mutex); + } + (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; } @@ -1215,6 +1239,12 @@ instruction_vars(struct_processus *s_eta } } + if (tableau[i].mutex != NULL) + { + // La variable est une variable partagée. On libère le mutex. + pthread_mutex_unlock(tableau[i].mutex); + } + (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; } @@ -1236,6 +1266,13 @@ instruction_vars(struct_processus *s_eta return; } + if (tableau[i].mutex != NULL) + { + // La variable est une variable partagée. On libère + // le mutex. + pthread_mutex_unlock(tableau[i].mutex); + } + (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; } @@ -1243,6 +1280,13 @@ instruction_vars(struct_processus *s_eta if (pthread_mutex_unlock(&((*(*s_etat_processus) .pointeur_variable_partagee_courante).mutex)) != 0) { + if (tableau[i].mutex != NULL) + { + // La variable est une variable partagée. On libère + // le mutex. + pthread_mutex_unlock(tableau[i].mutex); + } + (*s_etat_processus).erreur_systeme = d_es_processus; return; } @@ -1256,6 +1300,13 @@ instruction_vars(struct_processus *s_eta .donnee = copie_objet(s_etat_processus, tableau[i].objet, 'P')) == NULL) { + if (tableau[i].mutex != NULL) + { + // La variable est une variable partagée. On libère + // le mutex. + pthread_mutex_unlock(tableau[i].mutex); + } + (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; } @@ -1269,6 +1320,12 @@ instruction_vars(struct_processus *s_eta (*l_element_courant).donnee)).objet)).suivant).suivant) .suivant = allocation_maillon(s_etat_processus)) == NULL) { + if (tableau[i].mutex != NULL) + { + // La variable est une variable partagée. On libère le mutex. + pthread_mutex_unlock(tableau[i].mutex); + } + (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; } @@ -1277,6 +1334,12 @@ instruction_vars(struct_processus *s_eta (*l_element_courant).donnee)).objet)).suivant).suivant).suivant) .donnee = allocation(s_etat_processus, CHN)) == NULL) { + if (tableau[i].mutex != NULL) + { + // La variable est une variable partagée. On libère le mutex. + pthread_mutex_unlock(tableau[i].mutex); + } + (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; } @@ -1290,6 +1353,13 @@ instruction_vars(struct_processus *s_eta .suivant).donnee).objet = malloc(7 * sizeof(unsigned char))) == NULL) { + if (tableau[i].mutex != NULL) + { + // La variable est une variable partagée. On libère + // le mutex. + pthread_mutex_unlock(tableau[i].mutex); + } + (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; } @@ -1315,7 +1385,14 @@ instruction_vars(struct_processus *s_eta (*l_element_courant).donnee)).objet)).suivant).suivant) .suivant).donnee).objet = malloc(9 * sizeof(unsigned char))) == NULL) - { + { + if (tableau[i].mutex != NULL) + { + // La variable est une variable partagée. On libère + // le mutex. + pthread_mutex_unlock(tableau[i].mutex); + } + (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; } @@ -1334,6 +1411,12 @@ instruction_vars(struct_processus *s_eta .suivant).suivant = allocation_maillon(s_etat_processus)) == NULL) { + if (tableau[i].mutex != NULL) + { + // La variable est une variable partagée. On libère le mutex. + pthread_mutex_unlock(tableau[i].mutex); + } + (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; } @@ -1343,6 +1426,12 @@ instruction_vars(struct_processus *s_eta .suivant).donnee = allocation(s_etat_processus, CHN)) == NULL) { + if (tableau[i].mutex != NULL) + { + // La variable est une variable partagée. On libère le mutex. + pthread_mutex_unlock(tableau[i].mutex); + } + (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; } @@ -1354,6 +1443,13 @@ instruction_vars(struct_processus *s_eta .suivant).suivant).donnee).objet = malloc(7 * sizeof(unsigned char))) == NULL) { + if (tableau[i].mutex != NULL) + { + // La variable est une variable partagée. On libère + // le mutex. + pthread_mutex_unlock(tableau[i].mutex); + } + (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; } @@ -1370,6 +1466,13 @@ instruction_vars(struct_processus *s_eta .suivant).suivant).donnee).objet = malloc(9 * sizeof(unsigned char))) == NULL) { + if (tableau[i].mutex != NULL) + { + // La variable est une variable partagée. On libère + // le mutex. + pthread_mutex_unlock(tableau[i].mutex); + } + (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; } @@ -1381,7 +1484,7 @@ instruction_vars(struct_processus *s_eta } /* - * Préparation du drapeau PRIVATE/SHARED + * Préparation du drapeau PRIVATE/SHARED/MAPPED */ if (((*(*(*(*(*((struct_liste_chainee *) (*((struct_objet *) @@ -1389,6 +1492,12 @@ instruction_vars(struct_processus *s_eta .suivant).suivant).suivant = allocation_maillon(s_etat_processus)) == NULL) { + if (tableau[i].mutex != NULL) + { + // La variable est une variable partagée. On libère le mutex. + pthread_mutex_unlock(tableau[i].mutex); + } + (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; } @@ -1398,6 +1507,12 @@ instruction_vars(struct_processus *s_eta .suivant).suivant).donnee = allocation(s_etat_processus, CHN)) == NULL) { + if (tableau[i].mutex != NULL) + { + // La variable est une variable partagée. On libère le mutex. + pthread_mutex_unlock(tableau[i].mutex); + } + (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; } @@ -1409,6 +1524,36 @@ instruction_vars(struct_processus *s_eta .suivant).suivant).suivant).donnee).objet = malloc(7 * sizeof(unsigned char))) == NULL) { + if (tableau[i].mutex != NULL) + { + // La variable est une variable partagée. On libère + // le mutex. + pthread_mutex_unlock(tableau[i].mutex); + } + + (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; + return; + } + + strcpy((unsigned char *) (*(*(*(*(*(*(*((struct_liste_chainee *) + (*((struct_objet *) (*l_element_courant).donnee)).objet)) + .suivant).suivant).suivant).suivant).suivant).donnee).objet, + "MAPPED"); + } + else if (tableau[i].mutex != NULL) + { + if (((*(*(*(*(*(*(*((struct_liste_chainee *) (*((struct_objet *) + (*l_element_courant).donnee)).objet)).suivant).suivant) + .suivant).suivant).suivant).donnee).objet = malloc(7 * + sizeof(unsigned char))) == NULL) + { + if (tableau[i].mutex != NULL) + { + // La variable est une variable partagée. On libère + // le mutex. + pthread_mutex_unlock(tableau[i].mutex); + } + (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; } @@ -1425,6 +1570,13 @@ instruction_vars(struct_processus *s_eta .suivant).suivant).suivant).donnee).objet = malloc(8 * sizeof(unsigned char))) == NULL) { + if (tableau[i].mutex != NULL) + { + // La variable est une variable partagée. On libère + // le mutex. + pthread_mutex_unlock(tableau[i].mutex); + } + (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; } @@ -1444,6 +1596,13 @@ instruction_vars(struct_processus *s_eta .suivant).suivant).suivant).suivant = NULL; l_element_precedent = l_element_courant; + + if (tableau[i].mutex != NULL) + { + // La variable est une variable partagée. On libère + // le mutex. + pthread_mutex_unlock(tableau[i].mutex); + } } free(tableau);