version 1.5, 2010/03/09 10:18:44
|
version 1.75, 2019/02/09 13:36:34
|
Line 1
|
Line 1
|
/* |
/* |
================================================================================ |
================================================================================ |
RPL/2 (R) version 4.0.13 |
RPL/2 (R) version 4.1.31 |
Copyright (C) 1989-2010 Dr. BERTRAND Joël |
Copyright (C) 1989-2019 Dr. BERTRAND Joël |
|
|
This file is part of RPL/2. |
This file is part of RPL/2. |
|
|
Line 20
|
Line 20
|
*/ |
*/ |
|
|
|
|
#include "rpl.conv.h" |
#include "rpl-conv.h" |
|
|
|
|
/* |
/* |
Line 43 fusible(void *argument)
|
Line 43 fusible(void *argument)
|
real8 temps_cpu_precedent; |
real8 temps_cpu_precedent; |
real8 temps_cpu_courant; |
real8 temps_cpu_courant; |
|
|
sigset_t masque; |
|
|
|
struct_processus *s_etat_processus; |
struct_processus *s_etat_processus; |
|
|
|
# ifndef OS2 |
struct rusage s_rusage; |
struct rusage s_rusage; |
|
# else |
|
clock_t horloge; |
|
# endif |
|
|
struct timespec temporisation; |
struct timespec temporisation; |
|
|
s_etat_processus = argument; |
sigset_t set; |
|
|
|
sigfillset(&set); |
|
pthread_sigmask(SIG_BLOCK, &set, NULL); |
|
|
sigemptyset(&masque); |
s_etat_processus = argument; |
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).debug == d_vrai) |
if (((*s_etat_processus).type_debug & |
if (((*s_etat_processus).type_debug & |
Line 84 fusible(void *argument)
|
Line 82 fusible(void *argument)
|
temporisation.tv_sec = 0; |
temporisation.tv_sec = 0; |
temporisation.tv_nsec = 100000000; // un dixième de seconde |
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); |
pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL); |
|
# endif |
|
|
getrusage(RUSAGE_SELF, &s_rusage); |
# ifndef OS2 |
temps_cpu_courant = s_rusage.ru_utime.tv_sec + |
getrusage(RUSAGE_SELF, &s_rusage); |
(((real8) s_rusage.ru_utime.tv_usec) / ((real8) 1E6)); |
temps_cpu_courant = ((real8) 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 |
do |
{ |
{ |
pthread_testcancel(); |
pthread_testcancel(); |
nanosleep(&temporisation, NULL); |
nanosleep(&temporisation, NULL); |
|
|
getrusage(RUSAGE_SELF, &s_rusage); |
|
|
|
temps_cpu_precedent = temps_cpu_courant; |
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 = ((real8) 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 - |
(*s_etat_processus).temps_maximal_cpu -= temps_cpu_courant - |
temps_cpu_precedent; |
temps_cpu_precedent; |
Line 108 fusible(void *argument)
|
Line 125 fusible(void *argument)
|
{ |
{ |
(*s_etat_processus).temps_maximal_cpu = 0; |
(*s_etat_processus).temps_maximal_cpu = 0; |
|
|
pthread_kill((*s_etat_processus).thread_surveille_par_fusible, |
envoi_signal_thread(NULL, (*s_etat_processus) |
SIGFSTOP); |
.thread_surveille_par_fusible, rpl_sigstop); |
break; |
break; |
} |
} |
} while((*s_etat_processus).var_volatile_requete_arret == 0); |
} while((*s_etat_processus).var_volatile_requete_arret == 0); |