Algorithme de Dekker
Description du code
Code source ou contenu du fichier
Code ada (Algorithme de Dekker) (54 lignes)
PROCEDURE dekker_s_algorithm IS TYPE process_enumeration IS(first,second); favored_process : process_enumeration; p1_wants_to_enter, p2_wants_to_enter : boolean; PROCEDURE process_one IS BEGIN LOOP p1_wants_to_enter := true; WHILE p2_wants_to_enter LOOP IF favored_process = second THEN p1_wants_to_enter := false; WHILE favored_process = second LOOP NULL; END LOOP; p1_wants_to_enter := true; END IF; END LOOP; critical_section_one; favored_process := second; p1_wants_to_enter := false; other_stuff_one; END LOOP; END process_one; PROCEDURE process_two IS BEGIN LOOP p2_wants_to_enter := true; WHILE p1_wants_to_enter LOOP IF favored_process = first THEN p2_wants_to_enter := false; WHILE favored_process = first LOOP NULL; END LOOP; p2_wants_to_enter := true; END IF; END LOOP; critical_section_two; favored_process := first; p2_wants_to_enter := false; other_stuff_two; END LOOP; END process_two; BEGIN p1_wants_to_enter := false; p2_wants_to_enter := false; favored_process := first; PARBEGIN process_one; process_two; PAREND; END dekker_s_algorithm;
Autres extraits de codes en ada
- Algorithme de Dekker
- Suite de Fibonacci Exemple d'itération en ADA
- Suite de Fibonacci Exemple de récursion en ADA
- Hello world
- Tous les extraits
English translation
You have asked to visit this site in English. For now, only the interface is translated, but not all the content yet.If you want to help me in translations, your contribution is welcome. All you need to do is register on the site, and send me a message asking me to add you to the group of translators, which will give you the opportunity to translate the pages you want. A link at the bottom of each translated page indicates that you are the translator, and has a link to your profile.
Thank you in advance.
Document created the 05/10/2009, last modified the 28/10/2018
Source of the printed document:https://www.gaudry.be/en/sniplet-rf-ada/dekker_s_algorithm.ada.html
The infobrol is a personal site whose content is my sole responsibility. The text is available under CreativeCommons license (BY-NC-SA). More info on the terms of use and the author.