File:  [local] / rpl / src / instructions_s9.c
Revision 1.8: download - view: text, annotated - select for diffs - revision graph
Sat Apr 17 18:57:36 2010 UTC (14 years ago) by bertrand
Branches: MAIN
CVS tags: rpl-4_0_14, HEAD
Ajout du support pour MacOS X et Windows/Cygwin

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

CVSweb interface <joel.bertrand@systella.fr>