File:  [local] / rpl / src / instructions_s9.c
Revision 1.12: download - view: text, annotated - select for diffs - revision graph
Thu Jun 24 10:10:45 2010 UTC (13 years, 10 months ago) by bertrand
Branches: MAIN
CVS tags: rpl-4_0_17, HEAD
En route pour la 4.0.17 !

    1: /*
    2: ================================================================================
    3:   RPL/2 (R) version 4.0.17
    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, SIGFABORT) != 0)
  974:     {
  975:         (*s_etat_processus).erreur_systeme = d_es_processus;
  976:         return;
  977:     }
  978: 
  979:     if (sigdelset(&masque, SIGURG) != 0)
  980:     {
  981:         (*s_etat_processus).erreur_systeme = d_es_processus;
  982:         return;
  983:     }
  984: 
  985:     if (sigdelset(&masque, SIGALRM) != 0)
  986:     {
  987:         (*s_etat_processus).erreur_systeme = d_es_processus;
  988:         return;
  989:     }
  990: 
  991:     if ((*s_etat_processus).profilage == d_vrai)
  992:     {
  993:         profilage(s_etat_processus, "Suspend");
  994: 
  995:         if ((*s_etat_processus).erreur_systeme != d_es)
  996:         {
  997:             return;
  998:         }
  999:     }
 1000: 
 1001: #   ifndef SEMAPHORES_NOMMES
 1002:     if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0)
 1003:     {
 1004:         (*s_etat_processus).erreur_systeme = d_es_processus;
 1005:         return;
 1006:     }
 1007: #   else
 1008:     if (sem_post((*s_etat_processus).semaphore_fork) != 0)
 1009:     {
 1010:         (*s_etat_processus).erreur_systeme = d_es_processus;
 1011:         return;
 1012:     }
 1013: #   endif
 1014: 
 1015:     sigsuspend(&masque);
 1016: 
 1017: #   ifndef SEMAPHORES_NOMMES
 1018:     while(sem_wait(&((*s_etat_processus).semaphore_fork)) == -1)
 1019: #   else
 1020:     while(sem_wait((*s_etat_processus).semaphore_fork) == -1)
 1021: #   endif
 1022:     {
 1023:         if (errno != EINTR)
 1024:         {
 1025:             (*s_etat_processus).erreur_systeme = d_es_processus;
 1026:             return;
 1027:         }
 1028:     }
 1029: 
 1030:     if ((*s_etat_processus).profilage == d_vrai)
 1031:     {
 1032:         profilage(s_etat_processus, NULL);
 1033:     }
 1034: 
 1035:     return;
 1036: }
 1037: 
 1038: 
 1039: /*
 1040: ================================================================================
 1041:   Fonction 'static'
 1042: ================================================================================
 1043:   Entrées : structure processus
 1044: --------------------------------------------------------------------------------
 1045:   Sorties :
 1046: --------------------------------------------------------------------------------
 1047:   Effets de bord : néant
 1048: ================================================================================
 1049: */
 1050: 
 1051: void
 1052: instruction_static(struct_processus *s_etat_processus)
 1053: {
 1054:     (*s_etat_processus).erreur_execution = d_ex;
 1055: 
 1056:     if ((*s_etat_processus).affichage_arguments == 'Y')
 1057:     {
 1058:         printf("\n  STATIC ");
 1059: 
 1060:         if ((*s_etat_processus).langue == 'F')
 1061:         {
 1062:             printf("(déclaration de variables statiques)\n\n");
 1063:             printf("  Aucun argument\n");
 1064:         }
 1065:         else
 1066:         {
 1067:             printf("(static variables declaration)\n\n");
 1068:             printf("  No argument\n");
 1069:         }
 1070: 
 1071:         return;
 1072:     }
 1073:     else if ((*s_etat_processus).test_instruction == 'Y')
 1074:     {
 1075:         (*s_etat_processus).nombre_arguments = -1;
 1076:         return;
 1077:     }
 1078:     
 1079:     if (test_cfsf(s_etat_processus, 31) == d_vrai)
 1080:     {
 1081:         if (empilement_pile_last(s_etat_processus, 0) == d_erreur)
 1082:         {
 1083:             return;
 1084:         }
 1085:     }
 1086: 
 1087:     if ((*s_etat_processus).creation_variables_partagees == d_vrai)
 1088:     {
 1089:         (*s_etat_processus).erreur_execution = d_ex_variable_statique_partagee;
 1090:         return;
 1091:     }
 1092: 
 1093:     (*s_etat_processus).creation_variables_statiques = d_vrai;
 1094: 
 1095:     return;
 1096: }
 1097: 
 1098: 
 1099: /*
 1100: ================================================================================
 1101:   Fonction 'shared'
 1102: ================================================================================
 1103:   Entrées : structure processus
 1104: --------------------------------------------------------------------------------
 1105:   Sorties :
 1106: --------------------------------------------------------------------------------
 1107:   Effets de bord : néant
 1108: ================================================================================
 1109: */
 1110: 
 1111: void
 1112: instruction_shared(struct_processus *s_etat_processus)
 1113: {
 1114:     (*s_etat_processus).erreur_execution = d_ex;
 1115: 
 1116:     if ((*s_etat_processus).affichage_arguments == 'Y')
 1117:     {
 1118:         printf("\n  SHARED ");
 1119: 
 1120:         if ((*s_etat_processus).langue == 'F')
 1121:         {
 1122:             printf("(déclaration de variables partagées)\n\n");
 1123:             printf("  Aucun argument\n");
 1124:         }
 1125:         else
 1126:         {
 1127:             printf("(shared variables declaration)\n\n");
 1128:             printf("  No argument\n");
 1129:         }
 1130: 
 1131:         return;
 1132:     }
 1133:     else if ((*s_etat_processus).test_instruction == 'Y')
 1134:     {
 1135:         (*s_etat_processus).nombre_arguments = -1;
 1136:         return;
 1137:     }
 1138:     
 1139:     if (test_cfsf(s_etat_processus, 31) == d_vrai)
 1140:     {
 1141:         if (empilement_pile_last(s_etat_processus, 0) == d_erreur)
 1142:         {
 1143:             return;
 1144:         }
 1145:     }
 1146: 
 1147:     if ((*s_etat_processus).creation_variables_partagees == d_vrai)
 1148:     {
 1149:         (*s_etat_processus).erreur_execution = d_ex_variable_statique_partagee;
 1150:         return;
 1151:     }
 1152: 
 1153:     (*s_etat_processus).creation_variables_partagees = d_vrai;
 1154: 
 1155:     return;
 1156: }
 1157: 
 1158: 
 1159: /*
 1160: ================================================================================
 1161:   Fonction 'stoswi'
 1162: ================================================================================
 1163:   Entrées : structure processus
 1164: --------------------------------------------------------------------------------
 1165:   Sorties :
 1166: --------------------------------------------------------------------------------
 1167:   Effets de bord : néant
 1168: ================================================================================
 1169: */
 1170: 
 1171: void
 1172: instruction_stoswi(struct_processus *s_etat_processus)
 1173: {
 1174:     integer8                    interruption;
 1175: 
 1176:     struct_objet                *s_objet_argument_1;
 1177:     struct_objet                *s_objet_argument_2;
 1178: 
 1179:     (*s_etat_processus).erreur_execution = d_ex;
 1180: 
 1181:     if ((*s_etat_processus).affichage_arguments == 'Y')
 1182:     {
 1183:         printf("\n  STOSWI ");
 1184: 
 1185:         if ((*s_etat_processus).langue == 'F')
 1186:         {
 1187:             printf("(définition d'une interruption logicielle)\n\n");
 1188:         }
 1189:         else
 1190:         {
 1191:             printf("(software interrupt definition)\n\n");
 1192:         }
 1193: 
 1194:         printf("    2: %s, %s\n", d_NOM, d_RPN);
 1195:         printf("    1: %s\n", d_INT);
 1196: 
 1197:         return;
 1198:     }
 1199:     else if ((*s_etat_processus).test_instruction == 'Y')
 1200:     {
 1201:         (*s_etat_processus).nombre_arguments = -1;
 1202:         return;
 1203:     }
 1204: 
 1205:     if (test_cfsf(s_etat_processus, 31) == d_vrai)
 1206:     {
 1207:         if (empilement_pile_last(s_etat_processus, 2) == d_erreur)
 1208:         {
 1209:             return;
 1210:         }
 1211:     }
 1212: 
 1213:     if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
 1214:             &s_objet_argument_1) == d_erreur)
 1215:     {
 1216:         (*s_etat_processus).erreur_execution = d_ex_manque_argument;
 1217:         return;
 1218:     }
 1219: 
 1220:     if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
 1221:             &s_objet_argument_2) == d_erreur)
 1222:     {
 1223:         liberation(s_etat_processus, s_objet_argument_1);
 1224: 
 1225:         (*s_etat_processus).erreur_execution = d_ex_manque_argument;
 1226:         return;
 1227:     }
 1228: 
 1229:     if ((*s_objet_argument_1).type == INT)
 1230:     {
 1231:         interruption = (*((integer8 *) (*s_objet_argument_1).objet));
 1232: 
 1233:         if ((interruption < 1) || (interruption > d_NOMBRE_INTERRUPTIONS))
 1234:         {
 1235:             liberation(s_etat_processus, s_objet_argument_1);
 1236:             liberation(s_etat_processus, s_objet_argument_2);
 1237: 
 1238:             (*s_etat_processus).erreur_execution = d_ex_interruption_invalide;
 1239:             return;
 1240:         }
 1241: 
 1242:         if ((*s_objet_argument_2).type == NOM)
 1243:         {
 1244:             liberation(s_etat_processus, (*s_etat_processus).corps_interruptions
 1245:                     [interruption - 1]);
 1246:             (*s_etat_processus).corps_interruptions[interruption - 1] =
 1247:                     s_objet_argument_2;
 1248:         }
 1249:         else if((*s_objet_argument_2).type == RPN)
 1250:         {
 1251:             liberation(s_etat_processus, (*s_etat_processus).corps_interruptions
 1252:                     [interruption - 1]);
 1253:             (*s_etat_processus).corps_interruptions[interruption - 1] =
 1254:                     s_objet_argument_2;
 1255:         }
 1256:         else
 1257:         {
 1258:             liberation(s_etat_processus, s_objet_argument_1);
 1259:             liberation(s_etat_processus, s_objet_argument_2);
 1260: 
 1261:             (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
 1262:             return;
 1263:         }
 1264:     }
 1265:     else
 1266:     {
 1267:         liberation(s_etat_processus, s_objet_argument_1);
 1268:         liberation(s_etat_processus, s_objet_argument_2);
 1269: 
 1270:         (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
 1271:         return;
 1272:     }
 1273: 
 1274:     liberation(s_etat_processus, s_objet_argument_1);
 1275: 
 1276:     return;
 1277: }
 1278: 
 1279: 
 1280: /*
 1281: ================================================================================
 1282:   Fonction 'swi'
 1283: ================================================================================
 1284:   Entrées : structure processus
 1285: --------------------------------------------------------------------------------
 1286:   Sorties :
 1287: --------------------------------------------------------------------------------
 1288:   Effets de bord : néant
 1289: ================================================================================
 1290: */
 1291: 
 1292: void
 1293: instruction_swi(struct_processus *s_etat_processus)
 1294: {
 1295:     int                         interruption_reduite;
 1296: 
 1297:     integer8                    interruption;
 1298: 
 1299:     pid_t                       pid;
 1300: 
 1301:     pthread_t                   tid;
 1302: 
 1303:     sig_atomic_t                registre;
 1304: 
 1305:     ssize_t                     longueur_ecriture;
 1306: 
 1307:     struct_objet                *s_objet_argument;
 1308: 
 1309:     struct timespec             attente;
 1310: 
 1311:     unsigned char               tampon;
 1312: 
 1313:     (*s_etat_processus).erreur_execution = d_ex;
 1314: 
 1315:     if ((*s_etat_processus).affichage_arguments == 'Y')
 1316:     {
 1317:         printf("\n  SWI ");
 1318: 
 1319:         if ((*s_etat_processus).langue == 'F')
 1320:         {
 1321:             printf("(interruption logicielle)\n\n");
 1322:         }
 1323:         else
 1324:         {
 1325:             printf("(software interrupt)\n\n");
 1326:         }
 1327: 
 1328:         printf("    1: %s\n", d_INT);
 1329: 
 1330:         return;
 1331:     }
 1332:     else if ((*s_etat_processus).test_instruction == 'Y')
 1333:     {
 1334:         (*s_etat_processus).nombre_arguments = -1;
 1335:         return;
 1336:     }
 1337: 
 1338:     if (test_cfsf(s_etat_processus, 31) == d_vrai)
 1339:     {
 1340:         if (empilement_pile_last(s_etat_processus, 1) == d_erreur)
 1341:         {
 1342:             return;
 1343:         }
 1344:     }
 1345: 
 1346:     if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
 1347:             &s_objet_argument) == d_erreur)
 1348:     {
 1349:         (*s_etat_processus).erreur_execution = d_ex_manque_argument;
 1350:         return;
 1351:     }
 1352: 
 1353:     if ((*s_objet_argument).type == INT)
 1354:     {
 1355:         interruption = (*((integer8 *) (*s_objet_argument).objet));
 1356: 
 1357:         if ((interruption < 1) || (interruption > d_NOMBRE_INTERRUPTIONS))
 1358:         {
 1359:             liberation(s_etat_processus, s_objet_argument);
 1360: 
 1361:             (*s_etat_processus).erreur_execution = d_ex_interruption_invalide;
 1362:             return;
 1363:         }
 1364: 
 1365:         if ((*s_etat_processus).presence_pipes == d_faux)
 1366:         {
 1367:             liberation(s_etat_processus, s_objet_argument);
 1368: 
 1369:             (*s_etat_processus).erreur_execution = d_ex_absence_processus_pere;
 1370:             return;
 1371:         }
 1372: 
 1373:         // Envoi d'un PID invalide (-1) pour ne pas bloquer le thread
 1374:         // de surveillance.
 1375: 
 1376:         registre = (*s_etat_processus).var_volatile_traitement_retarde_stop;
 1377:         (*s_etat_processus).var_volatile_traitement_retarde_stop = 1;
 1378: 
 1379:         if ((*s_etat_processus).processus_detache == d_vrai)
 1380:         {
 1381:             pid = -1;
 1382: 
 1383:             attente.tv_sec = 0;
 1384:             attente.tv_nsec = GRANULARITE_us * 1000;
 1385: 
 1386: #           ifndef SEMAPHORES_NOMMES
 1387:             if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0)
 1388:             {
 1389:                 (*s_etat_processus).erreur_systeme = d_es_processus;
 1390:                 return;
 1391:             }
 1392: #           else
 1393:             if (sem_post((*s_etat_processus).semaphore_fork) != 0)
 1394:             {
 1395:                 (*s_etat_processus).erreur_systeme = d_es_processus;
 1396:                 return;
 1397:             }
 1398: #           endif
 1399: 
 1400:             while((longueur_ecriture = write_atomic(s_etat_processus,
 1401:                     (*s_etat_processus).pipe_nombre_objets_attente,
 1402:                     &pid, sizeof(pid))) != sizeof(pid))
 1403:             {
 1404: #               ifndef SEMAPHORES_NOMMES
 1405:                 while(sem_wait(&((*s_etat_processus).semaphore_fork)) == -1)
 1406: #               else
 1407:                 while(sem_wait((*s_etat_processus).semaphore_fork) == -1)
 1408: #               endif
 1409:                 {
 1410:                     if (errno != EINTR)
 1411:                     {
 1412:                         (*s_etat_processus).erreur_systeme = d_es_processus;
 1413:                         return;
 1414:                     }
 1415:                 }
 1416: 
 1417:                 if (longueur_ecriture == -1)
 1418:                 {
 1419:                     if (registre == 0)
 1420:                     {
 1421:                         if ((*s_etat_processus)
 1422:                                 .var_volatile_traitement_retarde_stop == -1)
 1423:                         {
 1424:                             (*s_etat_processus).var_volatile_requete_arret = -1;
 1425:                         }
 1426: 
 1427:                         (*s_etat_processus)
 1428:                                 .var_volatile_traitement_retarde_stop
 1429:                                 = registre;
 1430:                     }
 1431: 
 1432:                     (*s_etat_processus).erreur_systeme = d_es_processus;
 1433:                     return;
 1434:                 }
 1435: 
 1436:                 nanosleep(&attente, NULL);
 1437:                 INCR_GRANULARITE(attente.tv_nsec);
 1438: 
 1439: #               ifndef SEMAPHORES_NOMMES
 1440:                 if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0)
 1441: #               else
 1442:                 if (sem_post((*s_etat_processus).semaphore_fork) != 0)
 1443: #               endif
 1444:                 {
 1445:                     (*s_etat_processus).erreur_systeme = d_es_processus;
 1446:                     return;
 1447:                 }
 1448:             }
 1449: 
 1450: #           ifndef SEMAPHORES_NOMMES
 1451:             while(sem_wait(&((*s_etat_processus).semaphore_fork)) == -1)
 1452: #           else
 1453:             while(sem_wait((*s_etat_processus).semaphore_fork) == -1)
 1454: #           endif
 1455:             {
 1456:                 if (errno != EINTR)
 1457:                 {
 1458:                     (*s_etat_processus).erreur_systeme = d_es_processus;
 1459:                     return;
 1460:                 }
 1461:             }
 1462:         }
 1463:         else
 1464:         {
 1465:             tid = -1;
 1466: 
 1467:             attente.tv_sec = 0;
 1468:             attente.tv_nsec = GRANULARITE_us * 1000;
 1469: 
 1470: #           ifndef SEMAPHORES_NOMMES
 1471:             if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0)
 1472:             {
 1473:                 (*s_etat_processus).erreur_systeme = d_es_processus;
 1474:                 return;
 1475:             }
 1476: #           else
 1477:             if (sem_post((*s_etat_processus).semaphore_fork) != 0)
 1478:             {
 1479:                 (*s_etat_processus).erreur_systeme = d_es_processus;
 1480:                 return;
 1481:             }
 1482: #           endif
 1483: 
 1484:             while((longueur_ecriture = write_atomic(s_etat_processus,
 1485:                     (*s_etat_processus).pipe_nombre_objets_attente,
 1486:                     &tid, sizeof(tid))) != sizeof(tid))
 1487:             {
 1488: #               ifndef SEMAPHORES_NOMMES
 1489:                 while(sem_wait(&((*s_etat_processus).semaphore_fork)) == -1)
 1490: #               else
 1491:                 while(sem_wait((*s_etat_processus).semaphore_fork) == -1)
 1492: #               endif
 1493:                 {
 1494:                     if (errno != EINTR)
 1495:                     {
 1496:                         (*s_etat_processus).erreur_systeme = d_es_processus;
 1497:                         return;
 1498:                     }
 1499:                 }
 1500: 
 1501:                 if (longueur_ecriture == -1)
 1502:                 {
 1503:                     if (registre == 0)
 1504:                     {
 1505:                         if ((*s_etat_processus)
 1506:                                 .var_volatile_traitement_retarde_stop == -1)
 1507:                         {
 1508:                             (*s_etat_processus).var_volatile_requete_arret = -1;
 1509:                         }
 1510: 
 1511:                         (*s_etat_processus)
 1512:                                 .var_volatile_traitement_retarde_stop
 1513:                                 = registre;
 1514:                     }
 1515: 
 1516:                     (*s_etat_processus).erreur_systeme = d_es_processus;
 1517:                     return;
 1518:                 }
 1519: 
 1520:                 nanosleep(&attente, NULL);
 1521:                 INCR_GRANULARITE(attente.tv_nsec);
 1522: 
 1523: #               ifndef SEMAPHORES_NOMMES
 1524:                 if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0)
 1525:                 {
 1526:                     (*s_etat_processus).erreur_systeme = d_es_processus;
 1527:                     return;
 1528:                 }
 1529: #               else
 1530:                 if (sem_post((*s_etat_processus).semaphore_fork) != 0)
 1531:                 {
 1532:                     (*s_etat_processus).erreur_systeme = d_es_processus;
 1533:                     return;
 1534:                 }
 1535: #               endif
 1536:             }
 1537: 
 1538: #           ifndef SEMAPHORES_NOMMES
 1539:             while(sem_wait(&((*s_etat_processus).semaphore_fork)) == -1)
 1540: #           else
 1541:             while(sem_wait((*s_etat_processus).semaphore_fork) == -1)
 1542: #           endif
 1543:             {
 1544:                 if (errno != EINTR)
 1545:                 {
 1546:                     (*s_etat_processus).erreur_systeme = d_es_processus;
 1547:                     return;
 1548:                 }
 1549:             }
 1550:         }
 1551: 
 1552:         interruption_reduite = interruption;
 1553: 
 1554:         attente.tv_sec = 0;
 1555:         attente.tv_nsec = GRANULARITE_us * 1000;
 1556: 
 1557: #       ifndef SEMAPHORES_NOMMES
 1558:         if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0)
 1559:         {
 1560:             (*s_etat_processus).erreur_systeme = d_es_processus;
 1561:             return;
 1562:         }
 1563: #       else
 1564:         if (sem_post((*s_etat_processus).semaphore_fork) != 0)
 1565:         {
 1566:             (*s_etat_processus).erreur_systeme = d_es_processus;
 1567:             return;
 1568:         }
 1569: #       endif
 1570: 
 1571:         while((longueur_ecriture = write_atomic(s_etat_processus,
 1572:                 (*s_etat_processus).pipe_interruptions,
 1573:                 &interruption_reduite, sizeof(interruption_reduite)))
 1574:                 != sizeof(interruption_reduite))
 1575:         {
 1576: #           ifndef SEMAPHORES_NOMMES
 1577:             while(sem_wait(&((*s_etat_processus).semaphore_fork)) == -1)
 1578: #           else
 1579:             while(sem_wait((*s_etat_processus).semaphore_fork) == -1)
 1580: #           endif
 1581:             {
 1582:                 if (errno != EINTR)
 1583:                 {
 1584:                     (*s_etat_processus).erreur_systeme = d_es_processus;
 1585:                     return;
 1586:                 }
 1587:             }
 1588: 
 1589:             if (longueur_ecriture == -1)
 1590:             {
 1591:                 if (registre == 0)
 1592:                 {
 1593:                     if ((*s_etat_processus)
 1594:                             .var_volatile_traitement_retarde_stop == -1)
 1595:                     {
 1596:                         (*s_etat_processus).var_volatile_requete_arret = -1;
 1597:                     }
 1598: 
 1599:                     (*s_etat_processus)
 1600:                             .var_volatile_traitement_retarde_stop
 1601:                             = registre;
 1602:                 }
 1603: 
 1604:                 (*s_etat_processus).erreur_systeme = d_es_processus;
 1605:                 return;
 1606:             }
 1607: 
 1608:             nanosleep(&attente, NULL);
 1609:             INCR_GRANULARITE(attente.tv_nsec);
 1610: 
 1611: #           ifndef SEMAPHORES_NOMMES
 1612:             if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0)
 1613:             {
 1614:                 (*s_etat_processus).erreur_systeme = d_es_processus;
 1615:                 return;
 1616:             }
 1617: #           else
 1618:             if (sem_post((*s_etat_processus).semaphore_fork) != 0)
 1619:             {
 1620:                 (*s_etat_processus).erreur_systeme = d_es_processus;
 1621:                 return;
 1622:             }
 1623: #           endif
 1624:         }
 1625: 
 1626: #       ifndef SEMAPHORES_NOMMES
 1627:         while(sem_wait(&((*s_etat_processus).semaphore_fork)) == -1)
 1628: #       else
 1629:         while(sem_wait((*s_etat_processus).semaphore_fork) == -1)
 1630: #       endif
 1631:         {
 1632:             if (errno != EINTR)
 1633:             {
 1634:                 (*s_etat_processus).erreur_systeme = d_es_processus;
 1635:                 return;
 1636:             }
 1637:         }
 1638: 
 1639:         if ((*s_etat_processus).processus_detache == d_vrai)
 1640:         {
 1641:             pid = -3;
 1642: 
 1643:             attente.tv_sec = 0;
 1644:             attente.tv_nsec = GRANULARITE_us * 1000;
 1645: 
 1646: #           ifndef SEMAPHORES_NOMMES
 1647:             if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0)
 1648:             {
 1649:                 (*s_etat_processus).erreur_systeme = d_es_processus;
 1650:                 return;
 1651:             }
 1652: #           else
 1653:             if (sem_post((*s_etat_processus).semaphore_fork) != 0)
 1654:             {
 1655:                 (*s_etat_processus).erreur_systeme = d_es_processus;
 1656:                 return;
 1657:             }
 1658: #           endif
 1659: 
 1660:             while((longueur_ecriture = write_atomic(s_etat_processus,
 1661:                     (*s_etat_processus).pipe_nombre_interruptions_attente,
 1662:                     &pid, sizeof(pid))) != sizeof(pid))
 1663:             {
 1664: #               ifndef SEMAPHORES_NOMMES
 1665:                 while(sem_wait(&((*s_etat_processus).semaphore_fork)) == -1)
 1666: #               else
 1667:                 while(sem_wait((*s_etat_processus).semaphore_fork) == -1)
 1668: #               endif
 1669:                 {
 1670:                     (*s_etat_processus).erreur_systeme = d_es_processus;
 1671:                     return;
 1672:                 }
 1673: 
 1674:                 if (longueur_ecriture == -1)
 1675:                 {
 1676:                     if (registre == 0)
 1677:                     {
 1678:                         if ((*s_etat_processus)
 1679:                                 .var_volatile_traitement_retarde_stop == -1)
 1680:                         {
 1681:                             (*s_etat_processus).var_volatile_requete_arret = -1;
 1682:                         }
 1683: 
 1684:                         (*s_etat_processus)
 1685:                                 .var_volatile_traitement_retarde_stop
 1686:                                 = registre;
 1687:                     }
 1688: 
 1689:                     (*s_etat_processus).erreur_systeme = d_es_processus;
 1690:                     return;
 1691:                 }
 1692: 
 1693:                 nanosleep(&attente, NULL);
 1694:                 INCR_GRANULARITE(attente.tv_nsec);
 1695: 
 1696: #               ifndef SEMAPHORES_NOMMES
 1697:                 if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0)
 1698:                 {
 1699:                     (*s_etat_processus).erreur_systeme = d_es_processus;
 1700:                     return;
 1701:                 }
 1702: #               else
 1703:                 if (sem_post((*s_etat_processus).semaphore_fork) != 0)
 1704:                 {
 1705:                     (*s_etat_processus).erreur_systeme = d_es_processus;
 1706:                     return;
 1707:                 }
 1708: #               endif
 1709:             }
 1710: 
 1711:             pid = getpid();
 1712: 
 1713:             attente.tv_sec = 0;
 1714:             attente.tv_nsec = GRANULARITE_us * 1000;
 1715: 
 1716:             while((longueur_ecriture = write_atomic(s_etat_processus,
 1717:                     (*s_etat_processus).pipe_nombre_interruptions_attente,
 1718:                     &pid, sizeof(pid))) != sizeof(pid))
 1719:             {
 1720: #               ifndef SEMAPHORES_NOMMES
 1721:                 while(sem_wait(&((*s_etat_processus).semaphore_fork)) == -1)
 1722: #               else
 1723:                 while(sem_wait((*s_etat_processus).semaphore_fork) == -1)
 1724: #               endif
 1725:                 {
 1726:                     if (errno != EINTR)
 1727:                     {
 1728:                         (*s_etat_processus).erreur_systeme = d_es_processus;
 1729:                         return;
 1730:                     }
 1731:                 }
 1732: 
 1733:                 if (longueur_ecriture == -1)
 1734:                 {
 1735:                     if (registre == 0)
 1736:                     {
 1737:                         if ((*s_etat_processus)
 1738:                                 .var_volatile_traitement_retarde_stop == -1)
 1739:                         {
 1740:                             (*s_etat_processus).var_volatile_requete_arret = -1;
 1741:                         }
 1742: 
 1743:                         (*s_etat_processus)
 1744:                                 .var_volatile_traitement_retarde_stop
 1745:                                 = registre;
 1746:                     }
 1747: 
 1748:                     (*s_etat_processus).erreur_systeme = d_es_processus;
 1749:                     return;
 1750:                 }
 1751: 
 1752:                 nanosleep(&attente, NULL);
 1753:                 INCR_GRANULARITE(attente.tv_nsec);
 1754: 
 1755: #               ifndef SEMAPHORES_NOMMES
 1756:                 if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0)
 1757:                 {
 1758:                     (*s_etat_processus).erreur_systeme = d_es_processus;
 1759:                     return;
 1760:                 }
 1761: #               else
 1762:                 if (sem_post((*s_etat_processus).semaphore_fork) != 0)
 1763:                 {
 1764:                     (*s_etat_processus).erreur_systeme = d_es_processus;
 1765:                     return;
 1766:                 }
 1767: #               endif
 1768:             }
 1769: 
 1770: #           ifndef SEMAPHORES_NOMMES
 1771:             while(sem_wait(&((*s_etat_processus).semaphore_fork)) == -1)
 1772: #           else
 1773:             while(sem_wait((*s_etat_processus).semaphore_fork) == -1)
 1774: #           endif
 1775:             {
 1776:                 if (errno != EINTR)
 1777:                 {
 1778:                     (*s_etat_processus).erreur_systeme = d_es_processus;
 1779:                     return;
 1780:                 }
 1781:             }
 1782:         }
 1783:         else
 1784:         {
 1785:             tid = -3;
 1786: 
 1787: #           ifndef SEMAPHORES_NOMMES
 1788:             if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0)
 1789:             {
 1790:                 (*s_etat_processus).erreur_systeme = d_es_processus;
 1791:                 return;
 1792:             }
 1793: #           else
 1794:             if (sem_post((*s_etat_processus).semaphore_fork) != 0)
 1795:             {
 1796:                 (*s_etat_processus).erreur_systeme = d_es_processus;
 1797:                 return;
 1798:             }
 1799: #           endif
 1800: 
 1801:             while((longueur_ecriture = write_atomic(s_etat_processus,
 1802:                     (*s_etat_processus).pipe_nombre_interruptions_attente,
 1803:                     &tid, sizeof(tid))) != sizeof(tid))
 1804:             {
 1805: #               ifndef SEMAPHORES_NOMMES
 1806:                 while(sem_wait(&((*s_etat_processus).semaphore_fork)) == -1)
 1807: #               else
 1808:                 while(sem_wait((*s_etat_processus).semaphore_fork) == -1)
 1809: #               endif
 1810:                 {
 1811:                     if (errno != EINTR)
 1812:                     {
 1813:                         (*s_etat_processus).erreur_systeme = d_es_processus;
 1814:                         return;
 1815:                     }
 1816:                 }
 1817: 
 1818:                 if (longueur_ecriture == -1)
 1819:                 {
 1820:                     if (registre == 0)
 1821:                     {
 1822:                         if ((*s_etat_processus)
 1823:                                 .var_volatile_traitement_retarde_stop == -1)
 1824:                         {
 1825:                             (*s_etat_processus).var_volatile_requete_arret = -1;
 1826:                         }
 1827: 
 1828:                         (*s_etat_processus)
 1829:                                 .var_volatile_traitement_retarde_stop
 1830:                                 = registre;
 1831:                     }
 1832: 
 1833:                     (*s_etat_processus).erreur_systeme = d_es_processus;
 1834:                     return;
 1835:                 }
 1836: 
 1837:                 nanosleep(&attente, NULL);
 1838:                 INCR_GRANULARITE(attente.tv_nsec);
 1839: 
 1840: #               ifndef SEMAPHORES_NOMMES
 1841:                 if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0)
 1842:                 {
 1843:                     (*s_etat_processus).erreur_systeme = d_es_processus;
 1844:                     return;
 1845:                 }
 1846: #               else
 1847:                 if (sem_post((*s_etat_processus).semaphore_fork) != 0)
 1848:                 {
 1849:                     (*s_etat_processus).erreur_systeme = d_es_processus;
 1850:                     return;
 1851:                 }
 1852: #               endif
 1853:             }
 1854: 
 1855:             tid = pthread_self();
 1856: 
 1857:             attente.tv_sec = 0;
 1858:             attente.tv_nsec = GRANULARITE_us * 1000;
 1859: 
 1860:             while((longueur_ecriture = write_atomic(s_etat_processus,
 1861:                     (*s_etat_processus).pipe_nombre_interruptions_attente,
 1862:                     &tid, sizeof(tid))) != sizeof(tid))
 1863:             {
 1864: #               ifndef SEMAPHORES_NOMMES
 1865:                 while(sem_wait(&((*s_etat_processus).semaphore_fork)) == -1)
 1866: #               else
 1867:                 while(sem_wait((*s_etat_processus).semaphore_fork) == -1)
 1868: #               endif
 1869:                 {
 1870:                     if (errno != EINTR)
 1871:                     {
 1872:                         (*s_etat_processus).erreur_systeme = d_es_processus;
 1873:                         return;
 1874:                     }
 1875:                 }
 1876: 
 1877:                 if (longueur_ecriture == -1)
 1878: 
 1879:                 {
 1880:                     if (registre == 0)
 1881:                     {
 1882:                         if ((*s_etat_processus)
 1883:                                 .var_volatile_traitement_retarde_stop == -1)
 1884:                         {
 1885:                             (*s_etat_processus).var_volatile_requete_arret = -1;
 1886:                         }
 1887: 
 1888:                         (*s_etat_processus)
 1889:                                 .var_volatile_traitement_retarde_stop
 1890:                                 = registre;
 1891:                     }
 1892: 
 1893:                     (*s_etat_processus).erreur_systeme = d_es_processus;
 1894:                     return;
 1895:                 }
 1896: 
 1897:                 nanosleep(&attente, NULL);
 1898:                 INCR_GRANULARITE(attente.tv_nsec);
 1899: 
 1900: #               ifndef SEMAPHORES_NOMMES
 1901:                 if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0)
 1902:                 {
 1903:                     (*s_etat_processus).erreur_systeme = d_es_processus;
 1904:                     return;
 1905:                 }
 1906: #               else
 1907:                 if (sem_post((*s_etat_processus).semaphore_fork) != 0)
 1908:                 {
 1909:                     (*s_etat_processus).erreur_systeme = d_es_processus;
 1910:                     return;
 1911:                 }
 1912: #               endif
 1913:             }
 1914: 
 1915: #           ifndef SEMAPHORES_NOMMES
 1916:             while(sem_wait(&((*s_etat_processus).semaphore_fork)) == -1)
 1917: #           else
 1918:             while(sem_wait((*s_etat_processus).semaphore_fork) == -1)
 1919: #           endif
 1920:             {
 1921:                 if (errno != EINTR)
 1922:                 {
 1923:                     (*s_etat_processus).erreur_systeme = d_es_processus;
 1924:                     return;
 1925:                 }
 1926:             }
 1927:         }
 1928: 
 1929:         attente.tv_sec = 0;
 1930:         attente.tv_nsec = GRANULARITE_us * 1000;
 1931: 
 1932: #       ifndef SEMAPHORES_NOMMES
 1933:         if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0)
 1934:         {
 1935:             (*s_etat_processus).erreur_systeme = d_es_processus;
 1936:             return;
 1937:         }
 1938: #       else
 1939:         if (sem_post((*s_etat_processus).semaphore_fork) != 0)
 1940:         {
 1941:             (*s_etat_processus).erreur_systeme = d_es_processus;
 1942:             return;
 1943:         }
 1944: #       endif
 1945: 
 1946:         while(read_atomic(s_etat_processus,
 1947:                 (*s_etat_processus).pipe_acquittement,
 1948:                 &tampon, sizeof(unsigned char)) != sizeof(unsigned char))
 1949:         {
 1950: #           ifndef SEMAPHORES_NOMMES
 1951:             while(sem_wait(&((*s_etat_processus).semaphore_fork)) == -1)
 1952: #           else
 1953:             while(sem_wait((*s_etat_processus).semaphore_fork) == -1)
 1954: #           endif
 1955:             {
 1956:                 if (errno != EINTR)
 1957:                 {
 1958:                     (*s_etat_processus).erreur_systeme = d_es_processus;
 1959:                     return;
 1960:                 }
 1961:             }
 1962: 
 1963:             nanosleep(&attente, NULL);
 1964:             INCR_GRANULARITE(attente.tv_nsec);
 1965: 
 1966: #           ifndef SEMAPHORES_NOMMES
 1967:             if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0)
 1968: #           else
 1969:             if (sem_post((*s_etat_processus).semaphore_fork) != 0)
 1970: #           endif
 1971:             {
 1972:                 (*s_etat_processus).erreur_systeme = d_es_processus;
 1973:                 return;
 1974:             }
 1975:         }
 1976: 
 1977: #       ifndef SEMAPHORES_NOMMES
 1978:         while(sem_wait(&((*s_etat_processus).semaphore_fork)) == -1)
 1979: #       else
 1980:         while(sem_wait((*s_etat_processus).semaphore_fork) == -1)
 1981: #       endif
 1982:         {
 1983:             if (errno != EINTR)
 1984:             {
 1985:                 (*s_etat_processus).erreur_systeme = d_es_processus;
 1986:                 return;
 1987:             }
 1988:         }
 1989: 
 1990:         if (registre == 0)
 1991:         {
 1992:             if ((*s_etat_processus).var_volatile_traitement_retarde_stop == -1)
 1993:             {
 1994:                 (*s_etat_processus).var_volatile_requete_arret = -1;
 1995:             }
 1996: 
 1997:             (*s_etat_processus).var_volatile_traitement_retarde_stop = registre;
 1998:         }
 1999:     }
 2000:     else
 2001:     {
 2002:         liberation(s_etat_processus, s_objet_argument);
 2003: 
 2004:         (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
 2005:         return;
 2006:     }
 2007: 
 2008:     liberation(s_etat_processus, s_objet_argument);
 2009: 
 2010:     return;
 2011: }
 2012: 
 2013: 
 2014: /*
 2015: ================================================================================
 2016:   Fonction 'swilock'
 2017: ================================================================================
 2018:   Entrées : structure processus
 2019: --------------------------------------------------------------------------------
 2020:   Sorties :
 2021: --------------------------------------------------------------------------------
 2022:   Effets de bord : néant
 2023: ================================================================================
 2024: */
 2025: 
 2026: void
 2027: instruction_swilock(struct_processus *s_etat_processus)
 2028: {
 2029:     integer8                    interruption;
 2030: 
 2031:     struct_liste_chainee        *l_element_courant;
 2032: 
 2033:     struct_objet                *s_objet_argument;
 2034: 
 2035:     (*s_etat_processus).erreur_execution = d_ex;
 2036: 
 2037:     if ((*s_etat_processus).affichage_arguments == 'Y')
 2038:     {
 2039:         printf("\n  SWILOCK ");
 2040: 
 2041:         if ((*s_etat_processus).langue == 'F')
 2042:         {
 2043:             printf("(verrouillage des interruptions logicielles)\n\n");
 2044:         }
 2045:         else
 2046:         {
 2047:             printf("(software interrupt lock)\n\n");
 2048:         }
 2049: 
 2050:         printf("    1: %s, %s\n", d_INT, d_LST);
 2051: 
 2052:         return;
 2053:     }
 2054:     else if ((*s_etat_processus).test_instruction == 'Y')
 2055:     {
 2056:         (*s_etat_processus).nombre_arguments = -1;
 2057:         return;
 2058:     }
 2059: 
 2060:     if (test_cfsf(s_etat_processus, 31) == d_vrai)
 2061:     {
 2062:         if (empilement_pile_last(s_etat_processus, 1) == d_erreur)
 2063:         {
 2064:             return;
 2065:         }
 2066:     }
 2067: 
 2068:     if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
 2069:             &s_objet_argument) == d_erreur)
 2070:     {
 2071:         (*s_etat_processus).erreur_execution = d_ex_manque_argument;
 2072:         return;
 2073:     }
 2074: 
 2075:     if ((*s_objet_argument).type == INT)
 2076:     {
 2077:         interruption = (*((integer8 *) (*s_objet_argument).objet));
 2078: 
 2079:         if ((interruption < 1) || (interruption > d_NOMBRE_INTERRUPTIONS))
 2080:         {
 2081:             liberation(s_etat_processus, s_objet_argument);
 2082: 
 2083:             (*s_etat_processus).erreur_execution = d_ex_interruption_invalide;
 2084:             return;
 2085:         }
 2086: 
 2087:         (*s_etat_processus).masque_interruptions[interruption - 1] = 'I';
 2088:     }
 2089:     else if ((*s_objet_argument).type == LST)
 2090:     {
 2091:         l_element_courant = (*s_objet_argument).objet;
 2092: 
 2093:         while(l_element_courant)
 2094:         {
 2095:             if ((*(*l_element_courant).donnee).type != INT)
 2096:             {
 2097:                 liberation(s_etat_processus, s_objet_argument);
 2098: 
 2099:                 (*s_etat_processus).erreur_execution =
 2100:                         d_ex_erreur_type_argument;
 2101:                 return;
 2102:             }
 2103: 
 2104:             interruption = (*((integer8 *) (*(*l_element_courant)
 2105:                     .donnee).objet));
 2106: 
 2107:             if ((interruption < 1) || (interruption > d_NOMBRE_INTERRUPTIONS))
 2108:             {
 2109:                 liberation(s_etat_processus, s_objet_argument);
 2110: 
 2111:                 (*s_etat_processus).erreur_execution =
 2112:                         d_ex_interruption_invalide;
 2113:                 return;
 2114:             }
 2115: 
 2116:             (*s_etat_processus).masque_interruptions[interruption - 1] = 'I';
 2117:             l_element_courant = (*l_element_courant).suivant;
 2118:         }
 2119:     }
 2120:     else
 2121:     {
 2122:         liberation(s_etat_processus, s_objet_argument);
 2123: 
 2124:         (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
 2125:         return;
 2126:     }
 2127: 
 2128:     liberation(s_etat_processus, s_objet_argument);
 2129: 
 2130:     return;
 2131: }
 2132: 
 2133: 
 2134: /*
 2135: ================================================================================
 2136:   Fonction 'swistatus'
 2137: ================================================================================
 2138:   Entrées : structure processus
 2139: --------------------------------------------------------------------------------
 2140:   Sorties :
 2141: --------------------------------------------------------------------------------
 2142:   Effets de bord : néant
 2143: ================================================================================
 2144: */
 2145: 
 2146: void
 2147: instruction_swistatus(struct_processus *s_etat_processus)
 2148: {
 2149:     int                         i;
 2150: 
 2151:     struct_liste_chainee        *l_element_courant;
 2152:     struct_liste_chainee        *l_element_futur;
 2153:     struct_liste_chainee        *l_element_liste;
 2154: 
 2155:     struct_objet                *s_objet_resultat;
 2156: 
 2157:     (*s_etat_processus).erreur_execution = d_ex;
 2158: 
 2159:     if ((*s_etat_processus).affichage_arguments == 'Y')
 2160:     {
 2161:         printf("\n  SWISTATUS ");
 2162: 
 2163:         if ((*s_etat_processus).langue == 'F')
 2164:         {
 2165:             printf("(état des interruptions logicielles)\n\n");
 2166:         }
 2167:         else
 2168:         {
 2169:             printf("(software interrupts status)\n\n");
 2170:         }
 2171: 
 2172:         printf("->  1: %s\n\n", d_LST);
 2173: 
 2174:         if ((*s_etat_processus).langue == 'F')
 2175:         {
 2176:             printf("  Utilisation :\n\n");
 2177:         }
 2178:         else
 2179:         {
 2180:             printf("  Usage:\n\n");
 2181:         }
 2182: 
 2183:         printf("    { { initialized interrupts }\n"
 2184:                 "      { unlocked interrupts }\n"
 2185:                 "      { queued interrupts }\n"
 2186:                 "      { locked interrupts } }\n");
 2187:         return;
 2188:     }
 2189:     else if ((*s_etat_processus).test_instruction == 'Y')
 2190:     {
 2191:         (*s_etat_processus).nombre_arguments = -1;
 2192:         return;
 2193:     }
 2194: 
 2195:     if (test_cfsf(s_etat_processus, 31) == d_vrai)
 2196:     {
 2197:         if (empilement_pile_last(s_etat_processus, 0) == d_erreur)
 2198:         {
 2199:             return;
 2200:         }
 2201:     }
 2202: 
 2203:     if ((s_objet_resultat = allocation(s_etat_processus, LST)) == NULL)
 2204:     {
 2205:         (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
 2206:         return;
 2207:     }
 2208: 
 2209:     if (((*s_objet_resultat).objet =
 2210:             allocation_maillon(s_etat_processus)) == NULL)
 2211:     {
 2212:         (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
 2213:         return;
 2214:     }
 2215: 
 2216:     l_element_courant = (struct_liste_chainee *) (*s_objet_resultat).objet;
 2217: 
 2218:     if (((*l_element_courant).donnee = allocation(s_etat_processus, LST))
 2219:             == NULL)
 2220:     {
 2221:         (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
 2222:         return;
 2223:     }
 2224: 
 2225:     l_element_liste = NULL;
 2226:     l_element_futur = NULL;
 2227: 
 2228:     for(i = 0; i < d_NOMBRE_INTERRUPTIONS; i++)
 2229:     {
 2230:         if ((*s_etat_processus).corps_interruptions[i] != NULL)
 2231:         {
 2232:             if (l_element_liste == NULL)
 2233:             {
 2234:                 if ((l_element_liste =
 2235:                         allocation_maillon(s_etat_processus)) == NULL)
 2236:                 {
 2237:                     (*s_etat_processus).erreur_systeme =
 2238:                             d_es_allocation_memoire;
 2239:                     return;
 2240:                 }
 2241: 
 2242:                 l_element_futur = l_element_liste;
 2243:             }
 2244:             else
 2245:             {
 2246:                 if (((*l_element_liste).suivant =
 2247:                         allocation_maillon(s_etat_processus)) == NULL)
 2248:                 {
 2249:                     (*s_etat_processus).erreur_systeme =
 2250:                             d_es_allocation_memoire;
 2251:                     return;
 2252:                 }
 2253: 
 2254:                 l_element_liste = (*l_element_liste).suivant;
 2255:             }
 2256: 
 2257:             (*l_element_liste).suivant = NULL;
 2258: 
 2259:             if (((*l_element_liste).donnee = allocation(s_etat_processus,
 2260:                     INT)) == NULL)
 2261:             {
 2262:                 (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
 2263:                 return;
 2264:             }
 2265: 
 2266:             (*((integer8 *) (*(*l_element_liste).donnee).objet)) = i + 1;
 2267:         }
 2268:     }
 2269: 
 2270:     (*(*l_element_courant).donnee).objet = l_element_futur;
 2271: 
 2272:     if (((*l_element_courant).suivant =
 2273:             allocation_maillon(s_etat_processus)) == NULL)
 2274:     {
 2275:         (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
 2276:         return;
 2277:     }
 2278: 
 2279:     l_element_courant = (*l_element_courant).suivant;
 2280: 
 2281:     if (((*l_element_courant).donnee = allocation(s_etat_processus, LST))
 2282:             == NULL)
 2283:     {
 2284:         (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
 2285:         return;
 2286:     }
 2287: 
 2288:     l_element_liste = NULL;
 2289:     l_element_futur = NULL;
 2290: 
 2291:     for(i = 0; i < d_NOMBRE_INTERRUPTIONS; i++)
 2292:     {
 2293:         if ((*s_etat_processus).masque_interruptions[i] == 'N')
 2294:         {
 2295:             if (l_element_liste == NULL)
 2296:             {
 2297:                 if ((l_element_liste =
 2298:                         allocation_maillon(s_etat_processus)) == NULL)
 2299:                 {
 2300:                     (*s_etat_processus).erreur_systeme =
 2301:                             d_es_allocation_memoire;
 2302:                     return;
 2303:                 }
 2304: 
 2305:                 l_element_futur = l_element_liste;
 2306:             }
 2307:             else
 2308:             {
 2309:                 if (((*l_element_liste).suivant =
 2310:                         allocation_maillon(s_etat_processus)) == NULL)
 2311:                 {
 2312:                     (*s_etat_processus).erreur_systeme =
 2313:                             d_es_allocation_memoire;
 2314:                     return;
 2315:                 }
 2316: 
 2317:                 l_element_liste = (*l_element_liste).suivant;
 2318:             }
 2319: 
 2320:             (*l_element_liste).suivant = NULL;
 2321: 
 2322:             if (((*l_element_liste).donnee = allocation(s_etat_processus,
 2323:                     INT)) == NULL)
 2324:             {
 2325:                 (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
 2326:                 return;
 2327:             }
 2328: 
 2329:             (*((integer8 *) (*(*l_element_liste).donnee).objet)) = i + 1;
 2330:         }
 2331:     }
 2332: 
 2333:     (*(*l_element_courant).donnee).objet = l_element_futur;
 2334: 
 2335:     if (((*l_element_courant).suivant = allocation_maillon(s_etat_processus))
 2336:             == NULL)
 2337:     {
 2338:         (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
 2339:         return;
 2340:     }
 2341: 
 2342:     l_element_courant = (*l_element_courant).suivant;
 2343: 
 2344:     if (((*l_element_courant).donnee = allocation(s_etat_processus, LST))
 2345:             == NULL)
 2346:     {
 2347:         (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
 2348:         return;
 2349:     }
 2350: 
 2351:     l_element_liste = NULL;
 2352:     l_element_futur = NULL;
 2353: 
 2354:     for(i = 0; i < d_NOMBRE_INTERRUPTIONS; i++)
 2355:     {
 2356:         if ((*s_etat_processus).masque_interruptions[i] == 'Q')
 2357:         {
 2358:             if (l_element_liste == NULL)
 2359:             {
 2360:                 if ((l_element_liste =
 2361:                         allocation_maillon(s_etat_processus)) == NULL)
 2362:                 {
 2363:                     (*s_etat_processus).erreur_systeme =
 2364:                             d_es_allocation_memoire;
 2365:                     return;
 2366:                 }
 2367: 
 2368:                 l_element_futur = l_element_liste;
 2369:             }
 2370:             else
 2371:             {
 2372:                 if (((*l_element_liste).suivant =
 2373:                         allocation_maillon(s_etat_processus)) == NULL)
 2374:                 {
 2375:                     (*s_etat_processus).erreur_systeme =
 2376:                             d_es_allocation_memoire;
 2377:                     return;
 2378:                 }
 2379: 
 2380:                 l_element_liste = (*l_element_liste).suivant;
 2381:             }
 2382: 
 2383:             (*l_element_liste).suivant = NULL;
 2384: 
 2385:             if (((*l_element_liste).donnee = allocation(s_etat_processus,
 2386:                     INT)) == NULL)
 2387:             {
 2388:                 (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
 2389:                 return;
 2390:             }
 2391: 
 2392:             (*((integer8 *) (*(*l_element_liste).donnee).objet)) = i + 1;
 2393:         }
 2394:     }
 2395: 
 2396:     (*(*l_element_courant).donnee).objet = l_element_futur;
 2397: 
 2398:     if (((*l_element_courant).suivant = allocation_maillon(s_etat_processus))
 2399:             == NULL)
 2400:     {
 2401:         (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
 2402:         return;
 2403:     }
 2404: 
 2405:     l_element_courant = (*l_element_courant).suivant;
 2406: 
 2407:     if (((*l_element_courant).donnee = allocation(s_etat_processus, LST))
 2408:             == NULL)
 2409:     {
 2410:         (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
 2411:         return;
 2412:     }
 2413: 
 2414:     l_element_liste = NULL;
 2415:     l_element_futur = NULL;
 2416: 
 2417:     for(i = 0; i < d_NOMBRE_INTERRUPTIONS; i++)
 2418:     {
 2419:         if ((*s_etat_processus).masque_interruptions[i] == 'I')
 2420:         {
 2421:             if (l_element_liste == NULL)
 2422:             {
 2423:                 if ((l_element_liste =
 2424:                         allocation_maillon(s_etat_processus)) == NULL)
 2425:                 {
 2426:                     (*s_etat_processus).erreur_systeme =
 2427:                             d_es_allocation_memoire;
 2428:                     return;
 2429:                 }
 2430: 
 2431:                 l_element_futur = l_element_liste;
 2432:             }
 2433:             else
 2434:             {
 2435:                 if (((*l_element_liste).suivant =
 2436:                         allocation_maillon(s_etat_processus)) == NULL)
 2437:                 {
 2438:                     (*s_etat_processus).erreur_systeme =
 2439:                             d_es_allocation_memoire;
 2440:                     return;
 2441:                 }
 2442: 
 2443:                 l_element_liste = (*l_element_liste).suivant;
 2444:             }
 2445: 
 2446:             (*l_element_liste).suivant = NULL;
 2447: 
 2448:             if (((*l_element_liste).donnee = allocation(s_etat_processus,
 2449:                     INT)) == NULL)
 2450:             {
 2451:                 (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
 2452:                 return;
 2453:             }
 2454: 
 2455:             (*((integer8 *) (*(*l_element_liste).donnee).objet)) = i + 1;
 2456:         }
 2457:     }
 2458: 
 2459:     (*(*l_element_courant).donnee).objet = l_element_futur;
 2460: 
 2461:     (*l_element_courant).suivant = NULL;
 2462: 
 2463:     if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
 2464:             s_objet_resultat) == d_erreur)
 2465:     {
 2466:         return;
 2467:     }
 2468: 
 2469:     return;
 2470: }
 2471: 
 2472: 
 2473: /*
 2474: ================================================================================
 2475:   Fonction 'swiunlock'
 2476: ================================================================================
 2477:   Entrées : structure processus
 2478: --------------------------------------------------------------------------------
 2479:   Sorties :
 2480: --------------------------------------------------------------------------------
 2481:   Effets de bord : néant
 2482: ================================================================================
 2483: */
 2484: 
 2485: void
 2486: instruction_swiunlock(struct_processus *s_etat_processus)
 2487: {
 2488:     integer8                    interruption;
 2489: 
 2490:     struct_liste_chainee        *l_element_courant;
 2491: 
 2492:     struct_objet                *s_objet_argument;
 2493: 
 2494:     (*s_etat_processus).erreur_execution = d_ex;
 2495: 
 2496:     if ((*s_etat_processus).affichage_arguments == 'Y')
 2497:     {
 2498:         printf("\n  SWIUNLOCK ");
 2499: 
 2500:         if ((*s_etat_processus).langue == 'F')
 2501:         {
 2502:             printf("(déverrouillage des interruptions logicielles)\n\n");
 2503:         }
 2504:         else
 2505:         {
 2506:             printf("(software interrupt unlock)\n\n");
 2507:         }
 2508: 
 2509:         printf("    1: %s, %s\n", d_INT, d_LST);
 2510: 
 2511:         return;
 2512:     }
 2513:     else if ((*s_etat_processus).test_instruction == 'Y')
 2514:     {
 2515:         (*s_etat_processus).nombre_arguments = -1;
 2516:         return;
 2517:     }
 2518: 
 2519:     if (test_cfsf(s_etat_processus, 31) == d_vrai)
 2520:     {
 2521:         if (empilement_pile_last(s_etat_processus, 1) == d_erreur)
 2522:         {
 2523:             return;
 2524:         }
 2525:     }
 2526: 
 2527:     if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
 2528:             &s_objet_argument) == d_erreur)
 2529:     {
 2530:         (*s_etat_processus).erreur_execution = d_ex_manque_argument;
 2531:         return;
 2532:     }
 2533: 
 2534:     if ((*s_objet_argument).type == INT)
 2535:     {
 2536:         interruption = (*((integer8 *) (*s_objet_argument).objet));
 2537: 
 2538:         if ((interruption < 1) || (interruption > d_NOMBRE_INTERRUPTIONS))
 2539:         {
 2540:             liberation(s_etat_processus, s_objet_argument);
 2541: 
 2542:             (*s_etat_processus).erreur_execution = d_ex_interruption_invalide;
 2543:             return;
 2544:         }
 2545: 
 2546:         (*s_etat_processus).masque_interruptions[interruption - 1] = 'N';
 2547:     }
 2548:     else if ((*s_objet_argument).type == LST)
 2549:     {
 2550:         l_element_courant = (*s_objet_argument).objet;
 2551: 
 2552:         while(l_element_courant)
 2553:         {
 2554:             if ((*(*l_element_courant).donnee).type != INT)
 2555:             {
 2556:                 liberation(s_etat_processus, s_objet_argument);
 2557: 
 2558:                 (*s_etat_processus).erreur_execution =
 2559:                         d_ex_erreur_type_argument;
 2560:                 return;
 2561:             }
 2562: 
 2563:             interruption = (*((integer8 *) (*(*l_element_courant)
 2564:                     .donnee).objet));
 2565: 
 2566:             if ((interruption < 1) || (interruption > d_NOMBRE_INTERRUPTIONS))
 2567:             {
 2568:                 liberation(s_etat_processus, s_objet_argument);
 2569: 
 2570:                 (*s_etat_processus).erreur_execution =
 2571:                         d_ex_interruption_invalide;
 2572:                 return;
 2573:             }
 2574: 
 2575:             (*s_etat_processus).masque_interruptions[interruption - 1] = 'N';
 2576:             l_element_courant = (*l_element_courant).suivant;
 2577:         }
 2578:     }
 2579:     else
 2580:     {
 2581:         liberation(s_etat_processus, s_objet_argument);
 2582: 
 2583:         (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
 2584:         return;
 2585:     }
 2586: 
 2587:     liberation(s_etat_processus, s_objet_argument);
 2588: 
 2589:     return;
 2590: }
 2591: 
 2592: 
 2593: /*
 2594: ================================================================================
 2595:   Fonction 'swiqueue'
 2596: ================================================================================
 2597:   Entrées : structure processus
 2598: --------------------------------------------------------------------------------
 2599:   Sorties :
 2600: --------------------------------------------------------------------------------
 2601:   Effets de bord : néant
 2602: ================================================================================
 2603: */
 2604: 
 2605: void
 2606: instruction_swiqueue(struct_processus *s_etat_processus)
 2607: {
 2608:     integer8                    interruption;
 2609: 
 2610:     struct_liste_chainee        *l_element_courant;
 2611: 
 2612:     struct_objet                *s_objet_argument;
 2613: 
 2614:     (*s_etat_processus).erreur_execution = d_ex;
 2615: 
 2616:     if ((*s_etat_processus).affichage_arguments == 'Y')
 2617:     {
 2618:         printf("\n  SWIQUEUE ");
 2619: 
 2620:         if ((*s_etat_processus).langue == 'F')
 2621:         {
 2622:             printf("(enregistre des interruptions logicielles)\n\n");
 2623:         }
 2624:         else
 2625:         {
 2626:             printf("(software interrupt record)\n\n");
 2627:         }
 2628: 
 2629:         printf("    1: %s, %s\n", d_INT, d_LST);
 2630: 
 2631:         return;
 2632:     }
 2633:     else if ((*s_etat_processus).test_instruction == 'Y')
 2634:     {
 2635:         (*s_etat_processus).nombre_arguments = -1;
 2636:         return;
 2637:     }
 2638: 
 2639:     if (test_cfsf(s_etat_processus, 31) == d_vrai)
 2640:     {
 2641:         if (empilement_pile_last(s_etat_processus, 1) == d_erreur)
 2642:         {
 2643:             return;
 2644:         }
 2645:     }
 2646: 
 2647:     if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
 2648:             &s_objet_argument) == d_erreur)
 2649:     {
 2650:         (*s_etat_processus).erreur_execution = d_ex_manque_argument;
 2651:         return;
 2652:     }
 2653: 
 2654:     if ((*s_objet_argument).type == INT)
 2655:     {
 2656:         interruption = (*((integer8 *) (*s_objet_argument).objet));
 2657: 
 2658:         if ((interruption < 1) || (interruption > d_NOMBRE_INTERRUPTIONS))
 2659:         {
 2660:             liberation(s_etat_processus, s_objet_argument);
 2661: 
 2662:             (*s_etat_processus).erreur_execution = d_ex_interruption_invalide;
 2663:             return;
 2664:         }
 2665: 
 2666:         (*s_etat_processus).masque_interruptions[interruption - 1] = 'Q';
 2667:     }
 2668:     else if ((*s_objet_argument).type == LST)
 2669:     {
 2670:         l_element_courant = (*s_objet_argument).objet;
 2671: 
 2672:         while(l_element_courant)
 2673:         {
 2674:             if ((*(*l_element_courant).donnee).type != INT)
 2675:             {
 2676:                 liberation(s_etat_processus, s_objet_argument);
 2677: 
 2678:                 (*s_etat_processus).erreur_execution =
 2679:                         d_ex_erreur_type_argument;
 2680:                 return;
 2681:             }
 2682: 
 2683:             interruption = (*((integer8 *) (*(*l_element_courant)
 2684:                     .donnee).objet));
 2685: 
 2686:             if ((interruption < 1) || (interruption > d_NOMBRE_INTERRUPTIONS))
 2687:             {
 2688:                 liberation(s_etat_processus, s_objet_argument);
 2689: 
 2690:                 (*s_etat_processus).erreur_execution =
 2691:                         d_ex_interruption_invalide;
 2692:                 return;
 2693:             }
 2694: 
 2695:             (*s_etat_processus).masque_interruptions[interruption - 1] = 'Q';
 2696:             l_element_courant = (*l_element_courant).suivant;
 2697:         }
 2698:     }
 2699:     else
 2700:     {
 2701:         liberation(s_etat_processus, s_objet_argument);
 2702: 
 2703:         (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
 2704:         return;
 2705:     }
 2706: 
 2707:     liberation(s_etat_processus, s_objet_argument);
 2708: 
 2709:     return;
 2710: }
 2711: 
 2712: 
 2713: /*
 2714: ================================================================================
 2715:   Fonction 'sched'
 2716: ================================================================================
 2717:   Entrées : structure processus
 2718: --------------------------------------------------------------------------------
 2719:   Sorties :
 2720: --------------------------------------------------------------------------------
 2721:   Effets de bord : néant
 2722: ================================================================================
 2723: */
 2724: 
 2725: void
 2726: instruction_sched(struct_processus *s_etat_processus)
 2727: {
 2728:     real8                       pourcentage;
 2729: 
 2730:     struct_objet                *s_objet_argument;
 2731: 
 2732:     (*s_etat_processus).erreur_execution = d_ex;
 2733: 
 2734:     if ((*s_etat_processus).affichage_arguments == 'Y')
 2735:     {
 2736:         printf("\n  SCHED ");
 2737: 
 2738:         if ((*s_etat_processus).langue == 'F')
 2739:         {
 2740:             printf("(limitation des ressources de calcul)\n\n");
 2741:         }
 2742:         else
 2743:         {
 2744:             printf("(CPU ressources limitation)\n\n");
 2745:         }
 2746: 
 2747:         printf("    1: %s, %s\n", d_INT, d_REL);
 2748: 
 2749:         return;
 2750:     }
 2751:     else if ((*s_etat_processus).test_instruction == 'Y')
 2752:     {
 2753:         (*s_etat_processus).nombre_arguments = -1;
 2754:         return;
 2755:     }
 2756: 
 2757:     if (test_cfsf(s_etat_processus, 31) == d_vrai)
 2758:     {
 2759:         if (empilement_pile_last(s_etat_processus, 1) == d_erreur)
 2760:         {
 2761:             return;
 2762:         }
 2763:     }
 2764: 
 2765:     if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
 2766:             &s_objet_argument) == d_erreur)
 2767:     {
 2768:         (*s_etat_processus).erreur_execution = d_ex_manque_argument;
 2769:         return;
 2770:     }
 2771: 
 2772:     if ((*s_objet_argument).type == INT)
 2773:     {
 2774:         pourcentage = (real8) (*((integer8 *) (*s_objet_argument).objet));
 2775:     }
 2776:     else if ((*s_objet_argument).type == REL)
 2777:     {
 2778:         pourcentage = (*((real8 *) (*s_objet_argument).objet));
 2779:     }
 2780:     else
 2781:     {
 2782:         liberation(s_etat_processus, s_objet_argument);
 2783: 
 2784:         (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
 2785:         return;
 2786:     }
 2787: 
 2788:     liberation(s_etat_processus, s_objet_argument);
 2789: 
 2790:     if ((pourcentage <= 0) || (pourcentage > 100))
 2791:     {
 2792:         (*s_etat_processus).erreur_execution = d_ex_argument_invalide;
 2793:         return;
 2794:     }
 2795: 
 2796:     (*s_etat_processus).pourcentage_maximal_cpu = pourcentage;
 2797: 
 2798:     return;
 2799: }
 2800: 
 2801: // vim: ts=4

CVSweb interface <joel.bertrand@systella.fr>