No cache version.

Caching disabled. Default setting for this page:enabled (code LNG204)
If the display is too slow, you can disable the user mode to view the cached version.

Algorithme de Dekker

Description du code

Code source ou contenu du fichier

  1. PROCEDURE dekker_s_algorithm IS
  2. TYPE process_enumeration IS(first,second);
  3. favored_process : process_enumeration;
  4. p1_wants_to_enter,
  5. p2_wants_to_enter : boolean;
  6.  
  7. PROCEDURE process_one IS
  8. BEGIN
  9. LOOP
  10. p1_wants_to_enter := true;
  11. WHILE p2_wants_to_enter LOOP
  12. IF favored_process = second THEN
  13. p1_wants_to_enter := false;
  14. WHILE favored_process = second LOOP
  15. NULL;
  16. END LOOP;
  17. p1_wants_to_enter := true;
  18. END IF;
  19. END LOOP;
  20. critical_section_one;
  21. favored_process := second;
  22. p1_wants_to_enter := false;
  23. other_stuff_one;
  24. END LOOP;
  25. END process_one;
  26. PROCEDURE process_two IS
  27. BEGIN
  28. LOOP
  29. p2_wants_to_enter := true;
  30. WHILE p1_wants_to_enter LOOP
  31. IF favored_process = first THEN
  32. p2_wants_to_enter := false;
  33. WHILE favored_process = first LOOP
  34. NULL;
  35. END LOOP;
  36. p2_wants_to_enter := true;
  37. END IF;
  38. END LOOP;
  39. critical_section_two;
  40. favored_process := first;
  41. p2_wants_to_enter := false;
  42. other_stuff_two;
  43. END LOOP;
  44. END process_two;
  45.  
  46. BEGIN
  47. p1_wants_to_enter := false;
  48. p2_wants_to_enter := false;
  49. favored_process := first;
  50. PARBEGIN
  51. process_one;
  52. process_two;
  53. PAREND;
  54. END dekker_s_algorithm;

Autres extraits de codes en ada

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.