Diff for /rpl/src/analyse.c between versions 1.57 and 1.69

version 1.57, 2011/09/20 14:36:28 version 1.69, 2012/03/01 10:14:03
Line 1 Line 1
 /*  /*
 ================================================================================  ================================================================================
   RPL/2 (R) version 4.1.3    RPL/2 (R) version 4.1.7
   Copyright (C) 1989-2011 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 458  initialisation_instructions(struct_proce Line 458  initialisation_instructions(struct_proce
     INSTRUCTION("INCR", instruction_incr);      INSTRUCTION("INCR", instruction_incr);
     //INSTRUCTION("ISOL");      //INSTRUCTION("ISOL");
     INSTRUCTION("ISWI", instruction_iswi);      INSTRUCTION("ISWI", instruction_iswi);
 #   ifndef OS2  
     INSTRUCTION("KILL", instruction_kill);      INSTRUCTION("KILL", instruction_kill);
 #   endif  
     INSTRUCTION("KIND", instruction_kind);      INSTRUCTION("KIND", instruction_kind);
     INSTRUCTION("LAST", instruction_last);      INSTRUCTION("LAST", instruction_last);
     INSTRUCTION("LEGV", instruction_legv);      INSTRUCTION("LEGV", instruction_legv);
Line 488  initialisation_instructions(struct_proce Line 486  initialisation_instructions(struct_proce
     INSTRUCTION("PLOT", instruction_plot);      INSTRUCTION("PLOT", instruction_plot);
     INSTRUCTION("PMAX", instruction_pmax);      INSTRUCTION("PMAX", instruction_pmax);
     INSTRUCTION("PMIN", instruction_pmin);      INSTRUCTION("PMIN", instruction_pmin);
 #   ifndef OS2  
     INSTRUCTION("POKE", instruction_poke);      INSTRUCTION("POKE", instruction_poke);
 #   endif      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 557  initialisation_instructions(struct_proce Line 554  initialisation_instructions(struct_proce
     INSTRUCTION("STO-", instruction_sto_moins);      INSTRUCTION("STO-", instruction_sto_moins);
     INSTRUCTION("STO/", instruction_sto_division);      INSTRUCTION("STO/", instruction_sto_division);
     INSTRUCTION("STOF", instruction_stof);      INSTRUCTION("STOF", instruction_stof);
 #   ifndef OS2  
     INSTRUCTION("STOP", instruction_stop);      INSTRUCTION("STOP", instruction_stop);
 #   endif  
     INSTRUCTION("STOS", instruction_stos);      INSTRUCTION("STOS", instruction_stos);
     INSTRUCTION("STWS", instruction_stws);      INSTRUCTION("STWS", instruction_stws);
     INSTRUCTION("SWAP", instruction_swap);      INSTRUCTION("SWAP", instruction_swap);
Line 682  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 694  initialisation_instructions(struct_proce Line 690  initialisation_instructions(struct_proce
     INSTRUCTION("SLICE", instruction_slice);      INSTRUCTION("SLICE", instruction_slice);
     //INSTRUCTION("SLIST")      //INSTRUCTION("SLIST")
     //Instruction HP48 (somme des termes d'une liste)      //Instruction HP48 (somme des termes d'une liste)
 #   ifndef OS2  
     INSTRUCTION("SPAWN", instruction_spawn);      INSTRUCTION("SPAWN", instruction_spawn);
 #   endif  
     INSTRUCTION("START", instruction_start);      INSTRUCTION("START", instruction_start);
     INSTRUCTION("STORE", instruction_store);      INSTRUCTION("STORE", instruction_store);
     INSTRUCTION("STR->", instruction_str_fleche);      INSTRUCTION("STR->", instruction_str_fleche);
Line 733  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);
 #   ifndef OS2  #   ifdef SHARED_MEMORY
     INSTRUCTION("DETACH", instruction_detach);          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  #   endif
     INSTRUCTION("DIAG->", instruction_diag_fleche);      INSTRUCTION("DIAG->", instruction_diag_fleche);
     //INSTRUCTION("DOLIST")      //INSTRUCTION("DOLIST")
Line 816  initialisation_instructions(struct_proce Line 825  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 829  initialisation_instructions(struct_proce Line 839  initialisation_instructions(struct_proce
   
     INSTRUCTION("CLRCNTXT", instruction_clrcntxt);      INSTRUCTION("CLRCNTXT", instruction_clrcntxt);
     INSTRUCTION("CLRSMPHR", instruction_clrsmphr);      INSTRUCTION("CLRSMPHR", instruction_clrsmphr);
 #   ifndef OS2  
     INSTRUCTION("CONTINUE", instruction_continue);      INSTRUCTION("CONTINUE", instruction_continue);
 #   endif  
     INSTRUCTION("DUPCNTXT", instruction_dupcntxt);      INSTRUCTION("DUPCNTXT", instruction_dupcntxt);
     INSTRUCTION("FUNCTION", instruction_function);      INSTRUCTION("FUNCTION", instruction_function);
     INSTRUCTION("IMPLICIT", instruction_implicit);      INSTRUCTION("IMPLICIT", instruction_implicit);
Line 960  analyse(struct_processus *s_etat_process Line 968  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 1151  analyse(struct_processus *s_etat_process Line 1164  analyse(struct_processus *s_etat_process
 --------------------------------------------------------------------------------  --------------------------------------------------------------------------------
 */  */
   
 #   ifndef OS2  
     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 1164  analyse(struct_processus *s_etat_process Line 1181  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 1174  analyse(struct_processus *s_etat_process Line 1195  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 1192  analyse(struct_processus *s_etat_process Line 1216  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 1207  analyse(struct_processus *s_etat_process Line 1237  analyse(struct_processus *s_etat_process
             usage_initial = usage_final;              usage_initial = usage_final;
         }          }
     }      }
 #   endif      else
       {
           initialisation = d_faux;
       }
   
 /*  /*
 --------------------------------------------------------------------------------  --------------------------------------------------------------------------------

Removed from v.1.57  
changed lines
  Added in v.1.69


CVSweb interface <joel.bertrand@systella.fr>