version 1.33, 2011/06/20 17:54:22
|
version 1.67, 2013/03/05 16:20:47
|
Line 1
|
Line 1
|
/* |
/* |
================================================================================ |
================================================================================ |
RPL/2 (R) version 4.1.0.prerelease.1 |
RPL/2 (R) version 4.1.13 |
Copyright (C) 1989-2011 Dr. BERTRAND Joël |
Copyright (C) 1989-2013 Dr. BERTRAND Joël |
|
|
This file is part of RPL/2. |
This file is part of RPL/2. |
|
|
Line 29
|
Line 29
|
================================================================================ |
================================================================================ |
Entrées : structure sur l'état du processus |
Entrées : structure sur l'état du processus |
-------------------------------------------------------------------------------- |
-------------------------------------------------------------------------------- |
Sorties : Néant |
Sorties : néant |
-------------------------------------------------------------------------------- |
-------------------------------------------------------------------------------- |
Effets de bord : néant |
Effets de bord : néant |
================================================================================ |
================================================================================ |
Line 48 sequenceur(struct_processus *s_etat_proc
|
Line 48 sequenceur(struct_processus *s_etat_proc
|
logical1 drapeau_fin; |
logical1 drapeau_fin; |
logical1 drapeau_then; |
logical1 drapeau_then; |
logical1 erreur; |
logical1 erreur; |
|
logical1 presence_compteur; |
|
|
static logical1 completion_valide = d_faux; |
static logical1 completion_valide = d_faux; |
|
|
Line 63 sequenceur(struct_processus *s_etat_proc
|
Line 64 sequenceur(struct_processus *s_etat_proc
|
unsigned char tampon_retour; |
unsigned char tampon_retour; |
unsigned char *t_ligne; |
unsigned char *t_ligne; |
|
|
unsigned long i; |
|
unsigned long j; |
|
unsigned long niveau; |
unsigned long niveau; |
unsigned long position_courante; |
unsigned long position_courante; |
|
|
|
Keymap ancien_keymap; |
|
Keymap nouveau_keymap; |
|
|
(*s_etat_processus).retour_routine_evaluation = 'N'; |
(*s_etat_processus).retour_routine_evaluation = 'N'; |
|
|
if ((*s_etat_processus).debug == d_vrai) |
if ((*s_etat_processus).debug == d_vrai) |
Line 78 sequenceur(struct_processus *s_etat_proc
|
Line 80 sequenceur(struct_processus *s_etat_proc
|
{ |
{ |
if ((*s_etat_processus).langue == 'F') |
if ((*s_etat_processus).langue == 'F') |
{ |
{ |
printf("[%d] Exécution récursive de niveau %lu\n", |
printf("[%d] Exécution récursive de niveau %lu\n", |
(int) getpid(), (*s_etat_processus).niveau_recursivite); |
(int) getpid(), (*s_etat_processus).niveau_recursivite); |
} |
} |
else |
else |
Line 91 sequenceur(struct_processus *s_etat_proc
|
Line 93 sequenceur(struct_processus *s_etat_proc
|
{ |
{ |
if ((*s_etat_processus).langue == 'F') |
if ((*s_etat_processus).langue == 'F') |
{ |
{ |
printf("[%d] Exécution\n", (int) getpid()); |
printf("[%d] Exécution\n", (int) getpid()); |
} |
} |
else |
else |
{ |
{ |
Line 109 sequenceur(struct_processus *s_etat_proc
|
Line 111 sequenceur(struct_processus *s_etat_proc
|
-------------------------------------------------------------------------------- |
-------------------------------------------------------------------------------- |
*/ |
*/ |
|
|
i = 0; |
|
j = 0; |
|
|
|
do |
do |
{ |
{ |
drapeau_appel_definition = d_faux; |
drapeau_appel_definition = d_faux; |
Line 182 sequenceur(struct_processus *s_etat_proc
|
Line 181 sequenceur(struct_processus *s_etat_proc
|
flockfile(stdin); |
flockfile(stdin); |
flockfile(stdout); |
flockfile(stdout); |
|
|
|
ancien_keymap = rl_get_keymap(); |
|
nouveau_keymap = rl_copy_keymap(ancien_keymap); |
|
rl_set_keymap(nouveau_keymap); |
|
|
|
rl_bind_key(NEWLINE, readline_analyse_syntaxique); |
|
rl_bind_key(RETURN, readline_analyse_syntaxique); |
|
rl_bind_key(CTRL('g'), readline_effacement); |
|
rl_done = 0; |
|
|
ligne = readline("RPL/2> "); |
ligne = readline("RPL/2> "); |
|
|
|
rl_set_keymap(ancien_keymap); |
|
rl_free(nouveau_keymap); |
|
|
funlockfile(stdin); |
funlockfile(stdin); |
funlockfile(stdout); |
funlockfile(stdout); |
|
|
Line 338 sequenceur(struct_processus *s_etat_proc
|
Line 349 sequenceur(struct_processus *s_etat_proc
|
|
|
if ((*s_etat_processus).langue == 'F') |
if ((*s_etat_processus).langue == 'F') |
{ |
{ |
printf("+++Erreur : Défaut d'argument\n"); |
printf("+++Erreur : Défaut d'argument\n"); |
} |
} |
else |
else |
{ |
{ |
Line 571 sequenceur(struct_processus *s_etat_proc
|
Line 582 sequenceur(struct_processus *s_etat_proc
|
{ |
{ |
if ((*s_etat_processus).langue == 'F') |
if ((*s_etat_processus).langue == 'F') |
{ |
{ |
printf("[%d] Empilement de la variable " |
printf("[%d] Évaluation de la variable " |
"partagée %s de type %d\n", |
"partagée %s de type %d\n", |
(int) getpid(), (*s_etat_processus) |
(int) getpid(), (*s_etat_processus) |
.instruction_courante, |
.instruction_courante, |
Line 593 sequenceur(struct_processus *s_etat_proc
|
Line 604 sequenceur(struct_processus *s_etat_proc
|
fflush(stdout); |
fflush(stdout); |
} |
} |
|
|
if (pthread_mutex_lock(&((*(*s_etat_processus) |
|
.s_liste_variables_partagees).mutex)) != 0) |
|
{ |
|
(*s_etat_processus).erreur_systeme = |
|
d_es_processus; |
|
return(d_erreur); |
|
} |
|
|
|
if (recherche_variable_partagee(s_etat_processus, |
if (recherche_variable_partagee(s_etat_processus, |
(*(*s_etat_processus) |
(*(*s_etat_processus) |
.pointeur_variable_courante).nom, |
.pointeur_variable_courante).nom, |
(*(*s_etat_processus) |
(*(*s_etat_processus) |
.pointeur_variable_courante).variable_partagee, |
.pointeur_variable_courante).variable_partagee, |
'P') == d_vrai) |
'P') != NULL) |
{ |
{ |
// La variable existe. |
// La variable existe. |
|
|
if ((s_objet = copie_objet(s_etat_processus, |
if ((s_objet = copie_objet(s_etat_processus, |
(*(*s_etat_processus) |
(*(*s_etat_processus) |
.s_liste_variables_partagees) |
.pointeur_variable_partagee_courante) |
.table[(*(*s_etat_processus) |
.objet, 'P')) == NULL) |
.s_liste_variables_partagees) |
|
.position_variable].objet, 'P')) |
|
== NULL) |
|
{ |
{ |
(*s_etat_processus).erreur_systeme = |
(*s_etat_processus).erreur_systeme = |
d_es_allocation_memoire; |
d_es_allocation_memoire; |
Line 624 sequenceur(struct_processus *s_etat_proc
|
Line 624 sequenceur(struct_processus *s_etat_proc
|
} |
} |
|
|
if (pthread_mutex_unlock(&((*(*s_etat_processus) |
if (pthread_mutex_unlock(&((*(*s_etat_processus) |
.s_liste_variables_partagees).mutex)) |
.pointeur_variable_partagee_courante) |
!= 0) |
.mutex)) != 0) |
{ |
{ |
(*s_etat_processus).erreur_systeme = |
(*s_etat_processus).erreur_systeme = |
d_es_processus; |
d_es_processus; |
return(d_erreur); |
return(d_erreur); |
} |
} |
|
|
if (empilement(s_etat_processus, |
if (evaluation(s_etat_processus, s_objet, 'E') |
&((*s_etat_processus).l_base_pile), |
== d_erreur) |
s_objet) == d_erreur) |
|
{ |
{ |
(*s_etat_processus).erreur_systeme = |
liberation(s_etat_processus, s_objet); |
d_es_allocation_memoire; |
|
return(d_erreur); |
return(d_erreur); |
} |
} |
|
|
|
liberation(s_etat_processus, s_objet); |
} |
} |
else |
else |
{ |
{ |
// La variable n'existe plus. |
// La variable n'existe plus. |
|
|
(*s_etat_processus).erreur_systeme = d_es; |
|
|
|
if (pthread_mutex_unlock(&((*(*s_etat_processus) |
|
.s_liste_variables_partagees).mutex)) |
|
!= 0) |
|
{ |
|
(*s_etat_processus).erreur_systeme = |
|
d_es_processus; |
|
return(d_erreur); |
|
} |
|
|
|
recherche_type(s_etat_processus); |
|
} |
} |
} |
} |
|
|
Line 702 sequenceur(struct_processus *s_etat_proc
|
Line 689 sequenceur(struct_processus *s_etat_proc
|
(*s_etat_processus).autorisation_empilement_programme = |
(*s_etat_processus).autorisation_empilement_programme = |
'N'; |
'N'; |
|
|
|
uprintf("<A1>\n"); |
empilement_pile_systeme(s_etat_processus); |
empilement_pile_systeme(s_etat_processus); |
|
|
if ((*s_etat_processus).erreur_systeme != d_es) |
if ((*s_etat_processus).erreur_systeme != d_es) |
Line 750 sequenceur(struct_processus *s_etat_proc
|
Line 738 sequenceur(struct_processus *s_etat_proc
|
{ |
{ |
if ((*s_etat_processus).langue == 'F') |
if ((*s_etat_processus).langue == 'F') |
{ |
{ |
printf("[%d] Empilement de la variable " |
printf("[%d] Évaluation de la variable " |
"%s de type %d\n", |
"%s de type %d\n", |
(int) getpid(), |
(int) getpid(), |
(*s_etat_processus) |
(*s_etat_processus) |
Line 783 sequenceur(struct_processus *s_etat_proc
|
Line 771 sequenceur(struct_processus *s_etat_proc
|
return(d_erreur); |
return(d_erreur); |
} |
} |
|
|
if (empilement(s_etat_processus, |
if (evaluation(s_etat_processus, s_objet, 'E') |
&((*s_etat_processus).l_base_pile), |
== d_erreur) |
s_objet) == d_erreur) |
|
{ |
{ |
(*s_etat_processus).erreur_systeme = |
liberation(s_etat_processus, s_objet); |
d_es_allocation_memoire; |
|
return(d_erreur); |
return(d_erreur); |
} |
} |
|
|
|
liberation(s_etat_processus, s_objet); |
} |
} |
} |
} |
else |
else |
Line 809 sequenceur(struct_processus *s_etat_proc
|
Line 797 sequenceur(struct_processus *s_etat_proc
|
{ |
{ |
if ((*s_etat_processus).l_base_pile == NULL) |
if ((*s_etat_processus).l_base_pile == NULL) |
{ |
{ |
(*s_etat_processus).erreur_execution = |
if ((*s_etat_processus).erreur_execution != |
d_ex_manque_argument; |
d_ex_nom_implicite) |
|
{ |
|
(*s_etat_processus).erreur_execution = |
|
d_ex_manque_argument; |
|
} |
} |
} |
else if ((*(*(*s_etat_processus).l_base_pile).donnee) |
else if ((*(*(*s_etat_processus).l_base_pile).donnee) |
.type == NOM) |
.type == NOM) |
Line 1002 sequenceur(struct_processus *s_etat_proc
|
Line 994 sequenceur(struct_processus *s_etat_proc
|
{ |
{ |
if (strncmp(getenv("LANG"), "fr", 2) == 0) |
if (strncmp(getenv("LANG"), "fr", 2) == 0) |
{ |
{ |
printf("[%d] Arrêt\n", (int) getpid()); |
printf("[%d] Arrêt\n", (int) getpid()); |
} |
} |
else |
else |
{ |
{ |
Line 1164 sequenceur(struct_processus *s_etat_proc
|
Line 1156 sequenceur(struct_processus *s_etat_proc
|
else if ((*(*(*s_etat_processus) |
else if ((*(*(*s_etat_processus) |
.pointeur_variable_courante).objet).type == ADR) |
.pointeur_variable_courante).objet).type == ADR) |
{ |
{ |
|
uprintf("<A2>\n"); |
empilement_pile_systeme(s_etat_processus); |
empilement_pile_systeme(s_etat_processus); |
|
|
if ((*s_etat_processus).erreur_systeme != d_es) |
if ((*s_etat_processus).erreur_systeme != d_es) |
Line 1215 sequenceur(struct_processus *s_etat_proc
|
Line 1208 sequenceur(struct_processus *s_etat_proc
|
(strcmp(instruction_majuscule, "DO") == 0) || |
(strcmp(instruction_majuscule, "DO") == 0) || |
(strcmp(instruction_majuscule, "WHILE") == 0) || |
(strcmp(instruction_majuscule, "WHILE") == 0) || |
(strcmp(instruction_majuscule, "FOR") == 0) || |
(strcmp(instruction_majuscule, "FOR") == 0) || |
|
(strcmp(instruction_majuscule, "FORALL") == 0) |
|
|| |
(strcmp(instruction_majuscule, "START") == 0) || |
(strcmp(instruction_majuscule, "START") == 0) || |
(strcmp(instruction_majuscule, "SELECT") == 0) |
(strcmp(instruction_majuscule, "SELECT") == 0) |
|
|| |
|
(strcmp(instruction_majuscule, "CRITICAL") == 0) |
|| (strcmp(instruction_majuscule, "CASE") == 0) |
|| (strcmp(instruction_majuscule, "CASE") == 0) |
|| (strcmp(instruction_majuscule, "<<") == 0)) |
|| (strcmp(instruction_majuscule, "<<") == 0)) |
{ |
{ |
Line 1224 sequenceur(struct_processus *s_etat_proc
|
Line 1221 sequenceur(struct_processus *s_etat_proc
|
{ |
{ |
analyse(s_etat_processus, NULL); |
analyse(s_etat_processus, NULL); |
} |
} |
|
else if ((strcmp(instruction_majuscule, "FOR") == 0) |
|
|| (strcmp(instruction_majuscule, "FORALL") |
|
== 0) || (strcmp(instruction_majuscule, |
|
"START") == 0)) |
|
{ |
|
uprintf("<A3>\n"); |
|
empilement_pile_systeme(s_etat_processus); |
|
|
|
if ((*s_etat_processus).erreur_systeme != d_es) |
|
{ |
|
return(d_erreur); |
|
} |
|
|
|
(*(*s_etat_processus).l_base_pile_systeme) |
|
.type_cloture = 'L'; |
|
} |
else |
else |
{ |
{ |
|
uprintf("<A4>\n"); |
empilement_pile_systeme(s_etat_processus); |
empilement_pile_systeme(s_etat_processus); |
|
|
if ((*s_etat_processus).erreur_systeme != d_es) |
if ((*s_etat_processus).erreur_systeme != d_es) |
Line 1256 sequenceur(struct_processus *s_etat_proc
|
Line 1270 sequenceur(struct_processus *s_etat_proc
|
return(d_absence_erreur); |
return(d_absence_erreur); |
} |
} |
} |
} |
|
else if (((strcmp(instruction_majuscule, "NEXT") |
|
== 0) || (strcmp(instruction_majuscule, |
|
"STEP") == 0)) && ((*(*s_etat_processus) |
|
.l_base_pile_systeme).type_cloture != 'L')) |
|
{ |
|
/* |
|
* Libération des compteurs de boucle. |
|
*/ |
|
|
|
presence_compteur = (((*(*s_etat_processus) |
|
.l_base_pile_systeme).type_cloture |
|
== 'F') || ((*(*s_etat_processus) |
|
.l_base_pile_systeme).type_cloture |
|
== 'A')) ? d_vrai : d_faux; |
|
|
|
if (((*(*s_etat_processus).l_base_pile_systeme) |
|
.type_cloture != 'S') && |
|
(presence_compteur == d_faux)) |
|
{ |
|
return(d_erreur); |
|
} |
|
|
|
if (presence_compteur == d_vrai) |
|
{ |
|
if (recherche_variable(s_etat_processus, |
|
(*(*s_etat_processus) |
|
.l_base_pile_systeme).nom_variable) |
|
== d_faux) |
|
{ |
|
return(d_erreur); |
|
} |
|
|
|
if ((*(*s_etat_processus) |
|
.pointeur_variable_courante).objet |
|
== NULL) |
|
{ |
|
return(d_erreur); |
|
} |
|
|
|
(*s_etat_processus).niveau_courant--; |
|
|
|
if (retrait_variables_par_niveau( |
|
s_etat_processus) == d_erreur) |
|
{ |
|
return(d_erreur); |
|
} |
|
} |
|
|
|
depilement_pile_systeme(s_etat_processus); |
|
|
|
if ((*s_etat_processus).erreur_systeme != d_es) |
|
{ |
|
return(d_erreur); |
|
} |
|
} |
else |
else |
{ |
{ |
|
// Traitement spécifique pour la fin |
|
// d'une section critique |
|
|
|
if ((*s_etat_processus).l_base_pile_systeme |
|
== NULL) |
|
{ |
|
(*s_etat_processus).erreur_systeme = |
|
d_es_processus; |
|
return(d_erreur); |
|
} |
|
|
|
if ((*(*s_etat_processus).l_base_pile_systeme) |
|
.type_cloture == 'Q') |
|
{ |
|
if (pthread_mutex_unlock( |
|
&mutex_sections_critiques) != 0) |
|
{ |
|
(*s_etat_processus).erreur_systeme = |
|
d_es_processus; |
|
return(d_erreur); |
|
} |
|
|
|
(*s_etat_processus).sections_critiques--; |
|
} |
|
|
depilement_pile_systeme(s_etat_processus); |
depilement_pile_systeme(s_etat_processus); |
|
|
if ((*s_etat_processus).erreur_systeme != d_es) |
if ((*s_etat_processus).erreur_systeme != d_es) |
Line 1298 sequenceur(struct_processus *s_etat_proc
|
Line 1392 sequenceur(struct_processus *s_etat_proc
|
(strcmp(instruction_majuscule, "DO") == 0) || |
(strcmp(instruction_majuscule, "DO") == 0) || |
(strcmp(instruction_majuscule, "WHILE") == 0) || |
(strcmp(instruction_majuscule, "WHILE") == 0) || |
(strcmp(instruction_majuscule, "FOR") == 0) || |
(strcmp(instruction_majuscule, "FOR") == 0) || |
|
(strcmp(instruction_majuscule, "FORALL") == 0) || |
(strcmp(instruction_majuscule, "START") == 0) || |
(strcmp(instruction_majuscule, "START") == 0) || |
(strcmp(instruction_majuscule, "SELECT") == 0) |
(strcmp(instruction_majuscule, "SELECT") == 0) |
|
|| (strcmp(instruction_majuscule, "CRITICAL") == 0) |
|| (strcmp(instruction_majuscule, "CASE") == 0) |
|| (strcmp(instruction_majuscule, "CASE") == 0) |
|| (strcmp(instruction_majuscule, "<<") == 0)) |
|| (strcmp(instruction_majuscule, "<<") == 0)) |
{ |
{ |
Line 1394 sequenceur(struct_processus *s_etat_proc
|
Line 1490 sequenceur(struct_processus *s_etat_proc
|
|
|
if ((*s_etat_processus).var_volatile_processus_pere == 0) |
if ((*s_etat_processus).var_volatile_processus_pere == 0) |
{ |
{ |
kill((*s_etat_processus).pid_processus_pere, SIGALRM); |
envoi_signal_processus((*s_etat_processus).pid_processus_pere, |
|
rpl_sigalrm); |
} |
} |
else |
else |
{ |
{ |