File:  [local] / rpl / src / instructions_s9.c
Revision 1.14: download - view: text, annotated - select for diffs - revision graph
Sat Jul 24 16:39:44 2010 UTC (13 years, 9 months ago) by bertrand
Branches: MAIN
CVS tags: HEAD
Correction d'un dysfonctionnement bizarre dans SORT (argument TBL).
Je n'ai aucune explication valable sur la résolution du problème. Peut-être un
bug de gcc avec l'option -O3. À surveiller.

Problème : dans certains cas, SORT n'arrive par à trier une table et
les entiers 'nombre_occurrences' prennent des valeurs étranges. Le même tableau
traité directement est trié sans aucun problème !

    1: /*
    2: ================================================================================
    3:   RPL/2 (R) version 4.0.18
    4:   Copyright (C) 1989-2010 Dr. BERTRAND Joël
    5: 
    6:   This file is part of RPL/2.
    7: 
    8:   RPL/2 is free software; you can redistribute it and/or modify it
    9:   under the terms of the CeCILL V2 License as published by the french
   10:   CEA, CNRS and INRIA.
   11:  
   12:   RPL/2 is distributed in the hope that it will be useful, but WITHOUT
   13:   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   14:   FITNESS FOR A PARTICULAR PURPOSE.  See the CeCILL V2 License
   15:   for more details.
   16:  
   17:   You should have received a copy of the CeCILL License
   18:   along with RPL/2. If not, write to info@cecill.info.
   19: ================================================================================
   20: */
   21: 
   22: 
   23: #include "rpl.conv.h"
   24: 
   25: 
   26: /*
   27: ================================================================================
   28:   Fonction 'sort'
   29: ================================================================================
   30:   Entrées :
   31: --------------------------------------------------------------------------------
   32:   Sorties :
   33: --------------------------------------------------------------------------------
   34:   Effets de bord : néant
   35: ================================================================================
   36: */
   37: 
   38: void
   39: instruction_sort(struct_processus *s_etat_processus)
   40: {
   41:     integer8                    i;
   42:     integer8                    j;
   43:     integer8                    nombre_elements;
   44: 
   45:     logical1                    condition;
   46:     logical1                    inversion;
   47:     logical1                    presence_nom;
   48:     logical1                    terminaison_boucle_1;
   49:     logical1                    terminaison_boucle_2;
   50:     logical1                    terminaison_boucle_3;
   51:     logical1                    variable_partagee;
   52: 
   53:     struct_liste_chainee        *l_element_courant;
   54:     struct_liste_chainee        *l_element_precedent;
   55:     struct_liste_chainee        *l_element_tampon;
   56: 
   57:     struct_objet                *s_objet_copie;
   58:     struct_objet                *s_objet_critere;
   59:     struct_objet                *s_objet_liste;
   60:     struct_objet                *s_objet_test;
   61: 
   62:     signed long                 indice_i;
   63:     signed long                 indice_j;
   64:     signed long                 indice_k;
   65:     signed long                 indice_l;
   66: 
   67:     unsigned long               ecartement;
   68: 
   69:     (*s_etat_processus).erreur_execution = d_ex;
   70: 
   71:     if ((*s_etat_processus).affichage_arguments == 'Y')
   72:     {
   73:         printf("\n  SORT ");
   74: 
   75:         if ((*s_etat_processus).langue == 'F')
   76:         {
   77:             printf("(trie une liste selon un critère paramétrable)\n\n");
   78:         }
   79:         else
   80:         {
   81:             printf("(sort a list)\n\n");
   82:         }
   83: 
   84:         printf("    2: %s\n", d_LST);
   85:         printf("    1: %s\n", d_RPN);
   86:         printf("->  1: %s\n\n", d_LST);
   87: 
   88:         printf("    2: %s\n", d_TAB);
   89:         printf("    1: %s\n", d_RPN);
   90:         printf("->  1: %s\n\n", d_LST);
   91: 
   92:         printf("    2: %s\n", d_NOM);
   93:         printf("    1: %s\n", d_RPN);
   94: 
   95:         return;
   96:     }
   97:     else if ((*s_etat_processus).test_instruction == 'Y')
   98:     {
   99:         (*s_etat_processus).nombre_arguments = -1;
  100:         return;
  101:     }
  102:     
  103:     if (test_cfsf(s_etat_processus, 31) == d_vrai)
  104:     {
  105:         if (empilement_pile_last(s_etat_processus, 2) == d_erreur)
  106:         {
  107:             return;
  108:         }
  109:     }
  110: 
  111:     if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
  112:             &s_objet_critere) == d_erreur)
  113:     {
  114:         (*s_etat_processus).erreur_execution = d_ex_manque_argument;
  115:         return;
  116:     }
  117: 
  118:     if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
  119:             &s_objet_liste) == d_erreur)
  120:     {
  121:         liberation(s_etat_processus, s_objet_critere);
  122: 
  123:         (*s_etat_processus).erreur_execution = d_ex_manque_argument;
  124:         return;
  125:     }
  126: 
  127:     variable_partagee = d_faux;
  128: 
  129:     if ((*s_objet_liste).type == NOM)
  130:     {
  131:         if (recherche_variable(s_etat_processus, (*((struct_nom *)
  132:                 (*s_objet_liste).objet)).nom) == d_faux)
  133:         {
  134:             (*s_etat_processus).erreur_systeme = d_es;
  135:             (*s_etat_processus).erreur_execution = d_ex_variable_non_definie;
  136: 
  137:             liberation(s_etat_processus, s_objet_critere);
  138:             liberation(s_etat_processus, s_objet_liste);
  139: 
  140:             return;
  141:         }
  142: 
  143:         if ((*s_etat_processus).s_liste_variables[(*s_etat_processus)
  144:                 .position_variable_courante].variable_verrouillee == d_vrai)
  145:         {
  146:             (*s_etat_processus).erreur_execution = d_ex_variable_verrouillee;
  147: 
  148:             liberation(s_etat_processus, s_objet_critere);
  149:             liberation(s_etat_processus, s_objet_liste);
  150: 
  151:             return;
  152:         }
  153: 
  154:         if ((*s_etat_processus).s_liste_variables[(*s_etat_processus)
  155:                 .position_variable_courante].objet == NULL)
  156:         {
  157:             if (pthread_mutex_lock(&((*(*s_etat_processus)
  158:                     .s_liste_variables_partagees).mutex)) != 0)
  159:             {
  160:                 (*s_etat_processus).erreur_systeme = d_es_processus;
  161:                 return;
  162:             }
  163: 
  164:             if (recherche_variable_partagee(s_etat_processus,
  165:                     (*s_etat_processus).s_liste_variables
  166:                     [(*s_etat_processus).position_variable_courante].nom,
  167:                     (*s_etat_processus).s_liste_variables
  168:                     [(*s_etat_processus).position_variable_courante]
  169:                     .variable_partagee, (*s_etat_processus).s_liste_variables
  170:                     [(*s_etat_processus).position_variable_courante].origine)
  171:                     == d_faux)
  172:             {
  173:                 if (pthread_mutex_unlock(&((*(*s_etat_processus)
  174:                         .s_liste_variables_partagees).mutex)) != 0)
  175:                 {
  176:                     (*s_etat_processus).erreur_systeme = d_es_processus;
  177:                     return;
  178:                 }
  179: 
  180:                 (*s_etat_processus).erreur_execution =
  181:                         d_ex_erreur_type_argument;
  182: 
  183:                 liberation(s_etat_processus, s_objet_critere);
  184:                 liberation(s_etat_processus, s_objet_liste);
  185: 
  186:                 return;
  187:             }
  188: 
  189:             if (((*(*(*s_etat_processus).s_liste_variables_partagees)
  190:                     .table[(*(*s_etat_processus).s_liste_variables_partagees)
  191:                     .position_variable].objet).type != LST) &&
  192:                     ((*(*(*s_etat_processus).s_liste_variables_partagees)
  193:                     .table[(*(*s_etat_processus).s_liste_variables_partagees)
  194:                     .position_variable].objet).type != TBL))
  195:             {
  196:                 if (pthread_mutex_unlock(&((*(*s_etat_processus)
  197:                         .s_liste_variables_partagees).mutex)) != 0)
  198:                 {
  199:                     (*s_etat_processus).erreur_systeme = d_es_processus;
  200:                     return;
  201:                 }
  202: 
  203:                 (*s_etat_processus).erreur_execution =
  204:                         d_ex_erreur_type_argument;
  205: 
  206:                 liberation(s_etat_processus, s_objet_critere);
  207:                 liberation(s_etat_processus, s_objet_liste);
  208: 
  209:                 return;
  210:             }
  211: 
  212:             liberation(s_etat_processus, s_objet_liste);
  213: 
  214:             s_objet_liste = (*(*s_etat_processus).s_liste_variables_partagees)
  215:                     .table[(*(*s_etat_processus).s_liste_variables_partagees)
  216:                     .position_variable].objet;
  217: 
  218:             if ((s_objet_copie = copie_objet(s_etat_processus, s_objet_liste,
  219:                     'N')) == NULL)
  220:             {
  221:                 if (pthread_mutex_unlock(&((*(*s_etat_processus)
  222:                         .s_liste_variables_partagees).mutex)) != 0)
  223:                 {
  224:                     (*s_etat_processus).erreur_systeme = d_es_processus;
  225:                     return;
  226:                 }
  227: 
  228:                 (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
  229:                 return;
  230:             }
  231: 
  232:             variable_partagee = d_vrai;
  233:         }
  234:         else
  235:         {
  236:             if (((*(*s_etat_processus).s_liste_variables
  237:                     [(*s_etat_processus).position_variable_courante].objet)
  238:                     .type != LST) &&
  239:                     ((*(*s_etat_processus).s_liste_variables
  240:                     [(*s_etat_processus).position_variable_courante].objet)
  241:                     .type != TBL))
  242:             {
  243:                 (*s_etat_processus).erreur_execution =
  244:                         d_ex_erreur_type_argument;
  245: 
  246:                 liberation(s_etat_processus, s_objet_critere);
  247:                 liberation(s_etat_processus, s_objet_liste);
  248: 
  249:                 return;
  250:             }
  251: 
  252:             liberation(s_etat_processus, s_objet_liste);
  253: 
  254:             s_objet_liste = (*s_etat_processus).s_liste_variables
  255:                     [(*s_etat_processus).position_variable_courante].objet;
  256: 
  257:             if ((s_objet_copie = copie_objet(s_etat_processus, s_objet_liste,
  258:                     'N')) == NULL)
  259:             {
  260:                 (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
  261:                 return;
  262:             }
  263:         }
  264: 
  265:         liberation(s_etat_processus, s_objet_liste);
  266:         s_objet_liste = s_objet_copie;
  267: 
  268:         (*s_etat_processus).s_liste_variables[(*s_etat_processus)
  269:                 .position_variable_courante].objet = s_objet_liste;
  270: 
  271:         presence_nom = d_vrai;
  272:     }
  273:     else
  274:     {
  275:         if ((s_objet_copie = copie_objet(s_etat_processus, s_objet_liste, 'N'))
  276:                 == NULL)
  277:         {
  278:             (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
  279:             return;
  280:         }
  281: 
  282:         liberation(s_etat_processus, s_objet_liste);
  283:         s_objet_liste = s_objet_copie;
  284:         presence_nom = d_faux;
  285:     }
  286: 
  287:     if (((*s_objet_liste).type == LST) &&
  288:             ((*s_objet_critere).type == RPN))
  289:     {
  290:         /*
  291:          * Tri bulle de la liste chaînée. On se contente d'un tri bulle
  292:          * car on travaille sur une liste chaînée et non sur un tableau
  293:          * sur lequel on pourrait accéder directement aux données grâce à
  294:          * leur indice.
  295:          */
  296: 
  297:         nombre_elements = 0;
  298:         l_element_courant = (*s_objet_liste).objet;
  299: 
  300:         while(l_element_courant != NULL)
  301:         {
  302:             l_element_courant = (*l_element_courant).suivant;
  303:             nombre_elements++;
  304:         }
  305: 
  306:         // Si la liste est vide, on considère qu'elle est triée.
  307:         // De la même manière, on considère qu'une liste d'un
  308:         // seul élément est toujours triée.
  309: 
  310:         if (nombre_elements > 1)
  311:         {
  312:             j = nombre_elements;
  313: 
  314:             do
  315:             {
  316:                 inversion = d_faux;
  317: 
  318:                 l_element_courant = (*s_objet_liste).objet;
  319:                 l_element_precedent = NULL;
  320: 
  321:                 for(i = 0; i < j - 1; i++)
  322:                 {
  323:                     // Test des éléments adjacents. Pour cela, on
  324:                     // empile les deux éléments adjacents dans la pile dans
  325:                     // l'ordre [i] [i+1] et on évalue le critère d'ordre.
  326: 
  327:                     if ((s_objet_copie = copie_objet(s_etat_processus,
  328:                             (*l_element_courant).donnee, 'P')) == NULL)
  329:                     {
  330:                         (*s_etat_processus).erreur_systeme =
  331:                                 d_es_allocation_memoire;
  332:                         return;
  333:                     }
  334: 
  335:                     if (empilement(s_etat_processus,
  336:                             &((*s_etat_processus).l_base_pile),
  337:                             s_objet_copie) == d_erreur)
  338:                     {
  339:                         return;
  340:                     }
  341: 
  342:                     if ((s_objet_copie = copie_objet(s_etat_processus,
  343:                             (*(*l_element_courant)
  344:                             .suivant).donnee, 'P')) == NULL)
  345:                     {
  346:                         (*s_etat_processus).erreur_systeme =
  347:                                 d_es_allocation_memoire;
  348:                         return;
  349:                     }
  350: 
  351:                     if (empilement(s_etat_processus,
  352:                             &((*s_etat_processus).l_base_pile),
  353:                             s_objet_copie) == d_erreur)
  354:                     {
  355:                         return;
  356:                     }
  357: 
  358:                     if (evaluation(s_etat_processus, s_objet_critere, 'N')
  359:                             == d_erreur)
  360:                     {
  361:                         liberation(s_etat_processus, s_objet_critere);
  362:                         liberation(s_etat_processus, s_objet_liste);
  363: 
  364:                         return;
  365:                     }
  366: 
  367:                     if (depilement(s_etat_processus,
  368:                             &((*s_etat_processus).l_base_pile), &s_objet_test)
  369:                             == d_erreur)
  370:                     {
  371:                         liberation(s_etat_processus, s_objet_critere);
  372:                         liberation(s_etat_processus, s_objet_liste);
  373: 
  374:                         (*s_etat_processus).erreur_execution =
  375:                                 d_ex_manque_argument;
  376:                         return;
  377:                     }
  378: 
  379:                     if ((*s_objet_test).type == INT)
  380:                     {
  381:                         condition = ((*((integer8 *) (*s_objet_test).objet))
  382:                                 == 0) ? d_faux : d_vrai;
  383:                     }
  384:                     else if ((*s_objet_test).type == REL)
  385:                     {
  386:                         condition = ((*((real8 *) (*s_objet_test).objet))
  387:                                 == 0) ? d_faux : d_vrai;
  388:                     }
  389:                     else
  390:                     {
  391:                         liberation(s_etat_processus, s_objet_critere);
  392:                         liberation(s_etat_processus, s_objet_liste);
  393:                         liberation(s_etat_processus, s_objet_test);
  394: 
  395:                         (*s_etat_processus).erreur_execution =
  396:                                 d_ex_erreur_type_argument;
  397:                         return;
  398:                     }
  399: 
  400:                     liberation(s_etat_processus, s_objet_test);
  401: 
  402:                     if (condition == d_faux)
  403:                     {
  404:                         // On échange les deux éléments adjacents
  405: 
  406:                         inversion = d_vrai;
  407: 
  408:                         if (l_element_precedent == NULL)
  409:                         {
  410:                             // Échange des deux premiers éléments
  411:                             // de la liste.
  412: 
  413:                             l_element_tampon = (*(*l_element_courant)
  414:                                     .suivant).suivant;
  415:                             (*s_objet_liste).objet = (*l_element_courant)
  416:                                     .suivant;
  417:                             (*((struct_liste_chainee *) (*s_objet_liste)
  418:                                     .objet)).suivant = l_element_courant;
  419:                             (*l_element_courant).suivant =
  420:                                     l_element_tampon;
  421:                             l_element_courant = (*s_objet_liste).objet;
  422:                         }
  423:                         else
  424:                         {
  425:                             // Échange de deux éléments quelconques de la
  426:                             // liste.
  427: 
  428:                             l_element_tampon = (*l_element_courant).suivant;
  429:                             (*l_element_courant).suivant =
  430:                                     (*(*l_element_courant).suivant).suivant;
  431:                             (*l_element_precedent).suivant = l_element_tampon;
  432:                             (*l_element_tampon).suivant = l_element_courant;
  433: 
  434:                             l_element_courant = l_element_tampon;
  435:                         }
  436:                     }
  437: 
  438:                     l_element_precedent = l_element_courant;
  439:                     l_element_courant = (*l_element_courant).suivant;
  440:                 }
  441: 
  442:                 j--;
  443:             } while(inversion != d_faux);
  444:         }
  445:     }
  446:     else if (((*s_objet_liste).type == TBL) &&
  447:             ((*s_objet_critere).type == RPN))
  448:     {
  449:         /*
  450:          * Tri Shell-Metzner d'une table
  451:          */
  452: 
  453:         ecartement = (*((struct_tableau *) (*s_objet_liste).objet))
  454:                 .nombre_elements;
  455:         terminaison_boucle_1 = d_faux;
  456: 
  457:         do
  458:         {
  459:             ecartement = ecartement / 2;
  460: 
  461:             if (ecartement >= 1)
  462:             {
  463:                 indice_j = 0;
  464:                 indice_k = (*((struct_tableau *) (*s_objet_liste).objet))
  465:                         .nombre_elements - ecartement;
  466:                 terminaison_boucle_2 = d_faux;
  467: 
  468:                 do
  469:                 {
  470:                     indice_i = indice_j;
  471:                     terminaison_boucle_3 = d_faux;
  472: 
  473:                     do
  474:                     {
  475:                         indice_l = indice_i + ecartement;
  476: 
  477:                         if ((indice_i > 0) && (indice_l > 0))
  478:                         {
  479:                             if ((s_objet_copie = copie_objet(s_etat_processus,
  480:                                     (*((struct_tableau *) (*s_objet_liste)
  481:                                     .objet)).elements[indice_i - 1], 'P'))
  482:                                     == NULL)
  483:                             {
  484:                                 (*s_etat_processus).erreur_systeme =
  485:                                         d_es_allocation_memoire;
  486:                                 return;
  487:                             }
  488: 
  489:                             if (empilement(s_etat_processus,
  490:                                     &((*s_etat_processus).l_base_pile),
  491:                                     s_objet_copie) == d_erreur)
  492:                             {
  493:                                 return;
  494:                             }
  495: 
  496:                             if ((s_objet_copie = copie_objet(s_etat_processus,
  497:                                     (*((struct_tableau *) (*s_objet_liste)
  498:                                     .objet)).elements[indice_l - 1], 'P'))
  499:                                     == NULL)
  500:                             {
  501:                                 (*s_etat_processus).erreur_systeme =
  502:                                         d_es_allocation_memoire;
  503:                                 return;
  504:                             }
  505: 
  506:                             if (empilement(s_etat_processus,
  507:                                     &((*s_etat_processus).l_base_pile),
  508:                                     s_objet_copie) == d_erreur)
  509:                             {
  510:                                 return;
  511:                             }
  512: 
  513:                             if (evaluation(s_etat_processus, s_objet_critere,
  514:                                     'N') == d_erreur)
  515:                             {
  516:                                 liberation(s_etat_processus, s_objet_critere);
  517:                                 liberation(s_etat_processus, s_objet_liste);
  518: 
  519:                                 return;
  520:                             }
  521: 
  522:                             if (depilement(s_etat_processus,
  523:                                     &((*s_etat_processus).l_base_pile),
  524:                                     &s_objet_test) == d_erreur)
  525:                             {
  526:                                 liberation(s_etat_processus, s_objet_critere);
  527:                                 liberation(s_etat_processus, s_objet_liste);
  528: 
  529:                                 (*s_etat_processus).erreur_execution =
  530:                                         d_ex_manque_argument;
  531:                                 return;
  532:                             }
  533: 
  534:                             if ((*s_objet_test).type == INT)
  535:                             {
  536:                                 condition = ((*((integer8 *) (*s_objet_test)
  537:                                         .objet)) == 0) ? d_faux : d_vrai;
  538:                             }
  539:                             else if ((*s_objet_test).type == REL)
  540:                             {
  541:                                 condition = ((*((real8 *) (*s_objet_test)
  542:                                         .objet)) == 0) ? d_faux : d_vrai;
  543:                             }
  544:                             else
  545:                             {
  546:                                 liberation(s_etat_processus, s_objet_critere);
  547:                                 liberation(s_etat_processus, s_objet_liste);
  548:                                 liberation(s_etat_processus, s_objet_test);
  549: 
  550:                                 (*s_etat_processus).erreur_execution =
  551:                                         d_ex_erreur_type_argument;
  552:                                 return;
  553:                             }
  554: 
  555:                             liberation(s_etat_processus, s_objet_test);
  556: 
  557:                             if (condition == d_faux)
  558:                             {
  559:                                 swap(&((*((struct_tableau *)
  560:                                         (*s_objet_liste).objet)).elements
  561:                                         [indice_i - 1]),
  562:                                         &((*((struct_tableau *) (*s_objet_liste)
  563:                                         .objet)).elements[indice_l - 1]),
  564:                                         sizeof(struct_objet *));
  565: 
  566:                                 indice_i -= ecartement;
  567: 
  568:                                 if (indice_i < 1)
  569:                                 {
  570:                                     terminaison_boucle_3 = d_vrai;
  571:                                 }
  572:                             }
  573:                             else
  574:                             {
  575:                                 terminaison_boucle_3 = d_vrai;
  576:                             }
  577:                         }
  578:                         else
  579:                         {
  580:                             terminaison_boucle_3 = d_vrai;
  581:                         }
  582:                     } while(terminaison_boucle_3 == d_faux);
  583: 
  584:                     indice_j++;
  585: 
  586:                     if (indice_j > indice_k)
  587:                     {
  588:                         terminaison_boucle_2 = d_vrai;
  589:                     }
  590:                 } while(terminaison_boucle_2 == d_faux);
  591:             }
  592:             else
  593:             {
  594:                 terminaison_boucle_1 = d_vrai;
  595:             }
  596:         } while(terminaison_boucle_1 == d_faux);
  597:     }
  598:     else
  599:     {
  600:         if (pthread_mutex_unlock(&((*(*s_etat_processus)
  601:                 .s_liste_variables_partagees).mutex)) != 0)
  602:         {
  603:             (*s_etat_processus).erreur_systeme = d_es_processus;
  604:             return;
  605:         }
  606: 
  607:         liberation(s_etat_processus, s_objet_liste);
  608:         liberation(s_etat_processus, s_objet_critere);
  609: 
  610:         (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
  611:         return;
  612:     }
  613: 
  614:     if (presence_nom == d_faux)
  615:     {
  616:         if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
  617:                 s_objet_liste) == d_erreur)
  618:         {
  619:             return;
  620:         }
  621:     }
  622:     else
  623:     {
  624:         if (variable_partagee == d_vrai)
  625:         {
  626:             (*(*s_etat_processus).s_liste_variables_partagees)
  627:                     .table[(*(*s_etat_processus).s_liste_variables_partagees)
  628:                     .position_variable].objet = s_objet_liste;
  629: 
  630:             if (pthread_mutex_unlock(&((*(*s_etat_processus)
  631:                     .s_liste_variables_partagees).mutex)) != 0)
  632:             {
  633:                 (*s_etat_processus).erreur_systeme = d_es_processus;
  634:                 return;
  635:             }
  636:         }
  637:     }
  638: 
  639:     liberation(s_etat_processus, s_objet_critere);
  640: 
  641:     return;
  642: }
  643: 
  644: 
  645: /*
  646: ================================================================================
  647:   Fonction 'save'
  648: ================================================================================
  649:   Entrées : structure processus
  650: --------------------------------------------------------------------------------
  651:   Sorties :
  652: --------------------------------------------------------------------------------
  653:   Effets de bord : néant
  654: ================================================================================
  655: */
  656: 
  657: void
  658: instruction_save(struct_processus *s_etat_processus)
  659: {
  660:     logical1                            presence_variable;
  661: 
  662:     long                                i;
  663: 
  664:     struct_objet                        *s_objet_1;
  665:     struct_objet                        *s_objet_2;
  666: 
  667:     struct_variable                     s_variable;
  668: 
  669:     (*s_etat_processus).erreur_execution = d_ex;
  670: 
  671:     if ((*s_etat_processus).affichage_arguments == 'Y')
  672:     {
  673:         printf("\n  SAVE ");
  674: 
  675:         if ((*s_etat_processus).langue == 'F')
  676:         {
  677:             printf("(affecte un objet à une variable globale)\n\n");
  678:         }
  679:         else
  680:         {
  681:             printf("(store an object in a global variable)\n\n");
  682:         }
  683: 
  684:         printf("    2: %s, %s, %s, %s, %s, %s,\n"
  685:                 "       %s, %s, %s, %s, %s,\n"
  686:                 "       %s, %s, %s, %s, %s,\n"
  687:                 "       %s, %s, %s, %s,\n"
  688:                 "       %s, %s\n",
  689:                 d_INT, d_REL, d_CPL, d_VIN, d_VRL, d_VCX, d_MIN, d_MRL, d_MCX,
  690:                 d_TAB, d_BIN, d_NOM, d_CHN, d_LST, d_ALG, d_RPN, d_FCH, d_SCK,
  691:                 d_SQL, d_SLB, d_PRC, d_MTX);
  692:         printf("    1: %s\n", d_NOM);
  693: 
  694:         return;
  695:     }
  696:     else if ((*s_etat_processus).test_instruction == 'Y')
  697:     {
  698:         (*s_etat_processus).nombre_arguments = -1;
  699:         return;
  700:     }
  701:     
  702:     if (test_cfsf(s_etat_processus, 31) == d_vrai)
  703:     {
  704:         if (empilement_pile_last(s_etat_processus, 2) == d_erreur)
  705:         {
  706:             return;
  707:         }
  708:     }
  709: 
  710:     if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
  711:             &s_objet_1) == d_erreur)
  712:     {
  713:         (*s_etat_processus).erreur_execution = d_ex_manque_argument;
  714:         return;
  715:     }
  716: 
  717:     if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
  718:             &s_objet_2) == d_erreur)
  719:     {
  720:         liberation(s_etat_processus, s_objet_1);
  721: 
  722:         (*s_etat_processus).erreur_execution = d_ex_manque_argument;
  723:         return;
  724:     }
  725: 
  726:     if ((*s_objet_1).type != NOM)
  727:     {
  728:         liberation(s_etat_processus, s_objet_1);
  729:         liberation(s_etat_processus, s_objet_2);
  730: 
  731:         (*s_etat_processus).erreur_execution = d_ex_nom_invalide;
  732:         return;
  733:     }
  734: 
  735:     if (recherche_variable(s_etat_processus, (*((struct_nom *)
  736:             (*s_objet_1).objet)).nom) == d_vrai)
  737:     {
  738:         /*
  739:          * Une variable est accessible directement.
  740:          */
  741: 
  742:         if ((*s_etat_processus).s_liste_variables[(*s_etat_processus)
  743:                 .position_variable_courante].niveau == 1)
  744:         {
  745:             // La variable accessible directement est une variable globale.
  746: 
  747:             if ((*s_etat_processus).s_liste_variables[(*s_etat_processus)
  748:                     .position_variable_courante].variable_verrouillee == d_vrai)
  749:             {
  750:                 liberation(s_etat_processus, s_objet_1);
  751:                 liberation(s_etat_processus, s_objet_2);
  752: 
  753:                 (*s_etat_processus).erreur_execution =
  754:                         d_ex_variable_verrouillee;
  755:                 return;
  756:             }
  757: 
  758:             if ((*s_etat_processus).s_liste_variables[(*s_etat_processus)
  759:                     .position_variable_courante].objet == NULL)
  760:             {
  761:                 liberation(s_etat_processus, s_objet_1);
  762:                 liberation(s_etat_processus, s_objet_2);
  763: 
  764:                 (*s_etat_processus).erreur_execution = d_ex_variable_partagee;
  765:                 return;
  766:             }
  767: 
  768:             liberation(s_etat_processus,
  769:                     (*s_etat_processus).s_liste_variables[(*s_etat_processus)
  770:                     .position_variable_courante].objet);
  771: 
  772:             (*s_etat_processus).s_liste_variables[(*s_etat_processus)
  773:                     .position_variable_courante].objet = s_objet_2;
  774:         }
  775:         else
  776:         {
  777:             // On cherche une variable globale de même nom.
  778: 
  779:             i = (*s_etat_processus).position_variable_courante;
  780:             presence_variable = d_faux;
  781: 
  782:             while(i >= 0)
  783:             {
  784:                 if ((strcmp((*s_etat_processus).s_liste_variables[i].nom,
  785:                         (*((struct_nom *) (*s_objet_1).objet)).nom) == 0) &&
  786:                         ((*s_etat_processus).s_liste_variables[i].niveau == 1))
  787:                 {
  788:                     presence_variable = d_vrai;
  789:                     break;
  790:                 }
  791: 
  792:                 i--;
  793:             }
  794: 
  795:             (*s_etat_processus).position_variable_courante = i;
  796: 
  797:             if ((*s_etat_processus).s_liste_variables[(*s_etat_processus)
  798:                     .position_variable_courante].niveau == 1)
  799:             {
  800:                 // On a trouvé une variable globale correspondant au nom et
  801:                 // que l'on modifie.
  802: 
  803:                 if ((*s_etat_processus).s_liste_variables[(*s_etat_processus)
  804:                         .position_variable_courante].variable_verrouillee ==
  805:                         d_vrai)
  806:                 {
  807:                     liberation(s_etat_processus, s_objet_1);
  808:                     liberation(s_etat_processus, s_objet_2);
  809: 
  810:                     (*s_etat_processus).erreur_execution =
  811:                             d_ex_variable_verrouillee;
  812:                     return;
  813:                 }
  814: 
  815:                 if ((*s_etat_processus).s_liste_variables[(*s_etat_processus)
  816:                         .position_variable_courante].objet == NULL)
  817:                 {
  818:                     liberation(s_etat_processus, s_objet_1);
  819:                     liberation(s_etat_processus, s_objet_2);
  820: 
  821:                     (*s_etat_processus).erreur_execution =
  822:                             d_ex_variable_partagee;
  823:                     return;
  824:                 }
  825: 
  826:                 liberation(s_etat_processus,
  827:                         (*s_etat_processus).s_liste_variables
  828:                         [(*s_etat_processus).position_variable_courante].objet);
  829: 
  830:                 (*s_etat_processus).s_liste_variables[(*s_etat_processus)
  831:                         .position_variable_courante].objet = s_objet_2;
  832:             }
  833:             else
  834:             {
  835:                 if ((s_variable.nom = malloc((strlen((*((struct_nom *)
  836:                         (*s_objet_1).objet)).nom) + 1) * sizeof(unsigned char)))
  837:                         == NULL)
  838:                 {
  839:                     (*s_etat_processus).erreur_systeme =
  840:                             d_es_allocation_memoire;
  841:                     return;
  842:                 }
  843: 
  844:                 strcpy(s_variable.nom, (*((struct_nom *)
  845:                         (*s_objet_1).objet)).nom);
  846:                 s_variable.niveau = 1;
  847: 
  848:                 /*
  849:                  * Le niveau 0 correspond aux définitions. Les variables
  850:                  * commencent à 1 car elles sont toujours incluses dans
  851:                  * une définition.
  852:                  */
  853: 
  854:                 s_variable.objet = s_objet_2;
  855: 
  856:                 if (creation_variable(s_etat_processus, &s_variable, 'V', 'P')
  857:                         == d_erreur)
  858:                 {
  859:                     return;
  860:                 }
  861:             }
  862:         }
  863:     }
  864:     else
  865:     {
  866:         /*
  867:          * Aucune variable n'est accessible (ni locale, ni globale).
  868:          */
  869: 
  870:         if ((s_variable.nom = malloc((strlen((*((struct_nom *)
  871:                 (*s_objet_1).objet)).nom) + 1) * sizeof(unsigned char)))
  872:                 == NULL)
  873:         {
  874:             (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
  875:             return;
  876:         }
  877: 
  878:         strcpy(s_variable.nom, (*((struct_nom *) (*s_objet_1).objet)).nom);
  879:         s_variable.niveau = 1;
  880: 
  881:         /*
  882:          * Le niveau 0 correspond aux définitions. Les variables
  883:          * commencent à 1 car elles sont toujours incluses dans
  884:          * une définition.
  885:          */
  886: 
  887:         s_variable.objet = s_objet_2;
  888: 
  889:         if (creation_variable(s_etat_processus, &s_variable, 'V', 'P')
  890:                 == d_erreur)
  891:         {
  892:             return;
  893:         }
  894: 
  895:         (*s_etat_processus).erreur_systeme = d_es;
  896:     }
  897: 
  898:     liberation(s_etat_processus, s_objet_1);
  899: 
  900:     return;
  901: }
  902: 
  903: 
  904: /*
  905: ================================================================================
  906:   Fonction 'suspend'
  907: ================================================================================
  908:   Entrées : structure processus
  909: --------------------------------------------------------------------------------
  910:   Sorties :
  911: --------------------------------------------------------------------------------
  912:   Effets de bord : néant
  913: ================================================================================
  914: */
  915: 
  916: void
  917: instruction_suspend(struct_processus *s_etat_processus)
  918: {
  919:     sigset_t            masque;
  920: 
  921:     (*s_etat_processus).erreur_execution = d_ex;
  922: 
  923:     if ((*s_etat_processus).affichage_arguments == 'Y')
  924:     {
  925:         printf("\n  SUSPEND ");
  926: 
  927:         if ((*s_etat_processus).langue == 'F')
  928:         {
  929:             printf("(attend un signal SIGCONT)\n\n");
  930:             printf("  Aucun argument\n");
  931:         }
  932:         else
  933:         {
  934:             printf("(wait for SIGCONT signal)\n\n");
  935:             printf("  No argument\n");
  936:         }
  937: 
  938:         return;
  939:     }
  940:     else if ((*s_etat_processus).test_instruction == 'Y')
  941:     {
  942:         (*s_etat_processus).nombre_arguments = -1;
  943:         return;
  944:     }
  945: 
  946:     if (test_cfsf(s_etat_processus, 31) == d_vrai)
  947:     {
  948:         if (empilement_pile_last(s_etat_processus, 0) == d_erreur)
  949:         {
  950:             return;
  951:         }
  952:     }
  953: 
  954:     if (sigfillset(&masque) != 0)
  955:     {
  956:         (*s_etat_processus).erreur_systeme = d_es_processus;
  957:         return;
  958:     }
  959: 
  960:     if (sigdelset(&masque, SIGCONT) != 0)
  961:     {
  962:         (*s_etat_processus).erreur_systeme = d_es_processus;
  963:         return;
  964:     }
  965: 
  966:     if (sigdelset(&masque, SIGFSTOP) != 0)
  967:     {
  968:         (*s_etat_processus).erreur_systeme = d_es_processus;
  969:         return;
  970:     }
  971: 
  972:     if (sigdelset(&masque, SIGFABORT) != 0)
  973:     {
  974:         (*s_etat_processus).erreur_systeme = d_es_processus;
  975:         return;
  976:     }
  977: 
  978:     if (sigdelset(&masque, SIGURG) != 0)
  979:     {
  980:         (*s_etat_processus).erreur_systeme = d_es_processus;
  981:         return;
  982:     }
  983: 
  984:     if (sigdelset(&masque, SIGALRM) != 0)
  985:     {
  986:         (*s_etat_processus).erreur_systeme = d_es_processus;
  987:         return;
  988:     }
  989: 
  990:     if ((*s_etat_processus).profilage == d_vrai)
  991:     {
  992:         profilage(s_etat_processus, "Suspend");
  993: 
  994:         if ((*s_etat_processus).erreur_systeme != d_es)
  995:         {
  996:             return;
  997:         }
  998:     }
  999: 
 1000: #   ifndef SEMAPHORES_NOMMES
 1001:     if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0)
 1002:     {
 1003:         (*s_etat_processus).erreur_systeme = d_es_processus;
 1004:         return;
 1005:     }
 1006: #   else
 1007:     if (sem_post((*s_etat_processus).semaphore_fork) != 0)
 1008:     {
 1009:         (*s_etat_processus).erreur_systeme = d_es_processus;
 1010:         return;
 1011:     }
 1012: #   endif
 1013: 
 1014:     sigsuspend(&masque);
 1015: 
 1016: #   ifndef SEMAPHORES_NOMMES
 1017:     while(sem_wait(&((*s_etat_processus).semaphore_fork)) == -1)
 1018: #   else
 1019:     while(sem_wait((*s_etat_processus).semaphore_fork) == -1)
 1020: #   endif
 1021:     {
 1022:         if (errno != EINTR)
 1023:         {
 1024:             (*s_etat_processus).erreur_systeme = d_es_processus;
 1025:             return;
 1026:         }
 1027:     }
 1028: 
 1029:     if ((*s_etat_processus).profilage == d_vrai)
 1030:     {
 1031:         profilage(s_etat_processus, NULL);
 1032:     }
 1033: 
 1034:     return;
 1035: }
 1036: 
 1037: 
 1038: /*
 1039: ================================================================================
 1040:   Fonction 'static'
 1041: ================================================================================
 1042:   Entrées : structure processus
 1043: --------------------------------------------------------------------------------
 1044:   Sorties :
 1045: --------------------------------------------------------------------------------
 1046:   Effets de bord : néant
 1047: ================================================================================
 1048: */
 1049: 
 1050: void
 1051: instruction_static(struct_processus *s_etat_processus)
 1052: {
 1053:     (*s_etat_processus).erreur_execution = d_ex;
 1054: 
 1055:     if ((*s_etat_processus).affichage_arguments == 'Y')
 1056:     {
 1057:         printf("\n  STATIC ");
 1058: 
 1059:         if ((*s_etat_processus).langue == 'F')
 1060:         {
 1061:             printf("(déclaration de variables statiques)\n\n");
 1062:             printf("  Aucun argument\n");
 1063:         }
 1064:         else
 1065:         {
 1066:             printf("(static variables declaration)\n\n");
 1067:             printf("  No argument\n");
 1068:         }
 1069: 
 1070:         return;
 1071:     }
 1072:     else if ((*s_etat_processus).test_instruction == 'Y')
 1073:     {
 1074:         (*s_etat_processus).nombre_arguments = -1;
 1075:         return;
 1076:     }
 1077:     
 1078:     if (test_cfsf(s_etat_processus, 31) == d_vrai)
 1079:     {
 1080:         if (empilement_pile_last(s_etat_processus, 0) == d_erreur)
 1081:         {
 1082:             return;
 1083:         }
 1084:     }
 1085: 
 1086:     if ((*s_etat_processus).creation_variables_partagees == d_vrai)
 1087:     {
 1088:         (*s_etat_processus).erreur_execution = d_ex_variable_statique_partagee;
 1089:         return;
 1090:     }
 1091: 
 1092:     (*s_etat_processus).creation_variables_statiques = d_vrai;
 1093: 
 1094:     return;
 1095: }
 1096: 
 1097: 
 1098: /*
 1099: ================================================================================
 1100:   Fonction 'shared'
 1101: ================================================================================
 1102:   Entrées : structure processus
 1103: --------------------------------------------------------------------------------
 1104:   Sorties :
 1105: --------------------------------------------------------------------------------
 1106:   Effets de bord : néant
 1107: ================================================================================
 1108: */
 1109: 
 1110: void
 1111: instruction_shared(struct_processus *s_etat_processus)
 1112: {
 1113:     (*s_etat_processus).erreur_execution = d_ex;
 1114: 
 1115:     if ((*s_etat_processus).affichage_arguments == 'Y')
 1116:     {
 1117:         printf("\n  SHARED ");
 1118: 
 1119:         if ((*s_etat_processus).langue == 'F')
 1120:         {
 1121:             printf("(déclaration de variables partagées)\n\n");
 1122:             printf("  Aucun argument\n");
 1123:         }
 1124:         else
 1125:         {
 1126:             printf("(shared variables declaration)\n\n");
 1127:             printf("  No argument\n");
 1128:         }
 1129: 
 1130:         return;
 1131:     }
 1132:     else if ((*s_etat_processus).test_instruction == 'Y')
 1133:     {
 1134:         (*s_etat_processus).nombre_arguments = -1;
 1135:         return;
 1136:     }
 1137:     
 1138:     if (test_cfsf(s_etat_processus, 31) == d_vrai)
 1139:     {
 1140:         if (empilement_pile_last(s_etat_processus, 0) == d_erreur)
 1141:         {
 1142:             return;
 1143:         }
 1144:     }
 1145: 
 1146:     if ((*s_etat_processus).creation_variables_partagees == d_vrai)
 1147:     {
 1148:         (*s_etat_processus).erreur_execution = d_ex_variable_statique_partagee;
 1149:         return;
 1150:     }
 1151: 
 1152:     (*s_etat_processus).creation_variables_partagees = d_vrai;
 1153: 
 1154:     return;
 1155: }
 1156: 
 1157: 
 1158: /*
 1159: ================================================================================
 1160:   Fonction 'stoswi'
 1161: ================================================================================
 1162:   Entrées : structure processus
 1163: --------------------------------------------------------------------------------
 1164:   Sorties :
 1165: --------------------------------------------------------------------------------
 1166:   Effets de bord : néant
 1167: ================================================================================
 1168: */
 1169: 
 1170: void
 1171: instruction_stoswi(struct_processus *s_etat_processus)
 1172: {
 1173:     integer8                    interruption;
 1174: 
 1175:     struct_objet                *s_objet_argument_1;
 1176:     struct_objet                *s_objet_argument_2;
 1177: 
 1178:     (*s_etat_processus).erreur_execution = d_ex;
 1179: 
 1180:     if ((*s_etat_processus).affichage_arguments == 'Y')
 1181:     {
 1182:         printf("\n  STOSWI ");
 1183: 
 1184:         if ((*s_etat_processus).langue == 'F')
 1185:         {
 1186:             printf("(définition d'une interruption logicielle)\n\n");
 1187:         }
 1188:         else
 1189:         {
 1190:             printf("(software interrupt definition)\n\n");
 1191:         }
 1192: 
 1193:         printf("    2: %s, %s\n", d_NOM, d_RPN);
 1194:         printf("    1: %s\n", d_INT);
 1195: 
 1196:         return;
 1197:     }
 1198:     else if ((*s_etat_processus).test_instruction == 'Y')
 1199:     {
 1200:         (*s_etat_processus).nombre_arguments = -1;
 1201:         return;
 1202:     }
 1203: 
 1204:     if (test_cfsf(s_etat_processus, 31) == d_vrai)
 1205:     {
 1206:         if (empilement_pile_last(s_etat_processus, 2) == d_erreur)
 1207:         {
 1208:             return;
 1209:         }
 1210:     }
 1211: 
 1212:     if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
 1213:             &s_objet_argument_1) == d_erreur)
 1214:     {
 1215:         (*s_etat_processus).erreur_execution = d_ex_manque_argument;
 1216:         return;
 1217:     }
 1218: 
 1219:     if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
 1220:             &s_objet_argument_2) == d_erreur)
 1221:     {
 1222:         liberation(s_etat_processus, s_objet_argument_1);
 1223: 
 1224:         (*s_etat_processus).erreur_execution = d_ex_manque_argument;
 1225:         return;
 1226:     }
 1227: 
 1228:     if ((*s_objet_argument_1).type == INT)
 1229:     {
 1230:         interruption = (*((integer8 *) (*s_objet_argument_1).objet));
 1231: 
 1232:         if ((interruption < 1) || (interruption > d_NOMBRE_INTERRUPTIONS))
 1233:         {
 1234:             liberation(s_etat_processus, s_objet_argument_1);
 1235:             liberation(s_etat_processus, s_objet_argument_2);
 1236: 
 1237:             (*s_etat_processus).erreur_execution = d_ex_interruption_invalide;
 1238:             return;
 1239:         }
 1240: 
 1241:         if ((*s_objet_argument_2).type == NOM)
 1242:         {
 1243:             liberation(s_etat_processus, (*s_etat_processus).corps_interruptions
 1244:                     [interruption - 1]);
 1245:             (*s_etat_processus).corps_interruptions[interruption - 1] =
 1246:                     s_objet_argument_2;
 1247:         }
 1248:         else if((*s_objet_argument_2).type == RPN)
 1249:         {
 1250:             liberation(s_etat_processus, (*s_etat_processus).corps_interruptions
 1251:                     [interruption - 1]);
 1252:             (*s_etat_processus).corps_interruptions[interruption - 1] =
 1253:                     s_objet_argument_2;
 1254:         }
 1255:         else
 1256:         {
 1257:             liberation(s_etat_processus, s_objet_argument_1);
 1258:             liberation(s_etat_processus, s_objet_argument_2);
 1259: 
 1260:             (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
 1261:             return;
 1262:         }
 1263:     }
 1264:     else
 1265:     {
 1266:         liberation(s_etat_processus, s_objet_argument_1);
 1267:         liberation(s_etat_processus, s_objet_argument_2);
 1268: 
 1269:         (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
 1270:         return;
 1271:     }
 1272: 
 1273:     liberation(s_etat_processus, s_objet_argument_1);
 1274: 
 1275:     return;
 1276: }
 1277: 
 1278: 
 1279: /*
 1280: ================================================================================
 1281:   Fonction 'swi'
 1282: ================================================================================
 1283:   Entrées : structure processus
 1284: --------------------------------------------------------------------------------
 1285:   Sorties :
 1286: --------------------------------------------------------------------------------
 1287:   Effets de bord : néant
 1288: ================================================================================
 1289: */
 1290: 
 1291: void
 1292: instruction_swi(struct_processus *s_etat_processus)
 1293: {
 1294:     int                         interruption_reduite;
 1295: 
 1296:     integer8                    interruption;
 1297: 
 1298:     pid_t                       pid;
 1299: 
 1300:     pthread_t                   tid;
 1301: 
 1302:     sig_atomic_t                registre;
 1303: 
 1304:     ssize_t                     longueur_ecriture;
 1305: 
 1306:     struct_objet                *s_objet_argument;
 1307: 
 1308:     struct timespec             attente;
 1309: 
 1310:     unsigned char               tampon;
 1311: 
 1312:     (*s_etat_processus).erreur_execution = d_ex;
 1313: 
 1314:     if ((*s_etat_processus).affichage_arguments == 'Y')
 1315:     {
 1316:         printf("\n  SWI ");
 1317: 
 1318:         if ((*s_etat_processus).langue == 'F')
 1319:         {
 1320:             printf("(interruption logicielle)\n\n");
 1321:         }
 1322:         else
 1323:         {
 1324:             printf("(software interrupt)\n\n");
 1325:         }
 1326: 
 1327:         printf("    1: %s\n", d_INT);
 1328: 
 1329:         return;
 1330:     }
 1331:     else if ((*s_etat_processus).test_instruction == 'Y')
 1332:     {
 1333:         (*s_etat_processus).nombre_arguments = -1;
 1334:         return;
 1335:     }
 1336: 
 1337:     if (test_cfsf(s_etat_processus, 31) == d_vrai)
 1338:     {
 1339:         if (empilement_pile_last(s_etat_processus, 1) == d_erreur)
 1340:         {
 1341:             return;
 1342:         }
 1343:     }
 1344: 
 1345:     if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
 1346:             &s_objet_argument) == d_erreur)
 1347:     {
 1348:         (*s_etat_processus).erreur_execution = d_ex_manque_argument;
 1349:         return;
 1350:     }
 1351: 
 1352:     if ((*s_objet_argument).type == INT)
 1353:     {
 1354:         interruption = (*((integer8 *) (*s_objet_argument).objet));
 1355: 
 1356:         if ((interruption < 1) || (interruption > d_NOMBRE_INTERRUPTIONS))
 1357:         {
 1358:             liberation(s_etat_processus, s_objet_argument);
 1359: 
 1360:             (*s_etat_processus).erreur_execution = d_ex_interruption_invalide;
 1361:             return;
 1362:         }
 1363: 
 1364:         if ((*s_etat_processus).presence_pipes == d_faux)
 1365:         {
 1366:             liberation(s_etat_processus, s_objet_argument);
 1367: 
 1368:             (*s_etat_processus).erreur_execution = d_ex_absence_processus_pere;
 1369:             return;
 1370:         }
 1371: 
 1372:         // Envoi d'un PID invalide (-1) pour ne pas bloquer le thread
 1373:         // de surveillance.
 1374: 
 1375:         registre = (*s_etat_processus).var_volatile_traitement_retarde_stop;
 1376:         (*s_etat_processus).var_volatile_traitement_retarde_stop = 1;
 1377: 
 1378:         if ((*s_etat_processus).processus_detache == d_vrai)
 1379:         {
 1380:             pid = -1;
 1381: 
 1382:             attente.tv_sec = 0;
 1383:             attente.tv_nsec = GRANULARITE_us * 1000;
 1384: 
 1385: #           ifndef SEMAPHORES_NOMMES
 1386:             if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0)
 1387:             {
 1388:                 (*s_etat_processus).erreur_systeme = d_es_processus;
 1389:                 return;
 1390:             }
 1391: #           else
 1392:             if (sem_post((*s_etat_processus).semaphore_fork) != 0)
 1393:             {
 1394:                 (*s_etat_processus).erreur_systeme = d_es_processus;
 1395:                 return;
 1396:             }
 1397: #           endif
 1398: 
 1399:             while((longueur_ecriture = write_atomic(s_etat_processus,
 1400:                     (*s_etat_processus).pipe_nombre_objets_attente,
 1401:                     &pid, sizeof(pid))) != sizeof(pid))
 1402:             {
 1403: #               ifndef SEMAPHORES_NOMMES
 1404:                 while(sem_wait(&((*s_etat_processus).semaphore_fork)) == -1)
 1405: #               else
 1406:                 while(sem_wait((*s_etat_processus).semaphore_fork) == -1)
 1407: #               endif
 1408:                 {
 1409:                     if (errno != EINTR)
 1410:                     {
 1411:                         (*s_etat_processus).erreur_systeme = d_es_processus;
 1412:                         return;
 1413:                     }
 1414:                 }
 1415: 
 1416:                 if (longueur_ecriture == -1)
 1417:                 {
 1418:                     if (registre == 0)
 1419:                     {
 1420:                         if ((*s_etat_processus)
 1421:                                 .var_volatile_traitement_retarde_stop == -1)
 1422:                         {
 1423:                             (*s_etat_processus).var_volatile_requete_arret = -1;
 1424:                         }
 1425: 
 1426:                         (*s_etat_processus)
 1427:                                 .var_volatile_traitement_retarde_stop
 1428:                                 = registre;
 1429:                     }
 1430: 
 1431:                     (*s_etat_processus).erreur_systeme = d_es_processus;
 1432:                     return;
 1433:                 }
 1434: 
 1435:                 nanosleep(&attente, NULL);
 1436:                 INCR_GRANULARITE(attente.tv_nsec);
 1437: 
 1438: #               ifndef SEMAPHORES_NOMMES
 1439:                 if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0)
 1440: #               else
 1441:                 if (sem_post((*s_etat_processus).semaphore_fork) != 0)
 1442: #               endif
 1443:                 {
 1444:                     (*s_etat_processus).erreur_systeme = d_es_processus;
 1445:                     return;
 1446:                 }
 1447:             }
 1448: 
 1449: #           ifndef SEMAPHORES_NOMMES
 1450:             while(sem_wait(&((*s_etat_processus).semaphore_fork)) == -1)
 1451: #           else
 1452:             while(sem_wait((*s_etat_processus).semaphore_fork) == -1)
 1453: #           endif
 1454:             {
 1455:                 if (errno != EINTR)
 1456:                 {
 1457:                     (*s_etat_processus).erreur_systeme = d_es_processus;
 1458:                     return;
 1459:                 }
 1460:             }
 1461:         }
 1462:         else
 1463:         {
 1464:             tid = -1;
 1465: 
 1466:             attente.tv_sec = 0;
 1467:             attente.tv_nsec = GRANULARITE_us * 1000;
 1468: 
 1469: #           ifndef SEMAPHORES_NOMMES
 1470:             if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0)
 1471:             {
 1472:                 (*s_etat_processus).erreur_systeme = d_es_processus;
 1473:                 return;
 1474:             }
 1475: #           else
 1476:             if (sem_post((*s_etat_processus).semaphore_fork) != 0)
 1477:             {
 1478:                 (*s_etat_processus).erreur_systeme = d_es_processus;
 1479:                 return;
 1480:             }
 1481: #           endif
 1482: 
 1483:             while((longueur_ecriture = write_atomic(s_etat_processus,
 1484:                     (*s_etat_processus).pipe_nombre_objets_attente,
 1485:                     &tid, sizeof(tid))) != sizeof(tid))
 1486:             {
 1487: #               ifndef SEMAPHORES_NOMMES
 1488:                 while(sem_wait(&((*s_etat_processus).semaphore_fork)) == -1)
 1489: #               else
 1490:                 while(sem_wait((*s_etat_processus).semaphore_fork) == -1)
 1491: #               endif
 1492:                 {
 1493:                     if (errno != EINTR)
 1494:                     {
 1495:                         (*s_etat_processus).erreur_systeme = d_es_processus;
 1496:                         return;
 1497:                     }
 1498:                 }
 1499: 
 1500:                 if (longueur_ecriture == -1)
 1501:                 {
 1502:                     if (registre == 0)
 1503:                     {
 1504:                         if ((*s_etat_processus)
 1505:                                 .var_volatile_traitement_retarde_stop == -1)
 1506:                         {
 1507:                             (*s_etat_processus).var_volatile_requete_arret = -1;
 1508:                         }
 1509: 
 1510:                         (*s_etat_processus)
 1511:                                 .var_volatile_traitement_retarde_stop
 1512:                                 = registre;
 1513:                     }
 1514: 
 1515:                     (*s_etat_processus).erreur_systeme = d_es_processus;
 1516:                     return;
 1517:                 }
 1518: 
 1519:                 nanosleep(&attente, NULL);
 1520:                 INCR_GRANULARITE(attente.tv_nsec);
 1521: 
 1522: #               ifndef SEMAPHORES_NOMMES
 1523:                 if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0)
 1524:                 {
 1525:                     (*s_etat_processus).erreur_systeme = d_es_processus;
 1526:                     return;
 1527:                 }
 1528: #               else
 1529:                 if (sem_post((*s_etat_processus).semaphore_fork) != 0)
 1530:                 {
 1531:                     (*s_etat_processus).erreur_systeme = d_es_processus;
 1532:                     return;
 1533:                 }
 1534: #               endif
 1535:             }
 1536: 
 1537: #           ifndef SEMAPHORES_NOMMES
 1538:             while(sem_wait(&((*s_etat_processus).semaphore_fork)) == -1)
 1539: #           else
 1540:             while(sem_wait((*s_etat_processus).semaphore_fork) == -1)
 1541: #           endif
 1542:             {
 1543:                 if (errno != EINTR)
 1544:                 {
 1545:                     (*s_etat_processus).erreur_systeme = d_es_processus;
 1546:                     return;
 1547:                 }
 1548:             }
 1549:         }
 1550: 
 1551:         interruption_reduite = interruption;
 1552: 
 1553:         attente.tv_sec = 0;
 1554:         attente.tv_nsec = GRANULARITE_us * 1000;
 1555: 
 1556: #       ifndef SEMAPHORES_NOMMES
 1557:         if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0)
 1558:         {
 1559:             (*s_etat_processus).erreur_systeme = d_es_processus;
 1560:             return;
 1561:         }
 1562: #       else
 1563:         if (sem_post((*s_etat_processus).semaphore_fork) != 0)
 1564:         {
 1565:             (*s_etat_processus).erreur_systeme = d_es_processus;
 1566:             return;
 1567:         }
 1568: #       endif
 1569: 
 1570:         while((longueur_ecriture = write_atomic(s_etat_processus,
 1571:                 (*s_etat_processus).pipe_interruptions,
 1572:                 &interruption_reduite, sizeof(interruption_reduite)))
 1573:                 != sizeof(interruption_reduite))
 1574:         {
 1575: #           ifndef SEMAPHORES_NOMMES
 1576:             while(sem_wait(&((*s_etat_processus).semaphore_fork)) == -1)
 1577: #           else
 1578:             while(sem_wait((*s_etat_processus).semaphore_fork) == -1)
 1579: #           endif
 1580:             {
 1581:                 if (errno != EINTR)
 1582:                 {
 1583:                     (*s_etat_processus).erreur_systeme = d_es_processus;
 1584:                     return;
 1585:                 }
 1586:             }
 1587: 
 1588:             if (longueur_ecriture == -1)
 1589:             {
 1590:                 if (registre == 0)
 1591:                 {
 1592:                     if ((*s_etat_processus)
 1593:                             .var_volatile_traitement_retarde_stop == -1)
 1594:                     {
 1595:                         (*s_etat_processus).var_volatile_requete_arret = -1;
 1596:                     }
 1597: 
 1598:                     (*s_etat_processus)
 1599:                             .var_volatile_traitement_retarde_stop
 1600:                             = registre;
 1601:                 }
 1602: 
 1603:                 (*s_etat_processus).erreur_systeme = d_es_processus;
 1604:                 return;
 1605:             }
 1606: 
 1607:             nanosleep(&attente, NULL);
 1608:             INCR_GRANULARITE(attente.tv_nsec);
 1609: 
 1610: #           ifndef SEMAPHORES_NOMMES
 1611:             if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0)
 1612:             {
 1613:                 (*s_etat_processus).erreur_systeme = d_es_processus;
 1614:                 return;
 1615:             }
 1616: #           else
 1617:             if (sem_post((*s_etat_processus).semaphore_fork) != 0)
 1618:             {
 1619:                 (*s_etat_processus).erreur_systeme = d_es_processus;
 1620:                 return;
 1621:             }
 1622: #           endif
 1623:         }
 1624: 
 1625: #       ifndef SEMAPHORES_NOMMES
 1626:         while(sem_wait(&((*s_etat_processus).semaphore_fork)) == -1)
 1627: #       else
 1628:         while(sem_wait((*s_etat_processus).semaphore_fork) == -1)
 1629: #       endif
 1630:         {
 1631:             if (errno != EINTR)
 1632:             {
 1633:                 (*s_etat_processus).erreur_systeme = d_es_processus;
 1634:                 return;
 1635:             }
 1636:         }
 1637: 
 1638:         if ((*s_etat_processus).processus_detache == d_vrai)
 1639:         {
 1640:             pid = -3;
 1641: 
 1642:             attente.tv_sec = 0;
 1643:             attente.tv_nsec = GRANULARITE_us * 1000;
 1644: 
 1645: #           ifndef SEMAPHORES_NOMMES
 1646:             if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0)
 1647:             {
 1648:                 (*s_etat_processus).erreur_systeme = d_es_processus;
 1649:                 return;
 1650:             }
 1651: #           else
 1652:             if (sem_post((*s_etat_processus).semaphore_fork) != 0)
 1653:             {
 1654:                 (*s_etat_processus).erreur_systeme = d_es_processus;
 1655:                 return;
 1656:             }
 1657: #           endif
 1658: 
 1659:             while((longueur_ecriture = write_atomic(s_etat_processus,
 1660:                     (*s_etat_processus).pipe_nombre_interruptions_attente,
 1661:                     &pid, sizeof(pid))) != sizeof(pid))
 1662:             {
 1663: #               ifndef SEMAPHORES_NOMMES
 1664:                 while(sem_wait(&((*s_etat_processus).semaphore_fork)) == -1)
 1665: #               else
 1666:                 while(sem_wait((*s_etat_processus).semaphore_fork) == -1)
 1667: #               endif
 1668:                 {
 1669:                     (*s_etat_processus).erreur_systeme = d_es_processus;
 1670:                     return;
 1671:                 }
 1672: 
 1673:                 if (longueur_ecriture == -1)
 1674:                 {
 1675:                     if (registre == 0)
 1676:                     {
 1677:                         if ((*s_etat_processus)
 1678:                                 .var_volatile_traitement_retarde_stop == -1)
 1679:                         {
 1680:                             (*s_etat_processus).var_volatile_requete_arret = -1;
 1681:                         }
 1682: 
 1683:                         (*s_etat_processus)
 1684:                                 .var_volatile_traitement_retarde_stop
 1685:                                 = registre;
 1686:                     }
 1687: 
 1688:                     (*s_etat_processus).erreur_systeme = d_es_processus;
 1689:                     return;
 1690:                 }
 1691: 
 1692:                 nanosleep(&attente, NULL);
 1693:                 INCR_GRANULARITE(attente.tv_nsec);
 1694: 
 1695: #               ifndef SEMAPHORES_NOMMES
 1696:                 if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0)
 1697:                 {
 1698:                     (*s_etat_processus).erreur_systeme = d_es_processus;
 1699:                     return;
 1700:                 }
 1701: #               else
 1702:                 if (sem_post((*s_etat_processus).semaphore_fork) != 0)
 1703:                 {
 1704:                     (*s_etat_processus).erreur_systeme = d_es_processus;
 1705:                     return;
 1706:                 }
 1707: #               endif
 1708:             }
 1709: 
 1710:             pid = getpid();
 1711: 
 1712:             attente.tv_sec = 0;
 1713:             attente.tv_nsec = GRANULARITE_us * 1000;
 1714: 
 1715:             while((longueur_ecriture = write_atomic(s_etat_processus,
 1716:                     (*s_etat_processus).pipe_nombre_interruptions_attente,
 1717:                     &pid, sizeof(pid))) != sizeof(pid))
 1718:             {
 1719: #               ifndef SEMAPHORES_NOMMES
 1720:                 while(sem_wait(&((*s_etat_processus).semaphore_fork)) == -1)
 1721: #               else
 1722:                 while(sem_wait((*s_etat_processus).semaphore_fork) == -1)
 1723: #               endif
 1724:                 {
 1725:                     if (errno != EINTR)
 1726:                     {
 1727:                         (*s_etat_processus).erreur_systeme = d_es_processus;
 1728:                         return;
 1729:                     }
 1730:                 }
 1731: 
 1732:                 if (longueur_ecriture == -1)
 1733:                 {
 1734:                     if (registre == 0)
 1735:                     {
 1736:                         if ((*s_etat_processus)
 1737:                                 .var_volatile_traitement_retarde_stop == -1)
 1738:                         {
 1739:                             (*s_etat_processus).var_volatile_requete_arret = -1;
 1740:                         }
 1741: 
 1742:                         (*s_etat_processus)
 1743:                                 .var_volatile_traitement_retarde_stop
 1744:                                 = registre;
 1745:                     }
 1746: 
 1747:                     (*s_etat_processus).erreur_systeme = d_es_processus;
 1748:                     return;
 1749:                 }
 1750: 
 1751:                 nanosleep(&attente, NULL);
 1752:                 INCR_GRANULARITE(attente.tv_nsec);
 1753: 
 1754: #               ifndef SEMAPHORES_NOMMES
 1755:                 if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0)
 1756:                 {
 1757:                     (*s_etat_processus).erreur_systeme = d_es_processus;
 1758:                     return;
 1759:                 }
 1760: #               else
 1761:                 if (sem_post((*s_etat_processus).semaphore_fork) != 0)
 1762:                 {
 1763:                     (*s_etat_processus).erreur_systeme = d_es_processus;
 1764:                     return;
 1765:                 }
 1766: #               endif
 1767:             }
 1768: 
 1769: #           ifndef SEMAPHORES_NOMMES
 1770:             while(sem_wait(&((*s_etat_processus).semaphore_fork)) == -1)
 1771: #           else
 1772:             while(sem_wait((*s_etat_processus).semaphore_fork) == -1)
 1773: #           endif
 1774:             {
 1775:                 if (errno != EINTR)
 1776:                 {
 1777:                     (*s_etat_processus).erreur_systeme = d_es_processus;
 1778:                     return;
 1779:                 }
 1780:             }
 1781:         }
 1782:         else
 1783:         {
 1784:             tid = -3;
 1785: 
 1786: #           ifndef SEMAPHORES_NOMMES
 1787:             if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0)
 1788:             {
 1789:                 (*s_etat_processus).erreur_systeme = d_es_processus;
 1790:                 return;
 1791:             }
 1792: #           else
 1793:             if (sem_post((*s_etat_processus).semaphore_fork) != 0)
 1794:             {
 1795:                 (*s_etat_processus).erreur_systeme = d_es_processus;
 1796:                 return;
 1797:             }
 1798: #           endif
 1799: 
 1800:             while((longueur_ecriture = write_atomic(s_etat_processus,
 1801:                     (*s_etat_processus).pipe_nombre_interruptions_attente,
 1802:                     &tid, sizeof(tid))) != sizeof(tid))
 1803:             {
 1804: #               ifndef SEMAPHORES_NOMMES
 1805:                 while(sem_wait(&((*s_etat_processus).semaphore_fork)) == -1)
 1806: #               else
 1807:                 while(sem_wait((*s_etat_processus).semaphore_fork) == -1)
 1808: #               endif
 1809:                 {
 1810:                     if (errno != EINTR)
 1811:                     {
 1812:                         (*s_etat_processus).erreur_systeme = d_es_processus;
 1813:                         return;
 1814:                     }
 1815:                 }
 1816: 
 1817:                 if (longueur_ecriture == -1)
 1818:                 {
 1819:                     if (registre == 0)
 1820:                     {
 1821:                         if ((*s_etat_processus)
 1822:                                 .var_volatile_traitement_retarde_stop == -1)
 1823:                         {
 1824:                             (*s_etat_processus).var_volatile_requete_arret = -1;
 1825:                         }
 1826: 
 1827:                         (*s_etat_processus)
 1828:                                 .var_volatile_traitement_retarde_stop
 1829:                                 = registre;
 1830:                     }
 1831: 
 1832:                     (*s_etat_processus).erreur_systeme = d_es_processus;
 1833:                     return;
 1834:                 }
 1835: 
 1836:                 nanosleep(&attente, NULL);
 1837:                 INCR_GRANULARITE(attente.tv_nsec);
 1838: 
 1839: #               ifndef SEMAPHORES_NOMMES
 1840:                 if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0)
 1841:                 {
 1842:                     (*s_etat_processus).erreur_systeme = d_es_processus;
 1843:                     return;
 1844:                 }
 1845: #               else
 1846:                 if (sem_post((*s_etat_processus).semaphore_fork) != 0)
 1847:                 {
 1848:                     (*s_etat_processus).erreur_systeme = d_es_processus;
 1849:                     return;
 1850:                 }
 1851: #               endif
 1852:             }
 1853: 
 1854:             tid = pthread_self();
 1855: 
 1856:             attente.tv_sec = 0;
 1857:             attente.tv_nsec = GRANULARITE_us * 1000;
 1858: 
 1859:             while((longueur_ecriture = write_atomic(s_etat_processus,
 1860:                     (*s_etat_processus).pipe_nombre_interruptions_attente,
 1861:                     &tid, sizeof(tid))) != sizeof(tid))
 1862:             {
 1863: #               ifndef SEMAPHORES_NOMMES
 1864:                 while(sem_wait(&((*s_etat_processus).semaphore_fork)) == -1)
 1865: #               else
 1866:                 while(sem_wait((*s_etat_processus).semaphore_fork) == -1)
 1867: #               endif
 1868:                 {
 1869:                     if (errno != EINTR)
 1870:                     {
 1871:                         (*s_etat_processus).erreur_systeme = d_es_processus;
 1872:                         return;
 1873:                     }
 1874:                 }
 1875: 
 1876:                 if (longueur_ecriture == -1)
 1877: 
 1878:                 {
 1879:                     if (registre == 0)
 1880:                     {
 1881:                         if ((*s_etat_processus)
 1882:                                 .var_volatile_traitement_retarde_stop == -1)
 1883:                         {
 1884:                             (*s_etat_processus).var_volatile_requete_arret = -1;
 1885:                         }
 1886: 
 1887:                         (*s_etat_processus)
 1888:                                 .var_volatile_traitement_retarde_stop
 1889:                                 = registre;
 1890:                     }
 1891: 
 1892:                     (*s_etat_processus).erreur_systeme = d_es_processus;
 1893:                     return;
 1894:                 }
 1895: 
 1896:                 nanosleep(&attente, NULL);
 1897:                 INCR_GRANULARITE(attente.tv_nsec);
 1898: 
 1899: #               ifndef SEMAPHORES_NOMMES
 1900:                 if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0)
 1901:                 {
 1902:                     (*s_etat_processus).erreur_systeme = d_es_processus;
 1903:                     return;
 1904:                 }
 1905: #               else
 1906:                 if (sem_post((*s_etat_processus).semaphore_fork) != 0)
 1907:                 {
 1908:                     (*s_etat_processus).erreur_systeme = d_es_processus;
 1909:                     return;
 1910:                 }
 1911: #               endif
 1912:             }
 1913: 
 1914: #           ifndef SEMAPHORES_NOMMES
 1915:             while(sem_wait(&((*s_etat_processus).semaphore_fork)) == -1)
 1916: #           else
 1917:             while(sem_wait((*s_etat_processus).semaphore_fork) == -1)
 1918: #           endif
 1919:             {
 1920:                 if (errno != EINTR)
 1921:                 {
 1922:                     (*s_etat_processus).erreur_systeme = d_es_processus;
 1923:                     return;
 1924:                 }
 1925:             }
 1926:         }
 1927: 
 1928:         attente.tv_sec = 0;
 1929:         attente.tv_nsec = GRANULARITE_us * 1000;
 1930: 
 1931: #       ifndef SEMAPHORES_NOMMES
 1932:         if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0)
 1933:         {
 1934:             (*s_etat_processus).erreur_systeme = d_es_processus;
 1935:             return;
 1936:         }
 1937: #       else
 1938:         if (sem_post((*s_etat_processus).semaphore_fork) != 0)
 1939:         {
 1940:             (*s_etat_processus).erreur_systeme = d_es_processus;
 1941:             return;
 1942:         }
 1943: #       endif
 1944: 
 1945:         while(read_atomic(s_etat_processus,
 1946:                 (*s_etat_processus).pipe_acquittement,
 1947:                 &tampon, sizeof(unsigned char)) != sizeof(unsigned char))
 1948:         {
 1949: #           ifndef SEMAPHORES_NOMMES
 1950:             while(sem_wait(&((*s_etat_processus).semaphore_fork)) == -1)
 1951: #           else
 1952:             while(sem_wait((*s_etat_processus).semaphore_fork) == -1)
 1953: #           endif
 1954:             {
 1955:                 if (errno != EINTR)
 1956:                 {
 1957:                     (*s_etat_processus).erreur_systeme = d_es_processus;
 1958:                     return;
 1959:                 }
 1960:             }
 1961: 
 1962:             nanosleep(&attente, NULL);
 1963:             INCR_GRANULARITE(attente.tv_nsec);
 1964: 
 1965: #           ifndef SEMAPHORES_NOMMES
 1966:             if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0)
 1967: #           else
 1968:             if (sem_post((*s_etat_processus).semaphore_fork) != 0)
 1969: #           endif
 1970:             {
 1971:                 (*s_etat_processus).erreur_systeme = d_es_processus;
 1972:                 return;
 1973:             }
 1974:         }
 1975: 
 1976: #       ifndef SEMAPHORES_NOMMES
 1977:         while(sem_wait(&((*s_etat_processus).semaphore_fork)) == -1)
 1978: #       else
 1979:         while(sem_wait((*s_etat_processus).semaphore_fork) == -1)
 1980: #       endif
 1981:         {
 1982:             if (errno != EINTR)
 1983:             {
 1984:                 (*s_etat_processus).erreur_systeme = d_es_processus;
 1985:                 return;
 1986:             }
 1987:         }
 1988: 
 1989:         if (registre == 0)
 1990:         {
 1991:             if ((*s_etat_processus).var_volatile_traitement_retarde_stop == -1)
 1992:             {
 1993:                 (*s_etat_processus).var_volatile_requete_arret = -1;
 1994:             }
 1995: 
 1996:             (*s_etat_processus).var_volatile_traitement_retarde_stop = registre;
 1997:         }
 1998:     }
 1999:     else
 2000:     {
 2001:         liberation(s_etat_processus, s_objet_argument);
 2002: 
 2003:         (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
 2004:         return;
 2005:     }
 2006: 
 2007:     liberation(s_etat_processus, s_objet_argument);
 2008: 
 2009:     return;
 2010: }
 2011: 
 2012: 
 2013: /*
 2014: ================================================================================
 2015:   Fonction 'swilock'
 2016: ================================================================================
 2017:   Entrées : structure processus
 2018: --------------------------------------------------------------------------------
 2019:   Sorties :
 2020: --------------------------------------------------------------------------------
 2021:   Effets de bord : néant
 2022: ================================================================================
 2023: */
 2024: 
 2025: void
 2026: instruction_swilock(struct_processus *s_etat_processus)
 2027: {
 2028:     integer8                    interruption;
 2029: 
 2030:     struct_liste_chainee        *l_element_courant;
 2031: 
 2032:     struct_objet                *s_objet_argument;
 2033: 
 2034:     (*s_etat_processus).erreur_execution = d_ex;
 2035: 
 2036:     if ((*s_etat_processus).affichage_arguments == 'Y')
 2037:     {
 2038:         printf("\n  SWILOCK ");
 2039: 
 2040:         if ((*s_etat_processus).langue == 'F')
 2041:         {
 2042:             printf("(verrouillage des interruptions logicielles)\n\n");
 2043:         }
 2044:         else
 2045:         {
 2046:             printf("(software interrupt lock)\n\n");
 2047:         }
 2048: 
 2049:         printf("    1: %s, %s\n", d_INT, d_LST);
 2050: 
 2051:         return;
 2052:     }
 2053:     else if ((*s_etat_processus).test_instruction == 'Y')
 2054:     {
 2055:         (*s_etat_processus).nombre_arguments = -1;
 2056:         return;
 2057:     }
 2058: 
 2059:     if (test_cfsf(s_etat_processus, 31) == d_vrai)
 2060:     {
 2061:         if (empilement_pile_last(s_etat_processus, 1) == d_erreur)
 2062:         {
 2063:             return;
 2064:         }
 2065:     }
 2066: 
 2067:     if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
 2068:             &s_objet_argument) == d_erreur)
 2069:     {
 2070:         (*s_etat_processus).erreur_execution = d_ex_manque_argument;
 2071:         return;
 2072:     }
 2073: 
 2074:     if ((*s_objet_argument).type == INT)
 2075:     {
 2076:         interruption = (*((integer8 *) (*s_objet_argument).objet));
 2077: 
 2078:         if ((interruption < 1) || (interruption > d_NOMBRE_INTERRUPTIONS))
 2079:         {
 2080:             liberation(s_etat_processus, s_objet_argument);
 2081: 
 2082:             (*s_etat_processus).erreur_execution = d_ex_interruption_invalide;
 2083:             return;
 2084:         }
 2085: 
 2086:         (*s_etat_processus).masque_interruptions[interruption - 1] = 'I';
 2087:     }
 2088:     else if ((*s_objet_argument).type == LST)
 2089:     {
 2090:         l_element_courant = (*s_objet_argument).objet;
 2091: 
 2092:         while(l_element_courant)
 2093:         {
 2094:             if ((*(*l_element_courant).donnee).type != INT)
 2095:             {
 2096:                 liberation(s_etat_processus, s_objet_argument);
 2097: 
 2098:                 (*s_etat_processus).erreur_execution =
 2099:                         d_ex_erreur_type_argument;
 2100:                 return;
 2101:             }
 2102: 
 2103:             interruption = (*((integer8 *) (*(*l_element_courant)
 2104:                     .donnee).objet));
 2105: 
 2106:             if ((interruption < 1) || (interruption > d_NOMBRE_INTERRUPTIONS))
 2107:             {
 2108:                 liberation(s_etat_processus, s_objet_argument);
 2109: 
 2110:                 (*s_etat_processus).erreur_execution =
 2111:                         d_ex_interruption_invalide;
 2112:                 return;
 2113:             }
 2114: 
 2115:             (*s_etat_processus).masque_interruptions[interruption - 1] = 'I';
 2116:             l_element_courant = (*l_element_courant).suivant;
 2117:         }
 2118:     }
 2119:     else
 2120:     {
 2121:         liberation(s_etat_processus, s_objet_argument);
 2122: 
 2123:         (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
 2124:         return;
 2125:     }
 2126: 
 2127:     liberation(s_etat_processus, s_objet_argument);
 2128: 
 2129:     return;
 2130: }
 2131: 
 2132: 
 2133: /*
 2134: ================================================================================
 2135:   Fonction 'swistatus'
 2136: ================================================================================
 2137:   Entrées : structure processus
 2138: --------------------------------------------------------------------------------
 2139:   Sorties :
 2140: --------------------------------------------------------------------------------
 2141:   Effets de bord : néant
 2142: ================================================================================
 2143: */
 2144: 
 2145: void
 2146: instruction_swistatus(struct_processus *s_etat_processus)
 2147: {
 2148:     int                         i;
 2149: 
 2150:     struct_liste_chainee        *l_element_courant;
 2151:     struct_liste_chainee        *l_element_futur;
 2152:     struct_liste_chainee        *l_element_liste;
 2153: 
 2154:     struct_objet                *s_objet_resultat;
 2155: 
 2156:     (*s_etat_processus).erreur_execution = d_ex;
 2157: 
 2158:     if ((*s_etat_processus).affichage_arguments == 'Y')
 2159:     {
 2160:         printf("\n  SWISTATUS ");
 2161: 
 2162:         if ((*s_etat_processus).langue == 'F')
 2163:         {
 2164:             printf("(état des interruptions logicielles)\n\n");
 2165:         }
 2166:         else
 2167:         {
 2168:             printf("(software interrupts status)\n\n");
 2169:         }
 2170: 
 2171:         printf("->  1: %s\n\n", d_LST);
 2172: 
 2173:         if ((*s_etat_processus).langue == 'F')
 2174:         {
 2175:             printf("  Utilisation :\n\n");
 2176:         }
 2177:         else
 2178:         {
 2179:             printf("  Usage:\n\n");
 2180:         }
 2181: 
 2182:         printf("    { { initialized interrupts }\n"
 2183:                 "      { unlocked interrupts }\n"
 2184:                 "      { queued interrupts }\n"
 2185:                 "      { locked interrupts } }\n");
 2186:         return;
 2187:     }
 2188:     else if ((*s_etat_processus).test_instruction == 'Y')
 2189:     {
 2190:         (*s_etat_processus).nombre_arguments = -1;
 2191:         return;
 2192:     }
 2193: 
 2194:     if (test_cfsf(s_etat_processus, 31) == d_vrai)
 2195:     {
 2196:         if (empilement_pile_last(s_etat_processus, 0) == d_erreur)
 2197:         {
 2198:             return;
 2199:         }
 2200:     }
 2201: 
 2202:     if ((s_objet_resultat = allocation(s_etat_processus, LST)) == NULL)
 2203:     {
 2204:         (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
 2205:         return;
 2206:     }
 2207: 
 2208:     if (((*s_objet_resultat).objet =
 2209:             allocation_maillon(s_etat_processus)) == NULL)
 2210:     {
 2211:         (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
 2212:         return;
 2213:     }
 2214: 
 2215:     l_element_courant = (struct_liste_chainee *) (*s_objet_resultat).objet;
 2216: 
 2217:     if (((*l_element_courant).donnee = allocation(s_etat_processus, LST))
 2218:             == NULL)
 2219:     {
 2220:         (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
 2221:         return;
 2222:     }
 2223: 
 2224:     l_element_liste = NULL;
 2225:     l_element_futur = NULL;
 2226: 
 2227:     for(i = 0; i < d_NOMBRE_INTERRUPTIONS; i++)
 2228:     {
 2229:         if ((*s_etat_processus).corps_interruptions[i] != NULL)
 2230:         {
 2231:             if (l_element_liste == NULL)
 2232:             {
 2233:                 if ((l_element_liste =
 2234:                         allocation_maillon(s_etat_processus)) == NULL)
 2235:                 {
 2236:                     (*s_etat_processus).erreur_systeme =
 2237:                             d_es_allocation_memoire;
 2238:                     return;
 2239:                 }
 2240: 
 2241:                 l_element_futur = l_element_liste;
 2242:             }
 2243:             else
 2244:             {
 2245:                 if (((*l_element_liste).suivant =
 2246:                         allocation_maillon(s_etat_processus)) == NULL)
 2247:                 {
 2248:                     (*s_etat_processus).erreur_systeme =
 2249:                             d_es_allocation_memoire;
 2250:                     return;
 2251:                 }
 2252: 
 2253:                 l_element_liste = (*l_element_liste).suivant;
 2254:             }
 2255: 
 2256:             (*l_element_liste).suivant = NULL;
 2257: 
 2258:             if (((*l_element_liste).donnee = allocation(s_etat_processus,
 2259:                     INT)) == NULL)
 2260:             {
 2261:                 (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
 2262:                 return;
 2263:             }
 2264: 
 2265:             (*((integer8 *) (*(*l_element_liste).donnee).objet)) = i + 1;
 2266:         }
 2267:     }
 2268: 
 2269:     (*(*l_element_courant).donnee).objet = l_element_futur;
 2270: 
 2271:     if (((*l_element_courant).suivant =
 2272:             allocation_maillon(s_etat_processus)) == NULL)
 2273:     {
 2274:         (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
 2275:         return;
 2276:     }
 2277: 
 2278:     l_element_courant = (*l_element_courant).suivant;
 2279: 
 2280:     if (((*l_element_courant).donnee = allocation(s_etat_processus, LST))
 2281:             == NULL)
 2282:     {
 2283:         (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
 2284:         return;
 2285:     }
 2286: 
 2287:     l_element_liste = NULL;
 2288:     l_element_futur = NULL;
 2289: 
 2290:     for(i = 0; i < d_NOMBRE_INTERRUPTIONS; i++)
 2291:     {
 2292:         if ((*s_etat_processus).masque_interruptions[i] == 'N')
 2293:         {
 2294:             if (l_element_liste == NULL)
 2295:             {
 2296:                 if ((l_element_liste =
 2297:                         allocation_maillon(s_etat_processus)) == NULL)
 2298:                 {
 2299:                     (*s_etat_processus).erreur_systeme =
 2300:                             d_es_allocation_memoire;
 2301:                     return;
 2302:                 }
 2303: 
 2304:                 l_element_futur = l_element_liste;
 2305:             }
 2306:             else
 2307:             {
 2308:                 if (((*l_element_liste).suivant =
 2309:                         allocation_maillon(s_etat_processus)) == NULL)
 2310:                 {
 2311:                     (*s_etat_processus).erreur_systeme =
 2312:                             d_es_allocation_memoire;
 2313:                     return;
 2314:                 }
 2315: 
 2316:                 l_element_liste = (*l_element_liste).suivant;
 2317:             }
 2318: 
 2319:             (*l_element_liste).suivant = NULL;
 2320: 
 2321:             if (((*l_element_liste).donnee = allocation(s_etat_processus,
 2322:                     INT)) == NULL)
 2323:             {
 2324:                 (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
 2325:                 return;
 2326:             }
 2327: 
 2328:             (*((integer8 *) (*(*l_element_liste).donnee).objet)) = i + 1;
 2329:         }
 2330:     }
 2331: 
 2332:     (*(*l_element_courant).donnee).objet = l_element_futur;
 2333: 
 2334:     if (((*l_element_courant).suivant = allocation_maillon(s_etat_processus))
 2335:             == NULL)
 2336:     {
 2337:         (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
 2338:         return;
 2339:     }
 2340: 
 2341:     l_element_courant = (*l_element_courant).suivant;
 2342: 
 2343:     if (((*l_element_courant).donnee = allocation(s_etat_processus, LST))
 2344:             == NULL)
 2345:     {
 2346:         (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
 2347:         return;
 2348:     }
 2349: 
 2350:     l_element_liste = NULL;
 2351:     l_element_futur = NULL;
 2352: 
 2353:     for(i = 0; i < d_NOMBRE_INTERRUPTIONS; i++)
 2354:     {
 2355:         if ((*s_etat_processus).masque_interruptions[i] == 'Q')
 2356:         {
 2357:             if (l_element_liste == NULL)
 2358:             {
 2359:                 if ((l_element_liste =
 2360:                         allocation_maillon(s_etat_processus)) == NULL)
 2361:                 {
 2362:                     (*s_etat_processus).erreur_systeme =
 2363:                             d_es_allocation_memoire;
 2364:                     return;
 2365:                 }
 2366: 
 2367:                 l_element_futur = l_element_liste;
 2368:             }
 2369:             else
 2370:             {
 2371:                 if (((*l_element_liste).suivant =
 2372:                         allocation_maillon(s_etat_processus)) == NULL)
 2373:                 {
 2374:                     (*s_etat_processus).erreur_systeme =
 2375:                             d_es_allocation_memoire;
 2376:                     return;
 2377:                 }
 2378: 
 2379:                 l_element_liste = (*l_element_liste).suivant;
 2380:             }
 2381: 
 2382:             (*l_element_liste).suivant = NULL;
 2383: 
 2384:             if (((*l_element_liste).donnee = allocation(s_etat_processus,
 2385:                     INT)) == NULL)
 2386:             {
 2387:                 (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
 2388:                 return;
 2389:             }
 2390: 
 2391:             (*((integer8 *) (*(*l_element_liste).donnee).objet)) = i + 1;
 2392:         }
 2393:     }
 2394: 
 2395:     (*(*l_element_courant).donnee).objet = l_element_futur;
 2396: 
 2397:     if (((*l_element_courant).suivant = allocation_maillon(s_etat_processus))
 2398:             == NULL)
 2399:     {
 2400:         (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
 2401:         return;
 2402:     }
 2403: 
 2404:     l_element_courant = (*l_element_courant).suivant;
 2405: 
 2406:     if (((*l_element_courant).donnee = allocation(s_etat_processus, LST))
 2407:             == NULL)
 2408:     {
 2409:         (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
 2410:         return;
 2411:     }
 2412: 
 2413:     l_element_liste = NULL;
 2414:     l_element_futur = NULL;
 2415: 
 2416:     for(i = 0; i < d_NOMBRE_INTERRUPTIONS; i++)
 2417:     {
 2418:         if ((*s_etat_processus).masque_interruptions[i] == 'I')
 2419:         {
 2420:             if (l_element_liste == NULL)
 2421:             {
 2422:                 if ((l_element_liste =
 2423:                         allocation_maillon(s_etat_processus)) == NULL)
 2424:                 {
 2425:                     (*s_etat_processus).erreur_systeme =
 2426:                             d_es_allocation_memoire;
 2427:                     return;
 2428:                 }
 2429: 
 2430:                 l_element_futur = l_element_liste;
 2431:             }
 2432:             else
 2433:             {
 2434:                 if (((*l_element_liste).suivant =
 2435:                         allocation_maillon(s_etat_processus)) == NULL)
 2436:                 {
 2437:                     (*s_etat_processus).erreur_systeme =
 2438:                             d_es_allocation_memoire;
 2439:                     return;
 2440:                 }
 2441: 
 2442:                 l_element_liste = (*l_element_liste).suivant;
 2443:             }
 2444: 
 2445:             (*l_element_liste).suivant = NULL;
 2446: 
 2447:             if (((*l_element_liste).donnee = allocation(s_etat_processus,
 2448:                     INT)) == NULL)
 2449:             {
 2450:                 (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
 2451:                 return;
 2452:             }
 2453: 
 2454:             (*((integer8 *) (*(*l_element_liste).donnee).objet)) = i + 1;
 2455:         }
 2456:     }
 2457: 
 2458:     (*(*l_element_courant).donnee).objet = l_element_futur;
 2459: 
 2460:     (*l_element_courant).suivant = NULL;
 2461: 
 2462:     if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
 2463:             s_objet_resultat) == d_erreur)
 2464:     {
 2465:         return;
 2466:     }
 2467: 
 2468:     return;
 2469: }
 2470: 
 2471: 
 2472: /*
 2473: ================================================================================
 2474:   Fonction 'swiunlock'
 2475: ================================================================================
 2476:   Entrées : structure processus
 2477: --------------------------------------------------------------------------------
 2478:   Sorties :
 2479: --------------------------------------------------------------------------------
 2480:   Effets de bord : néant
 2481: ================================================================================
 2482: */
 2483: 
 2484: void
 2485: instruction_swiunlock(struct_processus *s_etat_processus)
 2486: {
 2487:     integer8                    interruption;
 2488: 
 2489:     struct_liste_chainee        *l_element_courant;
 2490: 
 2491:     struct_objet                *s_objet_argument;
 2492: 
 2493:     (*s_etat_processus).erreur_execution = d_ex;
 2494: 
 2495:     if ((*s_etat_processus).affichage_arguments == 'Y')
 2496:     {
 2497:         printf("\n  SWIUNLOCK ");
 2498: 
 2499:         if ((*s_etat_processus).langue == 'F')
 2500:         {
 2501:             printf("(déverrouillage des interruptions logicielles)\n\n");
 2502:         }
 2503:         else
 2504:         {
 2505:             printf("(software interrupt unlock)\n\n");
 2506:         }
 2507: 
 2508:         printf("    1: %s, %s\n", d_INT, d_LST);
 2509: 
 2510:         return;
 2511:     }
 2512:     else if ((*s_etat_processus).test_instruction == 'Y')
 2513:     {
 2514:         (*s_etat_processus).nombre_arguments = -1;
 2515:         return;
 2516:     }
 2517: 
 2518:     if (test_cfsf(s_etat_processus, 31) == d_vrai)
 2519:     {
 2520:         if (empilement_pile_last(s_etat_processus, 1) == d_erreur)
 2521:         {
 2522:             return;
 2523:         }
 2524:     }
 2525: 
 2526:     if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
 2527:             &s_objet_argument) == d_erreur)
 2528:     {
 2529:         (*s_etat_processus).erreur_execution = d_ex_manque_argument;
 2530:         return;
 2531:     }
 2532: 
 2533:     if ((*s_objet_argument).type == INT)
 2534:     {
 2535:         interruption = (*((integer8 *) (*s_objet_argument).objet));
 2536: 
 2537:         if ((interruption < 1) || (interruption > d_NOMBRE_INTERRUPTIONS))
 2538:         {
 2539:             liberation(s_etat_processus, s_objet_argument);
 2540: 
 2541:             (*s_etat_processus).erreur_execution = d_ex_interruption_invalide;
 2542:             return;
 2543:         }
 2544: 
 2545:         (*s_etat_processus).masque_interruptions[interruption - 1] = 'N';
 2546:     }
 2547:     else if ((*s_objet_argument).type == LST)
 2548:     {
 2549:         l_element_courant = (*s_objet_argument).objet;
 2550: 
 2551:         while(l_element_courant)
 2552:         {
 2553:             if ((*(*l_element_courant).donnee).type != INT)
 2554:             {
 2555:                 liberation(s_etat_processus, s_objet_argument);
 2556: 
 2557:                 (*s_etat_processus).erreur_execution =
 2558:                         d_ex_erreur_type_argument;
 2559:                 return;
 2560:             }
 2561: 
 2562:             interruption = (*((integer8 *) (*(*l_element_courant)
 2563:                     .donnee).objet));
 2564: 
 2565:             if ((interruption < 1) || (interruption > d_NOMBRE_INTERRUPTIONS))
 2566:             {
 2567:                 liberation(s_etat_processus, s_objet_argument);
 2568: 
 2569:                 (*s_etat_processus).erreur_execution =
 2570:                         d_ex_interruption_invalide;
 2571:                 return;
 2572:             }
 2573: 
 2574:             (*s_etat_processus).masque_interruptions[interruption - 1] = 'N';
 2575:             l_element_courant = (*l_element_courant).suivant;
 2576:         }
 2577:     }
 2578:     else
 2579:     {
 2580:         liberation(s_etat_processus, s_objet_argument);
 2581: 
 2582:         (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
 2583:         return;
 2584:     }
 2585: 
 2586:     liberation(s_etat_processus, s_objet_argument);
 2587: 
 2588:     return;
 2589: }
 2590: 
 2591: 
 2592: /*
 2593: ================================================================================
 2594:   Fonction 'swiqueue'
 2595: ================================================================================
 2596:   Entrées : structure processus
 2597: --------------------------------------------------------------------------------
 2598:   Sorties :
 2599: --------------------------------------------------------------------------------
 2600:   Effets de bord : néant
 2601: ================================================================================
 2602: */
 2603: 
 2604: void
 2605: instruction_swiqueue(struct_processus *s_etat_processus)
 2606: {
 2607:     integer8                    interruption;
 2608: 
 2609:     struct_liste_chainee        *l_element_courant;
 2610: 
 2611:     struct_objet                *s_objet_argument;
 2612: 
 2613:     (*s_etat_processus).erreur_execution = d_ex;
 2614: 
 2615:     if ((*s_etat_processus).affichage_arguments == 'Y')
 2616:     {
 2617:         printf("\n  SWIQUEUE ");
 2618: 
 2619:         if ((*s_etat_processus).langue == 'F')
 2620:         {
 2621:             printf("(enregistre des interruptions logicielles)\n\n");
 2622:         }
 2623:         else
 2624:         {
 2625:             printf("(software interrupt record)\n\n");
 2626:         }
 2627: 
 2628:         printf("    1: %s, %s\n", d_INT, d_LST);
 2629: 
 2630:         return;
 2631:     }
 2632:     else if ((*s_etat_processus).test_instruction == 'Y')
 2633:     {
 2634:         (*s_etat_processus).nombre_arguments = -1;
 2635:         return;
 2636:     }
 2637: 
 2638:     if (test_cfsf(s_etat_processus, 31) == d_vrai)
 2639:     {
 2640:         if (empilement_pile_last(s_etat_processus, 1) == d_erreur)
 2641:         {
 2642:             return;
 2643:         }
 2644:     }
 2645: 
 2646:     if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
 2647:             &s_objet_argument) == d_erreur)
 2648:     {
 2649:         (*s_etat_processus).erreur_execution = d_ex_manque_argument;
 2650:         return;
 2651:     }
 2652: 
 2653:     if ((*s_objet_argument).type == INT)
 2654:     {
 2655:         interruption = (*((integer8 *) (*s_objet_argument).objet));
 2656: 
 2657:         if ((interruption < 1) || (interruption > d_NOMBRE_INTERRUPTIONS))
 2658:         {
 2659:             liberation(s_etat_processus, s_objet_argument);
 2660: 
 2661:             (*s_etat_processus).erreur_execution = d_ex_interruption_invalide;
 2662:             return;
 2663:         }
 2664: 
 2665:         (*s_etat_processus).masque_interruptions[interruption - 1] = 'Q';
 2666:     }
 2667:     else if ((*s_objet_argument).type == LST)
 2668:     {
 2669:         l_element_courant = (*s_objet_argument).objet;
 2670: 
 2671:         while(l_element_courant)
 2672:         {
 2673:             if ((*(*l_element_courant).donnee).type != INT)
 2674:             {
 2675:                 liberation(s_etat_processus, s_objet_argument);
 2676: 
 2677:                 (*s_etat_processus).erreur_execution =
 2678:                         d_ex_erreur_type_argument;
 2679:                 return;
 2680:             }
 2681: 
 2682:             interruption = (*((integer8 *) (*(*l_element_courant)
 2683:                     .donnee).objet));
 2684: 
 2685:             if ((interruption < 1) || (interruption > d_NOMBRE_INTERRUPTIONS))
 2686:             {
 2687:                 liberation(s_etat_processus, s_objet_argument);
 2688: 
 2689:                 (*s_etat_processus).erreur_execution =
 2690:                         d_ex_interruption_invalide;
 2691:                 return;
 2692:             }
 2693: 
 2694:             (*s_etat_processus).masque_interruptions[interruption - 1] = 'Q';
 2695:             l_element_courant = (*l_element_courant).suivant;
 2696:         }
 2697:     }
 2698:     else
 2699:     {
 2700:         liberation(s_etat_processus, s_objet_argument);
 2701: 
 2702:         (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
 2703:         return;
 2704:     }
 2705: 
 2706:     liberation(s_etat_processus, s_objet_argument);
 2707: 
 2708:     return;
 2709: }
 2710: 
 2711: 
 2712: /*
 2713: ================================================================================
 2714:   Fonction 'sched'
 2715: ================================================================================
 2716:   Entrées : structure processus
 2717: --------------------------------------------------------------------------------
 2718:   Sorties :
 2719: --------------------------------------------------------------------------------
 2720:   Effets de bord : néant
 2721: ================================================================================
 2722: */
 2723: 
 2724: void
 2725: instruction_sched(struct_processus *s_etat_processus)
 2726: {
 2727:     real8                       pourcentage;
 2728: 
 2729:     struct_objet                *s_objet_argument;
 2730: 
 2731:     (*s_etat_processus).erreur_execution = d_ex;
 2732: 
 2733:     if ((*s_etat_processus).affichage_arguments == 'Y')
 2734:     {
 2735:         printf("\n  SCHED ");
 2736: 
 2737:         if ((*s_etat_processus).langue == 'F')
 2738:         {
 2739:             printf("(limitation des ressources de calcul)\n\n");
 2740:         }
 2741:         else
 2742:         {
 2743:             printf("(CPU ressources limitation)\n\n");
 2744:         }
 2745: 
 2746:         printf("    1: %s, %s\n", d_INT, d_REL);
 2747: 
 2748:         return;
 2749:     }
 2750:     else if ((*s_etat_processus).test_instruction == 'Y')
 2751:     {
 2752:         (*s_etat_processus).nombre_arguments = -1;
 2753:         return;
 2754:     }
 2755: 
 2756:     if (test_cfsf(s_etat_processus, 31) == d_vrai)
 2757:     {
 2758:         if (empilement_pile_last(s_etat_processus, 1) == d_erreur)
 2759:         {
 2760:             return;
 2761:         }
 2762:     }
 2763: 
 2764:     if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
 2765:             &s_objet_argument) == d_erreur)
 2766:     {
 2767:         (*s_etat_processus).erreur_execution = d_ex_manque_argument;
 2768:         return;
 2769:     }
 2770: 
 2771:     if ((*s_objet_argument).type == INT)
 2772:     {
 2773:         pourcentage = (real8) (*((integer8 *) (*s_objet_argument).objet));
 2774:     }
 2775:     else if ((*s_objet_argument).type == REL)
 2776:     {
 2777:         pourcentage = (*((real8 *) (*s_objet_argument).objet));
 2778:     }
 2779:     else
 2780:     {
 2781:         liberation(s_etat_processus, s_objet_argument);
 2782: 
 2783:         (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
 2784:         return;
 2785:     }
 2786: 
 2787:     liberation(s_etat_processus, s_objet_argument);
 2788: 
 2789:     if ((pourcentage <= 0) || (pourcentage > 100))
 2790:     {
 2791:         (*s_etat_processus).erreur_execution = d_ex_argument_invalide;
 2792:         return;
 2793:     }
 2794: 
 2795:     (*s_etat_processus).pourcentage_maximal_cpu = pourcentage;
 2796: 
 2797:     return;
 2798: }
 2799: 
 2800: // vim: ts=4

CVSweb interface <joel.bertrand@systella.fr>