Diff for /rpl/src/analyse.c between versions 1.72 and 1.92

version 1.72, 2012/08/22 10:47:13 version 1.92, 2013/12/03 09:36:10
Line 1 Line 1
 /*  /*
 ================================================================================  ================================================================================
   RPL/2 (R) version 4.1.10    RPL/2 (R) version 4.1.17
   Copyright (C) 1989-2012 Dr. BERTRAND Joël    Copyright (C) 1989-2013 Dr. BERTRAND Joël
   
   This file is part of RPL/2.    This file is part of RPL/2.
   
Line 61  creation_instruction(struct_processus *s Line 61  creation_instruction(struct_processus *s
         (*(*s_etat_processus).arbre_instructions).feuille = NULL;          (*(*s_etat_processus).arbre_instructions).feuille = NULL;
   
         if (((*(*s_etat_processus).arbre_instructions).noeuds =          if (((*(*s_etat_processus).arbre_instructions).noeuds =
                 malloc((*s_etat_processus).nombre_caracteres                  malloc(((size_t) (*s_etat_processus).nombre_caracteres)
                 * sizeof(struct_instruction))) == NULL)                  * sizeof(struct_instruction))) == NULL)
         {          {
             (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;              (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
Line 101  creation_instruction(struct_processus *s Line 101  creation_instruction(struct_processus *s
   
             if (((*(*l_instruction_courante).noeuds[(*s_etat_processus)              if (((*(*l_instruction_courante).noeuds[(*s_etat_processus)
                     .pointeurs_caracteres[*ptr]]).noeuds =                      .pointeurs_caracteres[*ptr]]).noeuds =
                     malloc((*s_etat_processus).nombre_caracteres                      malloc(((size_t) (*s_etat_processus).nombre_caracteres)
                     * sizeof(struct_instruction))) == NULL)                      * sizeof(struct_instruction))) == NULL)
             {              {
                 (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;                  (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
Line 180  initialisation_instructions(struct_proce Line 180  initialisation_instructions(struct_proce
     }      }
   
     if (((*s_etat_processus).pointeurs_caracteres =      if (((*s_etat_processus).pointeurs_caracteres =
             malloc(longueur_tableau * sizeof(int))) == NULL)              malloc(((size_t) longueur_tableau * sizeof(int)))) == NULL)
     {      {
         (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;          (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
         return;          return;
Line 513  initialisation_instructions(struct_proce Line 513  initialisation_instructions(struct_proce
     INSTRUCTION("RECV", instruction_recv);      INSTRUCTION("RECV", instruction_recv);
     INSTRUCTION("REGV", instruction_regv);      INSTRUCTION("REGV", instruction_regv);
     INSTRUCTION("REPL", instruction_repl);      INSTRUCTION("REPL", instruction_repl);
       INSTRUCTION("RGDL", instruction_rgdl);
       INSTRUCTION("RGDR", instruction_rgdr);
     INSTRUCTION("RNRM", instruction_rnrm);      INSTRUCTION("RNRM", instruction_rnrm);
     INSTRUCTION("ROLL", instruction_roll);      INSTRUCTION("ROLL", instruction_roll);
     //INSTRUCTION("ROOT")      //INSTRUCTION("ROOT")
Line 722  initialisation_instructions(struct_proce Line 724  initialisation_instructions(struct_proce
     INSTRUCTION("ATEXIT", instruction_atexit);      INSTRUCTION("ATEXIT", instruction_atexit);
     INSTRUCTION("ATPOKE", instruction_atpoke);      INSTRUCTION("ATPOKE", instruction_atpoke);
     INSTRUCTION("BESSEL", instruction_bessel);      INSTRUCTION("BESSEL", instruction_bessel);
       INSTRUCTION("CIPHER", instruction_cipher);
     INSTRUCTION("CLRERR", instruction_clrerr);      INSTRUCTION("CLRERR", instruction_clrerr);
     INSTRUCTION("CLRMTX", instruction_clrmtx);      INSTRUCTION("CLRMTX", instruction_clrmtx);
     INSTRUCTION("CLRSWI", instruction_clrswi);      INSTRUCTION("CLRSWI", instruction_clrswi);
Line 746  initialisation_instructions(struct_proce Line 749  initialisation_instructions(struct_proce
         INSTRUCTION("DETACH", instruction_spawn);          INSTRUCTION("DETACH", instruction_spawn);
 #   endif  #   endif
     INSTRUCTION("DIAG->", instruction_diag_fleche);      INSTRUCTION("DIAG->", instruction_diag_fleche);
       INSTRUCTION("DIGEST", instruction_digest);
     //INSTRUCTION("DOLIST")      //INSTRUCTION("DOLIST")
     //Instruction HP48 (application d'une fonction à une liste)      //Instruction HP48 (application d'une fonction à une liste)
     //liste(s) nombre_de_listes_a_traiter fonction DOLIST      //liste(s) nombre_de_listes_a_traiter fonction DOLIST
Line 757  initialisation_instructions(struct_proce Line 761  initialisation_instructions(struct_proce
     //DOLIST      //DOLIST
     //=> { 29 42 57 }      //=> { 29 42 57 }
     INSTRUCTION("ELSEIF", instruction_elseif);      INSTRUCTION("ELSEIF", instruction_elseif);
       INSTRUCTION("FORALL", instruction_forall);
     INSTRUCTION("FORMAT", instruction_format);      INSTRUCTION("FORMAT", instruction_format);
     //INSTRUCTION("HEIGHT")      //INSTRUCTION("HEIGHT")
     INSTRUCTION("ITRACE", instruction_itrace);      INSTRUCTION("ITRACE", instruction_itrace);
Line 839  initialisation_instructions(struct_proce Line 844  initialisation_instructions(struct_proce
   
     INSTRUCTION("CLRCNTXT", instruction_clrcntxt);      INSTRUCTION("CLRCNTXT", instruction_clrcntxt);
     INSTRUCTION("CLRSMPHR", instruction_clrsmphr);      INSTRUCTION("CLRSMPHR", instruction_clrsmphr);
       INSTRUCTION("COMPRESS", instruction_compress);
     INSTRUCTION("CONTINUE", instruction_continue);      INSTRUCTION("CONTINUE", instruction_continue);
       INSTRUCTION("CRITICAL", instruction_critical);
     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 897  initialisation_instructions(struct_proce Line 904  initialisation_instructions(struct_proce
     //pentes      //pentes
     //représentent la valeur de la fonction (x,y) en leur milieu.      //représentent la valeur de la fonction (x,y) en leur milieu.
     //=> utile pour y'=F(x,y)      //=> utile pour y'=F(x,y)
       INSTRUCTION("UNCOMPRESS", instruction_uncompress);
   
     INSTRUCTION("LOCALIZATION", instruction_localization);      INSTRUCTION("LOCALIZATION", instruction_localization);
     INSTRUCTION("SMPHRTRYDECR", instruction_smphrtrydecr);      INSTRUCTION("SMPHRTRYDECR", instruction_smphrtrydecr);
Line 958  analyse_instruction(struct_processus *s_ Line 966  analyse_instruction(struct_processus *s_
 void  void
 analyse(struct_processus *s_etat_processus, void (*fonction)())  analyse(struct_processus *s_etat_processus, void (*fonction)())
 {  {
     static logical1                 initialisation = d_faux;  
   
     real8                           attente;      real8                           attente;
     real8                           pourcentage;      real8                           pourcentage;
     real8                           temps_cpu;      real8                           temps_cpu;
Line 1021  analyse(struct_processus *s_etat_process Line 1027  analyse(struct_processus *s_etat_process
         }          }
     }      }
   
       /*
        * Verrou pour les sections_critiques
        */
   
       if (pthread_mutex_lock(&mutex_sections_critiques) != 0)
       {
           (*s_etat_processus).erreur_systeme = d_es_processus;
           return;
       }
   
       if (pthread_mutex_unlock(&mutex_sections_critiques) != 0)
       {
           (*s_etat_processus).erreur_systeme = d_es_processus;
           return;
       }
   
     scrutation_injection(s_etat_processus);      scrutation_injection(s_etat_processus);
   
     if (fonction == NULL)      if (fonction == NULL)
