home *** CD-ROM | disk | FTP | other *** search
/ Chip 1995 March / CHIP3.mdf / programm / prog4 / priority.ada < prev    next >
Encoding:
Text File  |  1991-07-01  |  1.4 KB  |  65 lines

  1.                                      -- Chapter 27 - Program 5
  2. with Text_IO;
  3. use Text_IO;
  4.  
  5. procedure Priority is
  6.  
  7. task type SHORT_LINE is
  8.    pragma PRIORITY (5);
  9. end SHORT_LINE;
  10.  
  11. task type LONG_LINE is
  12.    pragma PRIORITY (1);
  13. end LONG_LINE;
  14.  
  15. pragma PRIORITY (3);   -- This is the priority for the main program
  16.  
  17. Cow, Dog, Pig          : SHORT_LINE;
  18. Elephant, Hippopotamus : LONG_LINE;
  19.  
  20. task body SHORT_LINE is
  21. begin
  22.    for Index in 1..4 loop
  23.       delay 0.0;
  24.       Put_Line("This is a short line");
  25.    end loop;
  26. end SHORT_LINE;
  27.  
  28. task body LONG_LINE is
  29. begin
  30.    for Index in 1..3 loop
  31.       delay 0.0;
  32.       Put_Line("This is a much longer line to be displayed");
  33.    end loop;
  34. end LONG_LINE;
  35.  
  36. begin
  37.    Put_Line("This is an example of use of a task type");
  38. end Priority;
  39.  
  40.  
  41.  
  42.  
  43. -- Result of execution
  44.  
  45. -- This is a short line
  46. -- This is a short line
  47. -- This is a short line
  48. -- This is a short line
  49. -- This is a short line
  50. -- This is a short line
  51. -- This is a short line
  52. -- This is a short line
  53. -- This is a short line
  54. -- This is a short line
  55. -- This is a short line
  56. -- This is a short line
  57. -- This is an example of use of a task type
  58. -- This is a much longer line to be displayed
  59. -- This is a much longer line to be displayed
  60. -- This is a much longer line to be displayed
  61. -- This is a much longer line to be displayed
  62. -- This is a much longer line to be displayed
  63. -- This is a much longer line to be displayed
  64.  
  65.