--- rpl/src/fusible.c 2010/04/21 13:45:45 1.7 +++ rpl/src/fusible.c 2011/10/14 09:02:16 1.37 @@ -1,7 +1,7 @@ /* ================================================================================ - RPL/2 (R) version 4.0.15 - Copyright (C) 1989-2010 Dr. BERTRAND Joël + RPL/2 (R) version 4.1.4 + Copyright (C) 1989-2011 Dr. BERTRAND Joël This file is part of RPL/2. @@ -20,7 +20,7 @@ */ -#include "rpl.conv.h" +#include "rpl-conv.h" /* @@ -43,25 +43,18 @@ fusible(void *argument) real8 temps_cpu_precedent; real8 temps_cpu_courant; - sigset_t masque; - struct_processus *s_etat_processus; +# ifndef OS2 struct rusage s_rusage; +# else + clock_t horloge; +# endif struct timespec temporisation; s_etat_processus = argument; - sigemptyset(&masque); - sigaddset(&masque, SIGINJECT); - sigaddset(&masque, SIGFSTOP); - sigaddset(&masque, SIGURG); - sigaddset(&masque, SIGALRM); - sigaddset(&masque, SIGCONT); - sigaddset(&masque, SIGINT); - pthread_sigmask(SIG_BLOCK, &masque, NULL); - if ((*s_etat_processus).debug == d_vrai) if (((*s_etat_processus).type_debug & d_debug_fusible) != 0) @@ -84,22 +77,41 @@ fusible(void *argument) temporisation.tv_sec = 0; temporisation.tv_nsec = 100000000; // un dixième de seconde + // Par défaut, le thread peut être annulé. + +# ifdef PTHREAD_CANCEL_ENABLE pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL); +# endif - getrusage(RUSAGE_SELF, &s_rusage); - temps_cpu_courant = s_rusage.ru_utime.tv_sec + - (((real8) s_rusage.ru_utime.tv_usec) / ((real8) 1E6)); +# ifndef OS2 + getrusage(RUSAGE_SELF, &s_rusage); + temps_cpu_courant = s_rusage.ru_utime.tv_sec + + (((real8) s_rusage.ru_utime.tv_usec) / ((real8) 1E6)); +# else + horloge = clock(); + temps_cpu_courant = horloge / CLOCKS_PER_SEC; +# endif do { pthread_testcancel(); nanosleep(&temporisation, NULL); - - getrusage(RUSAGE_SELF, &s_rusage); - temps_cpu_precedent = temps_cpu_courant; - temps_cpu_courant = s_rusage.ru_utime.tv_sec + - (((real8) s_rusage.ru_utime.tv_usec) / ((real8) 1E6)); + +# ifndef OS2 + getrusage(RUSAGE_SELF, &s_rusage); + temps_cpu_courant = s_rusage.ru_utime.tv_sec + + (((real8) s_rusage.ru_utime.tv_usec) / ((real8) 1E6)); +# else + horloge = clock(); + temps_cpu_courant = horloge / CLOCKS_PER_SEC; + + if (temps_cpu_courant < temps_cpu_precedent) + { + // Le compteur a fait un tour... + temps_cpu_precedent = temps_cpu_courant; + } +# endif (*s_etat_processus).temps_maximal_cpu -= temps_cpu_courant - temps_cpu_precedent; @@ -108,8 +120,8 @@ fusible(void *argument) { (*s_etat_processus).temps_maximal_cpu = 0; - pthread_kill((*s_etat_processus).thread_surveille_par_fusible, - SIGFSTOP); + envoi_signal_thread((*s_etat_processus) + .thread_surveille_par_fusible, rpl_sigstop); break; } } while((*s_etat_processus).var_volatile_requete_arret == 0);