--- rpl/src/analyse.c 2011/08/01 08:07:55 1.50 +++ rpl/src/analyse.c 2011/10/21 11:38:38 1.62 @@ -1,6 +1,6 @@ /* ================================================================================ - RPL/2 (R) version 4.1.2 + RPL/2 (R) version 4.1.4 Copyright (C) 1989-2011 Dr. BERTRAND Joël This file is part of RPL/2. @@ -458,9 +458,7 @@ initialisation_instructions(struct_proce INSTRUCTION("INCR", instruction_incr); //INSTRUCTION("ISOL"); INSTRUCTION("ISWI", instruction_iswi); -# ifndef OS2 INSTRUCTION("KILL", instruction_kill); -# endif INSTRUCTION("KIND", instruction_kind); INSTRUCTION("LAST", instruction_last); INSTRUCTION("LEGV", instruction_legv); @@ -488,9 +486,7 @@ initialisation_instructions(struct_proce INSTRUCTION("PLOT", instruction_plot); INSTRUCTION("PMAX", instruction_pmax); INSTRUCTION("PMIN", instruction_pmin); -# ifndef OS2 INSTRUCTION("POKE", instruction_poke); -# endif INSTRUCTION("PPAR", instruction_ppar); INSTRUCTION("PRMD", instruction_prmd); INSTRUCTION("PRST", instruction_prst); @@ -544,6 +540,7 @@ initialisation_instructions(struct_proce INSTRUCTION("SPAR", instruction_spar); INSTRUCTION("SQRT", instruction_sqrt); //INSTRUCTION("SRAD"); + INSTRUCTION("SREV", instruction_srev); //INSTRUCTION("SRNM") //Instruction HP48 (renvoie la norme spectrale d'un tableau. Pour une //matrice, @@ -556,9 +553,7 @@ initialisation_instructions(struct_proce INSTRUCTION("STO-", instruction_sto_moins); INSTRUCTION("STO/", instruction_sto_division); INSTRUCTION("STOF", instruction_stof); -# ifndef OS2 INSTRUCTION("STOP", instruction_stop); -# endif INSTRUCTION("STOS", instruction_stos); INSTRUCTION("STWS", instruction_stws); INSTRUCTION("SWAP", instruction_swap); @@ -652,6 +647,7 @@ initialisation_instructions(struct_proce INSTRUCTION("LCASE", instruction_lcase); INSTRUCTION("LCHOL", instruction_lchol); INSTRUCTION("LCD->", instruction_lcd_fleche); + INSTRUCTION("LIMIT", instruction_limit); //INSTRUCTION("NDIST") //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é @@ -692,9 +688,7 @@ initialisation_instructions(struct_proce INSTRUCTION("SLICE", instruction_slice); //INSTRUCTION("SLIST") //Instruction HP48 (somme des termes d'une liste) -# ifndef OS2 INSTRUCTION("SPAWN", instruction_spawn); -# endif INSTRUCTION("START", instruction_start); INSTRUCTION("STORE", instruction_store); INSTRUCTION("STR->", instruction_str_fleche); @@ -731,8 +725,23 @@ initialisation_instructions(struct_proce INSTRUCTION("CLRSWI", instruction_clrswi); INSTRUCTION("CREATE", instruction_create); INSTRUCTION("DELETE", instruction_delete); -# ifndef OS2 - 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("DOLIST") @@ -827,9 +836,7 @@ initialisation_instructions(struct_proce INSTRUCTION("CLRCNTXT", instruction_clrcntxt); INSTRUCTION("CLRSMPHR", instruction_clrsmphr); -# ifndef OS2 INSTRUCTION("CONTINUE", instruction_continue); -# endif INSTRUCTION("DUPCNTXT", instruction_dupcntxt); INSTRUCTION("FUNCTION", instruction_function); INSTRUCTION("IMPLICIT", instruction_implicit); @@ -958,8 +965,13 @@ analyse(struct_processus *s_etat_process static struct timeval horodatage_initial; struct timeval horodatage_final; +# ifndef OS2 static struct rusage usage_initial; struct rusage usage_final; +# else + static clock_t usage_initial; + clock_t usage_final; +# endif struct timespec temporisation; @@ -984,28 +996,20 @@ analyse(struct_processus *s_etat_process */ # ifndef SEMAPHORES_NOMMES - if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0) - { - (*s_etat_processus).erreur_systeme = d_es_processus; - return; - } - - while(sem_wait(&((*s_etat_processus).semaphore_fork)) == -1) - { - if (errno != EINTR) - { - (*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; } - 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) { @@ -1013,7 +1017,6 @@ analyse(struct_processus *s_etat_process return; } } -# endif scrutation_injection(s_etat_processus); @@ -1158,10 +1161,14 @@ analyse(struct_processus *s_etat_process -------------------------------------------------------------------------------- */ -# ifndef OS2 if ((*s_etat_processus).pourcentage_maximal_cpu < 100) { +# ifndef OS2 getrusage(RUSAGE_SELF, &usage_final); +# else + usage_final = clock(); +# endif + gettimeofday(&horodatage_final, NULL); if (initialisation == d_vrai) @@ -1171,8 +1178,12 @@ analyse(struct_processus *s_etat_process (((real8) (horodatage_final.tv_usec - 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) { +# ifndef OS2 temps_cpu = ((real8) ((usage_final.ru_utime.tv_sec + usage_final.ru_stime.tv_sec) - (usage_initial.ru_utime.tv_sec + @@ -1181,6 +1192,9 @@ analyse(struct_processus *s_etat_process usage_final.ru_stime.tv_usec) - (usage_initial.ru_utime.tv_usec + 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; @@ -1199,7 +1213,13 @@ analyse(struct_processus *s_etat_process temporisation.tv_nsec = (attente - temporisation.tv_sec) * 1E9; - nanosleep(&temporisation, NULL); + while(nanosleep(&temporisation, &temporisation) == -1) + { + if (errno != EINTR) + { + break; + } + } } horodatage_initial = horodatage_final; @@ -1214,7 +1234,10 @@ analyse(struct_processus *s_etat_process usage_initial = usage_final; } } -# endif + else + { + initialisation = d_faux; + } /* --------------------------------------------------------------------------------