Annotation of rpl/src/instructions_s9.c, revision 1.58

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

CVSweb interface <joel.bertrand@systella.fr>