--- rpl/src/analyse.c 2011/10/10 10:58:12 1.60 +++ rpl/src/analyse.c 2011/11/30 17:21:07 1.64 @@ -1,6 +1,6 @@ /* ================================================================================ - RPL/2 (R) version 4.1.4 + RPL/2 (R) version 4.1.5 Copyright (C) 1989-2011 Dr. BERTRAND Joël This file is part of RPL/2. @@ -823,6 +823,7 @@ initialisation_instructions(struct_proce INSTRUCTION("PROTECT", instruction_protect); INSTRUCTION("PSHPRFL", instruction_pshprfl); INSTRUCTION("PULPRFL", instruction_pulprfl); + INSTRUCTION("RESTART", instruction_restart); INSTRUCTION("REVLIST", instruction_revlist); INSTRUCTION("SCATTER", instruction_scatter); INSTRUCTION("SUSPEND", instruction_suspend); @@ -965,8 +966,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; @@ -1156,10 +1162,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) @@ -1169,8 +1179,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 + @@ -1179,6 +1193,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; @@ -1197,7 +1214,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; @@ -1212,7 +1235,10 @@ analyse(struct_processus *s_etat_process usage_initial = usage_final; } } -# endif + else + { + initialisation = d_faux; + } /* --------------------------------------------------------------------------------