Line 1083  analyse(struct_processus *s_etat_process Line 1105  analyse(struct_processus *s_etat_process
         if ((position = index((*s_etat_processus).instruction_courante, '$'))          if ((position = index((*s_etat_processus).instruction_courante, '$'))
                 != NULL)                  != NULL)
         {          {
             if ((bibliotheque_candidate = malloc((position + 1              if ((bibliotheque_candidate = malloc(((size_t) (position + 1
                     - (*s_etat_processus).instruction_courante)                      - (*s_etat_processus).instruction_courante))
                     * sizeof(unsigned char))) == NULL)                      * sizeof(unsigned char))) == NULL)
             {              {
                 (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;                  (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
Line 1093  analyse(struct_processus *s_etat_process Line 1115  analyse(struct_processus *s_etat_process
   
             (*bibliotheque_candidate) = d_code_fin_chaine;              (*bibliotheque_candidate) = d_code_fin_chaine;
             strncat(bibliotheque_candidate,              strncat(bibliotheque_candidate,
                     (*s_etat_processus).instruction_courante,                      (*s_etat_processus).instruction_courante, ((size_t)
                     position - (*s_etat_processus).instruction_courante);                      (position - (*s_etat_processus).instruction_courante)));
   
             position++;              position++;
   
Line 1139  analyse(struct_processus *s_etat_process Line 1161  analyse(struct_processus *s_etat_process
     {      {
         if ((*s_etat_processus).test_instruction == 'N')          if ((*s_etat_processus).test_instruction == 'N')
         {          {
             if ((*s_etat_processus).nombre_interruptions_non_affectees != 0)              if (pthread_mutex_lock(&(*s_etat_processus).mutex_interruptions)
                       != 0)
               {
                   (*s_etat_processus).erreur_systeme = d_es_processus;
               }
               else
             {              {
                 affectation_interruptions_logicielles(s_etat_processus);                  if ((*s_etat_processus).nombre_interruptions_non_affectees != 0)
                   {
                       affectation_interruptions_logicielles(s_etat_processus);
                   }
   
                   if (pthread_mutex_unlock(&(*s_etat_processus)
                           .mutex_interruptions) != 0)
                   {
                       (*s_etat_processus).erreur_systeme = d_es_processus;
                   }
             }              }
   
             if (((*s_etat_processus).nombre_interruptions_en_queue != 0) &&              if (((*s_etat_processus).nombre_interruptions_en_queue != 0) &&
Line 1174  analyse(struct_processus *s_etat_process Line 1210  analyse(struct_processus *s_etat_process
   
         gettimeofday(&horodatage_final, NULL);          gettimeofday(&horodatage_final, NULL);
   
         if (initialisation == d_vrai)          if ((*s_etat_processus).initialisation_scheduler == d_vrai)
         {          {
             temps_reel = ((real8) (horodatage_final.tv_sec -              temps_reel = ((real8) (horodatage_final.tv_sec -
                     horodatage_initial.tv_sec)) +                      horodatage_initial.tv_sec)) +
Line 1212  analyse(struct_processus *s_etat_process Line 1248  analyse(struct_processus *s_etat_process
                             (*s_etat_processus).pourcentage_maximal_cpu)                              (*s_etat_processus).pourcentage_maximal_cpu)
                             - (pourcentage * temps_cpu / 100);                              - (pourcentage * temps_cpu / 100);
   
                     temporisation.tv_sec = floor(attente);                      temporisation.tv_sec = (time_t) floor(attente);
                     temporisation.tv_nsec = (attente - temporisation.tv_sec) *                      temporisation.tv_nsec = (suseconds_t) ((attente
                             1E9;                              - ((real8) temporisation.tv_sec)) * 1E9);
   
                     while(nanosleep(&temporisation, &temporisation) == -1)                      while(nanosleep(&temporisation, &temporisation) == -1)
                     {                      {
Line 1231  analyse(struct_processus *s_etat_process Line 1267  analyse(struct_processus *s_etat_process
         }          }
         else          else
         {          {
             initialisation = d_vrai;              (*s_etat_processus).initialisation_scheduler = d_vrai;
   
             horodatage_initial = horodatage_final;              horodatage_initial = horodatage_final;
             usage_initial = usage_final;              usage_initial = usage_final;
Line 1239  analyse(struct_processus *s_etat_process Line 1275  analyse(struct_processus *s_etat_process
     }      }
     else      else
     {      {
         initialisation = d_faux;          (*s_etat_processus).initialisation_scheduler = d_faux;
     }      }
   
 /*  /*

Removed from v.1.72  
changed lines
  Added in v.1.92


CVSweb interface <joel.bertrand@systella.fr>