home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / lang / ada / 2360 < prev    next >
Encoding:
Text File  |  1992-08-14  |  4.7 KB  |  158 lines

  1. Newsgroups: comp.lang.ada
  2. Path: sparky!uunet!wupost!gumby!destroyer!ubc-cs!uw-beaver!news.u.washington.edu!milton.u.washington.edu!sinan
  3. From: sinan@milton.u.washington.edu (Sinan Karasu)
  4. Subject: Signals and Ada (Verdix) 
  5. Message-ID: <1992Aug14.143206.17031@u.washington.edu>
  6. Keywords: Ada fortran translation
  7. Sender: news@u.washington.edu (USENET News System)
  8. Organization: University of Washington, Seattle
  9. References: <1992Aug4.144736.25337@swlvx2.msd.ray.com>
  10. Date: Fri, 14 Aug 1992 14:32:06 GMT
  11. Lines: 145
  12.  
  13. 1) The following is from a code that was originally written in Alsys Ada,
  14. running on SCO Unix. Here is the scenario:
  15. there is a parent process and 4 child processes.
  16. created by the standard method.
  17.  fork();
  18.  if PID=0 then
  19.    exec(child) 
  20.  
  21.    etc...
  22.  end if;
  23.  
  24.  Then parent signals children, and children signals parent using SIGUSR1,2
  25.  
  26.  Now in Verdix Ada when you attach an ISR routine that ISR routine
  27. can not do a blocking op. However it can do signal_semaphore or
  28. resume_task. So I thought the following code should do the trick but it
  29. does not seem to want to work. Does anybody have experience,
  30. or ideas about this. Any suggestions would be appreciated.
  31. (Post and send e-mail) or (send-email) , since e-mail will get to
  32. me instantly.  
  33.  
  34. 2) Is there a better way to do this ??
  35.  
  36. 3) Another idea occuder to me is that, What signals does Verdix use
  37.    for tasking ? ( seems like anytime I do a a.db -a PID PNAME
  38.    I found the program in sigpause routine.
  39.  
  40.  
  41.  
  42. ----------------------------------------------------------------------------
  43. --  Write_Ack                                                             --
  44. --                                                                        --
  45. --  Handle the acknowledge signal returned after written data is read.    --
  46. --  This is required because multiple signals from a single process are   --
  47. --  not properly buffered. Either SCO or Alsys problem.                   --
  48. ----------------------------------------------------------------------------
  49. TASK BODY Write_Ack IS
  50.     Local_Count : INTEGER := 0;
  51.     Quick_Wait    : BOOLEAN := FALSE;
  52. BEGIN
  53.     Ack_Count := 0;
  54.     LOOP
  55.     SELECT
  56.             ACCEPT Wait_For_Ack DO
  57.           Quick_Wait := (Probe_Label = Process_Label)
  58.                 AND Allow_Ack_Time_Out;
  59.             Wait_Loop: LOOP
  60.               SELECT
  61.                 ACCEPT Ack_Rcvd;
  62.             Ack_Count := Ack_Count - 1;
  63.             EXIT Wait_Loop;
  64.               OR
  65. -- This could cause problems since the msg is cleared before SIGUSR2 is sent.
  66.             WHEN Quick_Wait =>
  67.             DELAY(0.0);
  68.           OR
  69.             WHEN Allow_Ack_Time_Out =>
  70.             DELAY(1.0);
  71. ...etc 
  72.               END SELECT;
  73.           END LOOP Wait_Loop;
  74.         END Wait_For_Ack;
  75.     OR
  76.         TERMINATE;
  77.     END SELECT;
  78.     END LOOP;
  79.  
  80. EXCEPTION
  81.     WHEN TASKING_ERROR =>
  82.     Task_Has_Died := TRUE;
  83.     Set_Error_Msg(".Program_IO.Write_Ack Task " &
  84.         "has terminated due to a TASKING_ERROR.");
  85.     WHEN PROGRAM_ERROR =>
  86.             ...................................etc
  87.  
  88. END Write_Ack;
  89. -----------------------------------------------------------
  90. Task Catch_Ack_Task;
  91.  
  92. Task body Catch_Ack_Task is
  93. BEGIN
  94.     V_XTASKING.set_priority(20,Catch_Ack_Task'TASK_ID);
  95.     LOOP
  96.        V_XTASKING.suspend_task(Catch_Ack_Task'TASK_ID);
  97.        Ack_Count := Ack_Count + 1;
  98.        Write_Ack.Ack_Rcvd;
  99.     END LOOP;
  100. END Catch_Ack_Task;
  101.  
  102. Procedure Catch_Ack is --(Signum : IN ADDRESS) IS
  103. BEGIN
  104. --    Ack_Count := Ack_Count + 1;
  105. --    Signal_Caught := Signum;
  106. --    Write_Ack.Ack_Rcvd;
  107.     V_XTASKING.resume_task(Catch_Ack_Task'TASK_ID);
  108. END Catch_Ack;
  109.   
  110. --sik ----------------------------------------------------------------------
  111. Task Catch_Child_Task;
  112.  
  113. Task body Catch_Child_Task is
  114. BEGIN
  115.     V_XTASKING.set_priority(20,Catch_Child_Task'TASK_ID);
  116.     LOOP
  117.        V_XTASKING.suspend_task(Catch_Child_Task'TASK_ID);
  118.        Child_Died_Task.Child_Died;
  119.     END LOOP;
  120. END Catch_Child_Task;
  121.  
  122. PROCEDURE Catch_Child is --sik (Signum : IN ADDRESS) IS
  123. BEGIN
  124. --    Signal_Caught := Signum;
  125. --    Child_Died_Task.Child_Died;
  126.     V_XTASKING.resume_task(Catch_Child_Task'TASK_ID);
  127. END Catch_Child;
  128. ---------------------------
  129. Task Catch_Data_Task;
  130.  
  131. Task body Catch_Data_Task is
  132.  
  133.  ...etc
  134. -----------------------------------
  135. Task Catch_Term_Task;
  136.  
  137. ...etc
  138. -----------------------
  139.  
  140.  
  141.  
  142.     procedure Catch_Data_ISR   is new V_INTERRUPTS.ISR(Catch_Data);
  143.     procedure Catch_Ack_ISR    is new V_INTERRUPTS.ISR(Catch_Ack);
  144. ...etc
  145.  
  146. BEGIN
  147. --    Init_Interrupt_Manager(12,128,2048); -- Not well defined by Alsys!
  148.     V_INTERRUPTS.attach_isr(SIG_USR1,Catch_Data_ISR'ADDRESS );
  149.     V_INTERRUPTS.attach_isr(SIG_USR2,Catch_Ack_ISR'ADDRESS);
  150.  
  151. ...etc
  152. -- SIGCLD is installed after initialization and removed prior to termination
  153. -- Install_Handler(Catch_Child'ADDRESS, SIG_CLD, Extended_Priority'LAST-3);
  154.    ^^^ Alsys call.
  155. ...etc
  156.  
  157. END Program_IO_Support;
  158.