home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.ada
- Path: sparky!uunet!wupost!gumby!destroyer!ubc-cs!uw-beaver!news.u.washington.edu!milton.u.washington.edu!sinan
- From: sinan@milton.u.washington.edu (Sinan Karasu)
- Subject: Signals and Ada (Verdix)
- Message-ID: <1992Aug14.143206.17031@u.washington.edu>
- Keywords: Ada fortran translation
- Sender: news@u.washington.edu (USENET News System)
- Organization: University of Washington, Seattle
- References: <1992Aug4.144736.25337@swlvx2.msd.ray.com>
- Date: Fri, 14 Aug 1992 14:32:06 GMT
- Lines: 145
-
- 1) The following is from a code that was originally written in Alsys Ada,
- running on SCO Unix. Here is the scenario:
- there is a parent process and 4 child processes.
- created by the standard method.
- fork();
- if PID=0 then
- exec(child)
-
- etc...
- end if;
-
- Then parent signals children, and children signals parent using SIGUSR1,2
-
- Now in Verdix Ada when you attach an ISR routine that ISR routine
- can not do a blocking op. However it can do signal_semaphore or
- resume_task. So I thought the following code should do the trick but it
- does not seem to want to work. Does anybody have experience,
- or ideas about this. Any suggestions would be appreciated.
- (Post and send e-mail) or (send-email) , since e-mail will get to
- me instantly.
-
- 2) Is there a better way to do this ??
-
- 3) Another idea occuder to me is that, What signals does Verdix use
- for tasking ? ( seems like anytime I do a a.db -a PID PNAME
- I found the program in sigpause routine.
-
-
-
- ----------------------------------------------------------------------------
- -- Write_Ack --
- -- --
- -- Handle the acknowledge signal returned after written data is read. --
- -- This is required because multiple signals from a single process are --
- -- not properly buffered. Either SCO or Alsys problem. --
- ----------------------------------------------------------------------------
- TASK BODY Write_Ack IS
- Local_Count : INTEGER := 0;
- Quick_Wait : BOOLEAN := FALSE;
- BEGIN
- Ack_Count := 0;
- LOOP
- SELECT
- ACCEPT Wait_For_Ack DO
- Quick_Wait := (Probe_Label = Process_Label)
- AND Allow_Ack_Time_Out;
- Wait_Loop: LOOP
- SELECT
- ACCEPT Ack_Rcvd;
- Ack_Count := Ack_Count - 1;
- EXIT Wait_Loop;
- OR
- -- This could cause problems since the msg is cleared before SIGUSR2 is sent.
- WHEN Quick_Wait =>
- DELAY(0.0);
- OR
- WHEN Allow_Ack_Time_Out =>
- DELAY(1.0);
- ...etc
- END SELECT;
- END LOOP Wait_Loop;
- END Wait_For_Ack;
- OR
- TERMINATE;
- END SELECT;
- END LOOP;
-
- EXCEPTION
- WHEN TASKING_ERROR =>
- Task_Has_Died := TRUE;
- Set_Error_Msg(".Program_IO.Write_Ack Task " &
- "has terminated due to a TASKING_ERROR.");
- WHEN PROGRAM_ERROR =>
- ...................................etc
-
- END Write_Ack;
- -----------------------------------------------------------
- Task Catch_Ack_Task;
-
- Task body Catch_Ack_Task is
- BEGIN
- V_XTASKING.set_priority(20,Catch_Ack_Task'TASK_ID);
- LOOP
- V_XTASKING.suspend_task(Catch_Ack_Task'TASK_ID);
- Ack_Count := Ack_Count + 1;
- Write_Ack.Ack_Rcvd;
- END LOOP;
- END Catch_Ack_Task;
-
- Procedure Catch_Ack is --(Signum : IN ADDRESS) IS
- BEGIN
- -- Ack_Count := Ack_Count + 1;
- -- Signal_Caught := Signum;
- -- Write_Ack.Ack_Rcvd;
- V_XTASKING.resume_task(Catch_Ack_Task'TASK_ID);
- END Catch_Ack;
-
- --sik ----------------------------------------------------------------------
- Task Catch_Child_Task;
-
- Task body Catch_Child_Task is
- BEGIN
- V_XTASKING.set_priority(20,Catch_Child_Task'TASK_ID);
- LOOP
- V_XTASKING.suspend_task(Catch_Child_Task'TASK_ID);
- Child_Died_Task.Child_Died;
- END LOOP;
- END Catch_Child_Task;
-
- PROCEDURE Catch_Child is --sik (Signum : IN ADDRESS) IS
- BEGIN
- -- Signal_Caught := Signum;
- -- Child_Died_Task.Child_Died;
- V_XTASKING.resume_task(Catch_Child_Task'TASK_ID);
- END Catch_Child;
- ---------------------------
- Task Catch_Data_Task;
-
- Task body Catch_Data_Task is
-
- ...etc
- -----------------------------------
- Task Catch_Term_Task;
-
- ...etc
- -----------------------
-
-
-
- procedure Catch_Data_ISR is new V_INTERRUPTS.ISR(Catch_Data);
- procedure Catch_Ack_ISR is new V_INTERRUPTS.ISR(Catch_Ack);
- ...etc
-
- BEGIN
- -- Init_Interrupt_Manager(12,128,2048); -- Not well defined by Alsys!
- V_INTERRUPTS.attach_isr(SIG_USR1,Catch_Data_ISR'ADDRESS );
- V_INTERRUPTS.attach_isr(SIG_USR2,Catch_Ack_ISR'ADDRESS);
-
- ...etc
- -- SIGCLD is installed after initialization and removed prior to termination
- -- Install_Handler(Catch_Child'ADDRESS, SIG_CLD, Extended_Priority'LAST-3);
- ^^^ Alsys call.
- ...etc
-
- END Program_IO_Support;
-