version 1.25, 2010/08/06 15:26:43
|
version 1.75, 2012/10/01 11:04:57
|
Line 1
|
Line 1
|
/* |
/* |
================================================================================ |
================================================================================ |
RPL/2 (R) version 4.0.18 |
RPL/2 (R) version 4.1.11 |
Copyright (C) 1989-2010 Dr. BERTRAND Joël |
Copyright (C) 1989-2012 Dr. BERTRAND Joël |
|
|
This file is part of RPL/2. |
This file is part of RPL/2. |
|
|
Line 35
|
Line 35
|
================================================================================ |
================================================================================ |
*/ |
*/ |
|
|
|
|
static void |
static void |
creation_instruction(struct_processus *s_etat_processus, |
creation_instruction(struct_processus *s_etat_processus, |
unsigned char *instruction, void (*routine)()) |
unsigned char *instruction, void (*routine)()) |
Line 61 creation_instruction(struct_processus *s
|
Line 60 creation_instruction(struct_processus *s
|
|
|
(*(*s_etat_processus).arbre_instructions).feuille = NULL; |
(*(*s_etat_processus).arbre_instructions).feuille = NULL; |
|
|
if (((*(*s_etat_processus).arbre_instructions).noeud = |
if (((*(*s_etat_processus).arbre_instructions).noeuds = |
malloc((*s_etat_processus).nombre_caracteres |
malloc((*s_etat_processus).nombre_caracteres |
* sizeof(struct_instruction))) == NULL) |
* sizeof(struct_instruction))) == NULL) |
{ |
{ |
Line 71 creation_instruction(struct_processus *s
|
Line 70 creation_instruction(struct_processus *s
|
|
|
for(i = 0; i < (*s_etat_processus).nombre_caracteres; i++) |
for(i = 0; i < (*s_etat_processus).nombre_caracteres; i++) |
{ |
{ |
(*(*s_etat_processus).arbre_instructions).noeud[i] = NULL; |
(*(*s_etat_processus).arbre_instructions).noeuds[i] = NULL; |
} |
} |
} |
} |
|
|
Line 84 creation_instruction(struct_processus *s
|
Line 83 creation_instruction(struct_processus *s
|
printf("Instruction=\"%s\", (*ptr)='%c'\n", |
printf("Instruction=\"%s\", (*ptr)='%c'\n", |
instruction, *ptr)); |
instruction, *ptr)); |
|
|
if ((*l_instruction_courante).noeud[(*s_etat_processus) |
if ((*l_instruction_courante).noeuds[(*s_etat_processus) |
.pointeurs_caracteres[*ptr]] == NULL) |
.pointeurs_caracteres[*ptr]] == NULL) |
{ |
{ |
// Le noeud suivant n'existe pas, on le crée. |
// Le noeud suivant n'existe pas, on le crée. |
|
|
if (((*l_instruction_courante).noeud[(*s_etat_processus) |
if (((*l_instruction_courante).noeuds[(*s_etat_processus) |
.pointeurs_caracteres[*ptr]] = |
.pointeurs_caracteres[*ptr]] = |
malloc(sizeof(struct_instruction))) == NULL) |
malloc(sizeof(struct_instruction))) == NULL) |
{ |
{ |
Line 97 creation_instruction(struct_processus *s
|
Line 96 creation_instruction(struct_processus *s
|
return; |
return; |
} |
} |
|
|
(*(*l_instruction_courante).noeud[(*s_etat_processus) |
(*(*l_instruction_courante).noeuds[(*s_etat_processus) |
.pointeurs_caracteres[*ptr]]).feuille = NULL; |
.pointeurs_caracteres[*ptr]]).feuille = NULL; |
|
|
if (((*(*l_instruction_courante).noeud[(*s_etat_processus) |
if (((*(*l_instruction_courante).noeuds[(*s_etat_processus) |
.pointeurs_caracteres[*ptr]]).noeud = |
.pointeurs_caracteres[*ptr]]).noeuds = |
malloc((*s_etat_processus).nombre_caracteres |
malloc((*s_etat_processus).nombre_caracteres |
* sizeof(struct_instruction))) == NULL) |
* sizeof(struct_instruction))) == NULL) |
{ |
{ |
Line 111 creation_instruction(struct_processus *s
|
Line 110 creation_instruction(struct_processus *s
|
|
|
for(i = 0; i < (*s_etat_processus).nombre_caracteres; i++) |
for(i = 0; i < (*s_etat_processus).nombre_caracteres; i++) |
{ |
{ |
(*(*l_instruction_courante).noeud[(*s_etat_processus) |
(*(*l_instruction_courante).noeuds[(*s_etat_processus) |
.pointeurs_caracteres[*ptr]]).noeud[i] = NULL; |
.pointeurs_caracteres[*ptr]]).noeuds[i] = NULL; |
} |
} |
} |
} |
|
|
l_instruction_courante = (*l_instruction_courante).noeud |
l_instruction_courante = (*l_instruction_courante).noeuds |
[(*s_etat_processus).pointeurs_caracteres[*ptr]]; |
[(*s_etat_processus).pointeurs_caracteres[*ptr]]; |
ptr++; |
ptr++; |
} |
} |
Line 138 liberation_arbre_instructions(struct_pro
|
Line 137 liberation_arbre_instructions(struct_pro
|
|
|
for(i = 0; i < (*s_etat_processus).nombre_caracteres; i++) |
for(i = 0; i < (*s_etat_processus).nombre_caracteres; i++) |
{ |
{ |
if ((*arbre).noeud[i] != NULL) |
if ((*arbre).noeuds[i] != NULL) |
{ |
{ |
liberation_arbre_instructions(s_etat_processus, (*arbre).noeud[i]); |
liberation_arbre_instructions(s_etat_processus, (*arbre).noeuds[i]); |
} |
} |
} |
} |
|
|
free((*arbre).noeud); |
free((*arbre).noeuds); |
free(arbre); |
free(arbre); |
|
|
return; |
return; |
Line 466 initialisation_instructions(struct_proce
|
Line 465 initialisation_instructions(struct_proce
|
INSTRUCTION("LINE", instruction_line); |
INSTRUCTION("LINE", instruction_line); |
INSTRUCTION("LNP1", instruction_lnp1); |
INSTRUCTION("LNP1", instruction_lnp1); |
INSTRUCTION("LOCK", instruction_lock); |
INSTRUCTION("LOCK", instruction_lock); |
|
INSTRUCTION("L->T", instruction_l_vers_t); |
INSTRUCTION("MANT", instruction_mant); |
INSTRUCTION("MANT", instruction_mant); |
INSTRUCTION("MARK", instruction_mark); |
INSTRUCTION("MARK", instruction_mark); |
//INSTRUCTION("MAXR") |
//INSTRUCTION("MAXR") |
Line 487 initialisation_instructions(struct_proce
|
Line 487 initialisation_instructions(struct_proce
|
INSTRUCTION("PMAX", instruction_pmax); |
INSTRUCTION("PMAX", instruction_pmax); |
INSTRUCTION("PMIN", instruction_pmin); |
INSTRUCTION("PMIN", instruction_pmin); |
INSTRUCTION("POKE", instruction_poke); |
INSTRUCTION("POKE", instruction_poke); |
|
INSTRUCTION("POLL", instruction_poll); |
INSTRUCTION("PPAR", instruction_ppar); |
INSTRUCTION("PPAR", instruction_ppar); |
INSTRUCTION("PRMD", instruction_prmd); |
INSTRUCTION("PRMD", instruction_prmd); |
INSTRUCTION("PRST", instruction_prst); |
INSTRUCTION("PRST", instruction_prst); |
Line 540 initialisation_instructions(struct_proce
|
Line 541 initialisation_instructions(struct_proce
|
INSTRUCTION("SPAR", instruction_spar); |
INSTRUCTION("SPAR", instruction_spar); |
INSTRUCTION("SQRT", instruction_sqrt); |
INSTRUCTION("SQRT", instruction_sqrt); |
//INSTRUCTION("SRAD"); |
//INSTRUCTION("SRAD"); |
|
INSTRUCTION("SREV", instruction_srev); |
//INSTRUCTION("SRNM") |
//INSTRUCTION("SRNM") |
//Instruction HP48 (renvoie la norme spectrale d'un tableau. Pour une |
//Instruction HP48 (renvoie la norme spectrale d'un tableau. Pour une |
//matrice, |
//matrice, |
Line 565 initialisation_instructions(struct_proce
|
Line 567 initialisation_instructions(struct_proce
|
INSTRUCTION("TRNC", instruction_trnc); |
INSTRUCTION("TRNC", instruction_trnc); |
INSTRUCTION("TRUE", instruction_true); |
INSTRUCTION("TRUE", instruction_true); |
INSTRUCTION("TYPE", instruction_type); |
INSTRUCTION("TYPE", instruction_type); |
|
INSTRUCTION("T->L", instruction_t_vers_l); |
INSTRUCTION("UTPC", instruction_utpc); |
INSTRUCTION("UTPC", instruction_utpc); |
INSTRUCTION("UTPF", instruction_utpf); |
INSTRUCTION("UTPF", instruction_utpf); |
INSTRUCTION("UTPN", instruction_utpn); |
INSTRUCTION("UTPN", instruction_utpn); |
Line 645 initialisation_instructions(struct_proce
|
Line 648 initialisation_instructions(struct_proce
|
INSTRUCTION("LCASE", instruction_lcase); |
INSTRUCTION("LCASE", instruction_lcase); |
INSTRUCTION("LCHOL", instruction_lchol); |
INSTRUCTION("LCHOL", instruction_lchol); |
INSTRUCTION("LCD->", instruction_lcd_fleche); |
INSTRUCTION("LCD->", instruction_lcd_fleche); |
|
INSTRUCTION("LIMIT", instruction_limit); |
//INSTRUCTION("NDIST") |
//INSTRUCTION("NDIST") |
//Instruction HP48 (distribution normale, prend la moyenne au niveau 3, |
//Instruction HP48 (distribution normale, prend la moyenne au niveau 3, |
//la variance au niveau 2, un réel x au niveau 1 et renvoie la probabilité |
//la variance au niveau 2, un réel x au niveau 1 et renvoie la probabilité |
Line 673 initialisation_instructions(struct_proce
|
Line 677 initialisation_instructions(struct_proce
|
INSTRUCTION("PSDEV", instruction_psdev); |
INSTRUCTION("PSDEV", instruction_psdev); |
INSTRUCTION("PURGE", instruction_purge); |
INSTRUCTION("PURGE", instruction_purge); |
INSTRUCTION("RDATE", instruction_rdate); |
INSTRUCTION("RDATE", instruction_rdate); |
|
INSTRUCTION("REGEX", instruction_regex); |
INSTRUCTION("RELAX", instruction_relax); |
INSTRUCTION("RELAX", instruction_relax); |
INSTRUCTION("RFUSE", instruction_rfuse); |
INSTRUCTION("RFUSE", instruction_rfuse); |
INSTRUCTION("RSTOP", instruction_rstop); |
INSTRUCTION("RSTOP", instruction_rstop); |
Line 722 initialisation_instructions(struct_proce
|
Line 727 initialisation_instructions(struct_proce
|
INSTRUCTION("CLRSWI", instruction_clrswi); |
INSTRUCTION("CLRSWI", instruction_clrswi); |
INSTRUCTION("CREATE", instruction_create); |
INSTRUCTION("CREATE", instruction_create); |
INSTRUCTION("DELETE", instruction_delete); |
INSTRUCTION("DELETE", instruction_delete); |
INSTRUCTION("DETACH", instruction_detach); |
# ifdef SHARED_MEMORY |
|
INSTRUCTION("DETACH", instruction_detach); |
|
# else |
|
if ((*s_etat_processus).langue == 'F') |
|
{ |
|
printf("+++Attention : DETACH est émulé par SPAWN car le système" |
|
" hôte ne supporte\n" |
|
" pas de mémoire partagée !\n"); |
|
} |
|
else |
|
{ |
|
printf("+++Warning : DETACH is replaced by SPAWN as host system" |
|
" does not support\n" |
|
" shared memory !\n"); |
|
} |
|
|
|
INSTRUCTION("DETACH", instruction_spawn); |
|
# endif |
INSTRUCTION("DIAG->", instruction_diag_fleche); |
INSTRUCTION("DIAG->", instruction_diag_fleche); |
//INSTRUCTION("DOLIST") |
//INSTRUCTION("DOLIST") |
//Instruction HP48 (application d'une fonction à une liste) |
//Instruction HP48 (application d'une fonction à une liste) |
Line 735 initialisation_instructions(struct_proce
|
Line 757 initialisation_instructions(struct_proce
|
//DOLIST |
//DOLIST |
//=> { 29 42 57 } |
//=> { 29 42 57 } |
INSTRUCTION("ELSEIF", instruction_elseif); |
INSTRUCTION("ELSEIF", instruction_elseif); |
|
INSTRUCTION("FORALL", instruction_forall); |
INSTRUCTION("FORMAT", instruction_format); |
INSTRUCTION("FORMAT", instruction_format); |
//INSTRUCTION("HEIGHT") |
//INSTRUCTION("HEIGHT") |
INSTRUCTION("ITRACE", instruction_itrace); |
INSTRUCTION("ITRACE", instruction_itrace); |
Line 803 initialisation_instructions(struct_proce
|
Line 826 initialisation_instructions(struct_proce
|
INSTRUCTION("PROTECT", instruction_protect); |
INSTRUCTION("PROTECT", instruction_protect); |
INSTRUCTION("PSHPRFL", instruction_pshprfl); |
INSTRUCTION("PSHPRFL", instruction_pshprfl); |
INSTRUCTION("PULPRFL", instruction_pulprfl); |
INSTRUCTION("PULPRFL", instruction_pulprfl); |
|
INSTRUCTION("RESTART", instruction_restart); |
INSTRUCTION("REVLIST", instruction_revlist); |
INSTRUCTION("REVLIST", instruction_revlist); |
INSTRUCTION("SCATTER", instruction_scatter); |
INSTRUCTION("SCATTER", instruction_scatter); |
INSTRUCTION("SUSPEND", instruction_suspend); |
INSTRUCTION("SUSPEND", instruction_suspend); |
Line 817 initialisation_instructions(struct_proce
|
Line 841 initialisation_instructions(struct_proce
|
INSTRUCTION("CLRCNTXT", instruction_clrcntxt); |
INSTRUCTION("CLRCNTXT", instruction_clrcntxt); |
INSTRUCTION("CLRSMPHR", instruction_clrsmphr); |
INSTRUCTION("CLRSMPHR", instruction_clrsmphr); |
INSTRUCTION("CONTINUE", instruction_continue); |
INSTRUCTION("CONTINUE", instruction_continue); |
|
INSTRUCTION("CRITICAL", instruction_critical); |
INSTRUCTION("DUPCNTXT", instruction_dupcntxt); |
INSTRUCTION("DUPCNTXT", instruction_dupcntxt); |
INSTRUCTION("FUNCTION", instruction_function); |
INSTRUCTION("FUNCTION", instruction_function); |
INSTRUCTION("IMPLICIT", instruction_implicit); |
INSTRUCTION("IMPLICIT", instruction_implicit); |
|
INSTRUCTION("INFINITY", instruction_sensible_infinity); |
INSTRUCTION("KEYLABEL", instruction_keylabel); |
INSTRUCTION("KEYLABEL", instruction_keylabel); |
INSTRUCTION("KEYTITLE", instruction_keytitle); |
INSTRUCTION("KEYTITLE", instruction_keytitle); |
INSTRUCTION("LOGSCALE", instruction_logscale); |
INSTRUCTION("LOGSCALE", instruction_logscale); |
Line 884 initialisation_instructions(struct_proce
|
Line 910 initialisation_instructions(struct_proce
|
} |
} |
|
|
|
|
#ifndef OS2 |
|
extern inline |
|
#endif |
|
void * |
void * |
analyse_instruction(struct_processus *s_etat_processus, unsigned char *ptr) |
analyse_instruction(struct_processus *s_etat_processus, unsigned char *ptr) |
{ |
{ |
Line 907 analyse_instruction(struct_processus *s_
|
Line 930 analyse_instruction(struct_processus *s_
|
return(NULL); |
return(NULL); |
} |
} |
|
|
if ((*l_instruction_courante).noeud[pointeur] == NULL) |
if ((*l_instruction_courante).noeuds[pointeur] == NULL) |
{ |
{ |
// Le chemin de l'instruction candidate n'existe pas. |
// Le chemin de l'instruction candidate n'existe pas. |
|
|
return(NULL); |
return(NULL); |
} |
} |
|
|
l_instruction_courante = (*l_instruction_courante).noeud[pointeur]; |
l_instruction_courante = (*l_instruction_courante).noeuds[pointeur]; |
ptr++; |
ptr++; |
|
|
if ((l_instruction_courante == NULL) && ((*ptr) != d_code_fin_chaine)) |
if ((l_instruction_courante == NULL) && ((*ptr) != d_code_fin_chaine)) |
Line 947 analyse(struct_processus *s_etat_process
|
Line 970 analyse(struct_processus *s_etat_process
|
static struct timeval horodatage_initial; |
static struct timeval horodatage_initial; |
struct timeval horodatage_final; |
struct timeval horodatage_final; |
|
|
|
# ifndef OS2 |
static struct rusage usage_initial; |
static struct rusage usage_initial; |
struct rusage usage_final; |
struct rusage usage_final; |
|
# else |
|
static clock_t usage_initial; |
|
clock_t usage_final; |
|
# endif |
|
|
struct timespec temporisation; |
struct timespec temporisation; |
|
|
Line 973 analyse(struct_processus *s_etat_process
|
Line 1001 analyse(struct_processus *s_etat_process
|
*/ |
*/ |
|
|
# ifndef SEMAPHORES_NOMMES |
# 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) |
|
# endif |
{ |
{ |
(*s_etat_processus).erreur_systeme = d_es_processus; |
(*s_etat_processus).erreur_systeme = d_es_processus; |
return; |
return; |
} |
} |
|
|
while(sem_wait(&((*s_etat_processus).semaphore_fork)) == -1) |
# ifndef SEMAPHORES_NOMMES |
|
while(sem_wait(&((*s_etat_processus).semaphore_fork)) != 0) |
|
# else |
|
while(sem_wait((*s_etat_processus).semaphore_fork) != 0) |
|
# endif |
{ |
{ |
if (errno != EINTR) |
if (errno != EINTR) |
{ |
{ |
Line 987 analyse(struct_processus *s_etat_process
|
Line 1022 analyse(struct_processus *s_etat_process
|
return; |
return; |
} |
} |
} |
} |
# else |
|
if (sem_post((*s_etat_processus).semaphore_fork) != 0) |
/* |
|
* Verrou pour les sections_critiques |
|
*/ |
|
|
|
if (pthread_mutex_lock(&mutex_sections_critiques) != 0) |
{ |
{ |
(*s_etat_processus).erreur_systeme = d_es_processus; |
(*s_etat_processus).erreur_systeme = d_es_processus; |
return; |
return; |
} |
} |
|
|
while(sem_wait((*s_etat_processus).semaphore_fork) == -1) |
if (pthread_mutex_unlock(&mutex_sections_critiques) != 0) |
{ |
{ |
if (errno != EINTR) |
(*s_etat_processus).erreur_systeme = d_es_processus; |
{ |
return; |
(*s_etat_processus).erreur_systeme = d_es_processus; |
|
return; |
|
} |
|
} |
} |
# endif |
|
|
|
scrutation_injection(s_etat_processus); |
scrutation_injection(s_etat_processus); |
|
|
Line 1149 analyse(struct_processus *s_etat_process
|
Line 1184 analyse(struct_processus *s_etat_process
|
|
|
if ((*s_etat_processus).pourcentage_maximal_cpu < 100) |
if ((*s_etat_processus).pourcentage_maximal_cpu < 100) |
{ |
{ |
|
# ifndef OS2 |
getrusage(RUSAGE_SELF, &usage_final); |
getrusage(RUSAGE_SELF, &usage_final); |
|
# else |
|
usage_final = clock(); |
|
# endif |
|
|
gettimeofday(&horodatage_final, NULL); |
gettimeofday(&horodatage_final, NULL); |
|
|
if (initialisation == d_vrai) |
if (initialisation == d_vrai) |
Line 1159 analyse(struct_processus *s_etat_process
|
Line 1199 analyse(struct_processus *s_etat_process
|
(((real8) (horodatage_final.tv_usec - |
(((real8) (horodatage_final.tv_usec - |
horodatage_initial.tv_usec)) / ((real8) 1E6)); |
horodatage_initial.tv_usec)) / ((real8) 1E6)); |
|
|
|
// Le temps depuis la dernière limitation est de plus de un |
|
// dixième de seconde. |
|
|
if (temps_reel >= 0.1) |
if (temps_reel >= 0.1) |
{ |
{ |
|
# ifndef OS2 |
temps_cpu = ((real8) ((usage_final.ru_utime.tv_sec + |
temps_cpu = ((real8) ((usage_final.ru_utime.tv_sec + |
usage_final.ru_stime.tv_sec) - |
usage_final.ru_stime.tv_sec) - |
(usage_initial.ru_utime.tv_sec + |
(usage_initial.ru_utime.tv_sec + |
Line 1169 analyse(struct_processus *s_etat_process
|
Line 1213 analyse(struct_processus *s_etat_process
|
usage_final.ru_stime.tv_usec) - |
usage_final.ru_stime.tv_usec) - |
(usage_initial.ru_utime.tv_usec + |
(usage_initial.ru_utime.tv_usec + |
usage_initial.ru_stime.tv_usec))) / ((real8) 1E6)); |
usage_initial.ru_stime.tv_usec))) / ((real8) 1E6)); |
|
# else |
|
temps_cpu = (usage_final - usage_initial) / CLOCKS_PER_SEC; |
|
# endif |
|
|
pourcentage = 100 * temps_cpu / temps_reel; |
pourcentage = 100 * temps_cpu / temps_reel; |
|
|
Line 1187 analyse(struct_processus *s_etat_process
|
Line 1234 analyse(struct_processus *s_etat_process
|
temporisation.tv_nsec = (attente - temporisation.tv_sec) * |
temporisation.tv_nsec = (attente - temporisation.tv_sec) * |
1E9; |
1E9; |
|
|
nanosleep(&temporisation, NULL); |
while(nanosleep(&temporisation, &temporisation) == -1) |
|
{ |
|
if (errno != EINTR) |
|
{ |
|
break; |
|
} |
|
} |
} |
} |
|
|
horodatage_initial = horodatage_final; |
horodatage_initial = horodatage_final; |
Line 1202 analyse(struct_processus *s_etat_process
|
Line 1255 analyse(struct_processus *s_etat_process
|
usage_initial = usage_final; |
usage_initial = usage_final; |
} |
} |
} |
} |
|
else |
|
{ |
|
initialisation = d_faux; |
|
} |
|
|
/* |
/* |
-------------------------------------------------------------------------------- |
-------------------------------------------------------------------------------- |