--- rpl/src/instructions_p7.c 2011/04/21 16:00:58 1.23 +++ rpl/src/instructions_p7.c 2011/09/20 14:36:29 1.38 @@ -1,6 +1,6 @@ /* ================================================================================ - RPL/2 (R) version 4.1.0.prerelease.0 + RPL/2 (R) version 4.1.3 Copyright (C) 1989-2011 Dr. BERTRAND Joël This file is part of RPL/2. @@ -94,8 +94,8 @@ instruction_protect(struct_processus *s_ return; } - ((*s_etat_processus).s_liste_variables[(*s_etat_processus) - .position_variable_courante]).variable_verrouillee = d_vrai; + (*(*s_etat_processus).pointeur_variable_courante) + .variable_verrouillee = d_vrai; } else if ((*s_objet).type == LST) { @@ -122,8 +122,8 @@ instruction_protect(struct_processus *s_ return; } - ((*s_etat_processus).s_liste_variables[(*s_etat_processus) - .position_variable_courante]).variable_verrouillee = d_vrai; + (*(*s_etat_processus).pointeur_variable_courante) + .variable_verrouillee = d_vrai; l_element_courant = (*l_element_courant).suivant; } @@ -157,10 +157,6 @@ instruction_protect(struct_processus *s_ void instruction_parameter(struct_processus *s_etat_processus) { - logical1 presence_variable; - - long i; - struct_liste_chainee *l_element_courant; struct_objet *s_objet; @@ -207,7 +203,7 @@ instruction_parameter(struct_processus * if ((*s_objet).type == NOM) { - if (recherche_variable(s_etat_processus, ((*((struct_nom *) + if (recherche_variable_globale(s_etat_processus, ((*((struct_nom *) (*s_objet).objet)).nom)) == d_faux) { liberation(s_etat_processus, s_objet); @@ -217,34 +213,8 @@ instruction_parameter(struct_processus * return; } - i = (*s_etat_processus).position_variable_courante; - presence_variable = d_faux; - - while(i >= 0) - { - if ((strcmp((*s_etat_processus).s_liste_variables[i].nom, - (*((struct_nom *) (*s_objet).objet)).nom) == 0) - && ((*s_etat_processus).s_liste_variables[i].niveau == 1)) - { - presence_variable = d_vrai; - break; - } - - i--; - } - - (*s_etat_processus).position_variable_courante = i; - - if (presence_variable == d_faux) - { - liberation(s_etat_processus, s_objet); - - (*s_etat_processus).erreur_execution = d_ex_variable_non_definie; - return; - } - - ((*s_etat_processus).s_liste_variables[(*s_etat_processus) - .position_variable_courante]).variable_verrouillee = d_vrai; + (*(*s_etat_processus).pointeur_variable_courante) + .variable_verrouillee = d_vrai; } else if ((*s_objet).type == LST) { @@ -260,7 +230,7 @@ instruction_parameter(struct_processus * return; } - if (recherche_variable(s_etat_processus, (*((struct_nom *) + if (recherche_variable_globale(s_etat_processus, (*((struct_nom *) (*(*l_element_courant).donnee).objet)).nom) == d_faux) { liberation(s_etat_processus, s_objet); @@ -271,36 +241,8 @@ instruction_parameter(struct_processus * return; } - i = (*s_etat_processus).position_variable_courante; - presence_variable = d_faux; - - while(i >= 0) - { - if ((strcmp((*s_etat_processus).s_liste_variables[i].nom, - (*((struct_nom *) (*(*l_element_courant).donnee) - .objet)).nom) == 0) && ((*s_etat_processus) - .s_liste_variables[i].niveau == 1)) - { - presence_variable = d_vrai; - break; - } - - i--; - } - - (*s_etat_processus).position_variable_courante = i; - - if (presence_variable == d_faux) - { - liberation(s_etat_processus, s_objet); - - (*s_etat_processus).erreur_execution = - d_ex_variable_non_definie; - return; - } - - ((*s_etat_processus).s_liste_variables[(*s_etat_processus) - .position_variable_courante]).variable_verrouillee = d_vrai; + (*(*s_etat_processus).pointeur_variable_courante) + .variable_verrouillee = d_vrai; l_element_courant = (*l_element_courant).suivant; } @@ -821,9 +763,9 @@ instruction_poke(struct_processus *s_eta // débloquer les instructions de type WF* pour les // lectures bloquantes. - if (kill((*(*((struct_processus_fils *) + if (envoi_signal_processus((*(*((struct_processus_fils *) (*(*l_element_courant).donnee).objet)) - .thread).pid, SIGINJECT) != 0) + .thread).pid, rpl_siginject) != 0) { // Le processus fils peut s'être terminé. break; @@ -847,18 +789,15 @@ instruction_poke(struct_processus *s_eta } # ifndef SEMAPHORES_NOMMES - if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0) - { - (*s_etat_processus).erreur_systeme = d_es_processus; - return; - } + if (sem_post(&((*s_etat_processus).semaphore_fork)) + != 0) # else - if (sem_post((*s_etat_processus).semaphore_fork) != 0) + if (sem_post((*s_etat_processus).semaphore_fork) != 0) +# endif { (*s_etat_processus).erreur_systeme = d_es_processus; return; } -# endif while((longueur_ecriture = write_atomic(s_etat_processus, (*(*((struct_processus_fils *) @@ -867,11 +806,11 @@ instruction_poke(struct_processus *s_eta sizeof(unsigned char))) != sizeof(unsigned char)) { # ifndef SEMAPHORES_NOMMES - while(sem_wait(&((*s_etat_processus) - .semaphore_fork)) == -1) + while(sem_wait( + &((*s_etat_processus).semaphore_fork)) != 0) # else - while(sem_wait((*s_etat_processus) - .semaphore_fork) == -1) + while(sem_wait( + (*s_etat_processus).semaphore_fork) != 0) # endif { if (errno != EINTR) @@ -920,11 +859,11 @@ instruction_poke(struct_processus *s_eta } # ifndef SEMAPHORES_NOMMES - if (sem_post(&((*s_etat_processus) - .semaphore_fork)) != 0) + if (sem_post( + &((*s_etat_processus).semaphore_fork)) != 0) # else - if (sem_post((*s_etat_processus) - .semaphore_fork) != 0) + if (sem_post( + (*s_etat_processus).semaphore_fork) != 0) # endif { (*s_etat_processus).erreur_systeme = d_es_processus; @@ -947,12 +886,13 @@ instruction_poke(struct_processus *s_eta } # ifndef SEMAPHORES_NOMMES - while(sem_wait(&((*s_etat_processus).semaphore_fork)) == -1) + while(sem_wait(&((*s_etat_processus).semaphore_fork)) + != 0) # else - while(sem_wait((*s_etat_processus).semaphore_fork) == -1) + while(sem_wait((*s_etat_processus).semaphore_fork) != 0) # endif { - if (errno == EINTR) + if (errno != EINTR) { (*s_etat_processus).erreur_systeme = d_es_processus; return; @@ -1038,9 +978,9 @@ instruction_poke(struct_processus *s_eta (*(*l_element_courant).donnee).objet)).thread) .thread_actif == d_vrai) { - if (pthread_kill((*(*((struct_processus_fils *) + if (envoi_signal_thread((*(*((struct_processus_fils *) (*(*l_element_courant).donnee).objet)).thread) - .tid, SIGINJECT) != 0) + .tid, rpl_siginject) != 0) { // Le processus fils peut s'être terminé. @@ -1097,9 +1037,11 @@ instruction_poke(struct_processus *s_eta } # ifndef SEMAPHORES_NOMMES - if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0) + if (sem_post( + &((*s_etat_processus).semaphore_fork)) != 0) # else - if (sem_post((*s_etat_processus).semaphore_fork) != 0) + if (sem_post( + (*s_etat_processus).semaphore_fork) != 0) # endif { (*s_etat_processus).erreur_systeme = d_es_processus; @@ -1113,11 +1055,11 @@ instruction_poke(struct_processus *s_eta sizeof(unsigned char))) != sizeof(unsigned char)) { # ifndef SEMAPHORES_NOMMES - while(sem_wait(&((*s_etat_processus) - .semaphore_fork)) == -1) + while(sem_wait( + &((*s_etat_processus).semaphore_fork)) != 0) # else - while(sem_wait((*s_etat_processus) - .semaphore_fork) == -1) + while(sem_wait( + (*s_etat_processus).semaphore_fork) != 0) # endif { if (errno != EINTR) @@ -1166,11 +1108,11 @@ instruction_poke(struct_processus *s_eta } # ifndef SEMAPHORES_NOMMES - if (sem_post(&((*s_etat_processus) - .semaphore_fork)) != 0) + if (sem_post( + &((*s_etat_processus).semaphore_fork)) != 0) # else - if (sem_post((*s_etat_processus) - .semaphore_fork) != 0) + if (sem_post( + (*s_etat_processus).semaphore_fork) != 0) # endif { (*s_etat_processus).erreur_systeme = d_es_processus; @@ -1193,11 +1135,11 @@ instruction_poke(struct_processus *s_eta } # ifndef SEMAPHORES_NOMMES - while(sem_wait(&((*s_etat_processus) - .semaphore_fork)) == -1) + while(sem_wait( + &((*s_etat_processus).semaphore_fork)) != 0) # else - while(sem_wait((*s_etat_processus) - .semaphore_fork) == -1) + while(sem_wait( + (*s_etat_processus).semaphore_fork) != 0) # endif { if (errno != EINTR) @@ -1350,10 +1292,9 @@ instruction_private(struct_processus *s_ } if (recherche_variable_partagee(s_etat_processus, ((*((struct_nom *) - (*s_objet).objet)).nom), ((*s_etat_processus).s_liste_variables - [(*s_etat_processus).position_variable_courante]) - .variable_partagee, ((*s_etat_processus).s_liste_variables - [(*s_etat_processus).position_variable_courante]).origine) + (*s_objet).objet)).nom), (*(*s_etat_processus) + .pointeur_variable_courante).variable_partagee, + (*(*s_etat_processus).pointeur_variable_courante).origine) == d_faux) { if (pthread_mutex_unlock(&((*(*s_etat_processus) @@ -1369,8 +1310,7 @@ instruction_private(struct_processus *s_ return; } - (*s_etat_processus).s_liste_variables[(*s_etat_processus) - .position_variable_courante].objet = + (*(*s_etat_processus).pointeur_variable_courante).objet = (*(*s_etat_processus).s_liste_variables_partagees).table [(*(*s_etat_processus).s_liste_variables_partagees) .position_variable].objet; @@ -1380,8 +1320,8 @@ instruction_private(struct_processus *s_ if (retrait_variable_partagee(s_etat_processus, (*((struct_nom *) (*s_objet).objet)).nom, - (*s_etat_processus).s_liste_variables[(*s_etat_processus) - .position_variable_courante].variable_partagee) == d_erreur) + (*(*s_etat_processus).pointeur_variable_courante) + .variable_partagee) == d_erreur) { if (pthread_mutex_unlock(&((*(*s_etat_processus) .s_liste_variables_partagees).mutex)) != 0) @@ -1394,17 +1334,15 @@ instruction_private(struct_processus *s_ return; } - if ((*s_etat_processus).s_liste_variables[(*s_etat_processus) - .position_variable_courante].origine == 'P') + if ((*(*s_etat_processus).pointeur_variable_courante).origine == 'P') { - (*s_etat_processus).s_liste_variables[(*s_etat_processus) - .position_variable_courante].variable_partagee.adresse = 0; + (*(*s_etat_processus).pointeur_variable_courante) + .variable_partagee.adresse = 0; } else { - (*s_etat_processus).s_liste_variables[(*s_etat_processus) - .position_variable_courante].variable_partagee.pointeur - = NULL; + (*(*s_etat_processus).pointeur_variable_courante) + .variable_partagee.pointeur = NULL; } if (pthread_mutex_unlock(&((*(*s_etat_processus) @@ -1447,11 +1385,9 @@ instruction_private(struct_processus *s_ } if (recherche_variable_partagee(s_etat_processus, ((*((struct_nom *) - (*s_objet).objet)).nom), ((*s_etat_processus) - .s_liste_variables[(*s_etat_processus) - .position_variable_courante]).variable_partagee, - ((*s_etat_processus).s_liste_variables - [(*s_etat_processus).position_variable_courante]).origine) + (*s_objet).objet)).nom), (*(*s_etat_processus) + .pointeur_variable_courante).variable_partagee, + (*(*s_etat_processus).pointeur_variable_courante).origine) == d_faux) { if (pthread_mutex_unlock(&((*(*s_etat_processus) @@ -1469,8 +1405,7 @@ instruction_private(struct_processus *s_ return; } - (*s_etat_processus).s_liste_variables[(*s_etat_processus) - .position_variable_courante].objet = + (*(*s_etat_processus).pointeur_variable_courante).objet = (*(*s_etat_processus).s_liste_variables_partagees).table [(*(*s_etat_processus).s_liste_variables_partagees) .position_variable].objet; @@ -1478,24 +1413,22 @@ instruction_private(struct_processus *s_ [(*(*s_etat_processus).s_liste_variables_partagees) .position_variable].objet = NULL; - if ((*s_etat_processus).s_liste_variables[(*s_etat_processus) - .position_variable_courante].origine == 'P') + if ((*(*s_etat_processus).pointeur_variable_courante).origine + == 'P') { - (*s_etat_processus).s_liste_variables[(*s_etat_processus) - .position_variable_courante].variable_partagee.adresse - = 0; + (*(*s_etat_processus).pointeur_variable_courante) + .variable_partagee.adresse = 0; } else { - (*s_etat_processus).s_liste_variables[(*s_etat_processus) - .position_variable_courante].variable_partagee.pointeur - = NULL; + (*(*s_etat_processus).pointeur_variable_courante) + .variable_partagee.pointeur = NULL; } if (retrait_variable_partagee(s_etat_processus, (*((struct_nom *) (*s_objet).objet)).nom, - (*s_etat_processus).s_liste_variables[(*s_etat_processus) - .position_variable_courante].variable_statique) == d_erreur) + (*(*s_etat_processus).pointeur_variable_courante) + .variable_statique) == d_erreur) { if (pthread_mutex_unlock(&((*(*s_etat_processus) .s_liste_variables_partagees).mutex)) != 0)