[comp.sys.amiga.tech] Parent/child processes

cogswell@egrunix.UUCP (Dan Cogswell) (10/03/89)

Hello, friends.

Does anybody have a neat way of blocking a parent process from terminating
until all it's child processes have also terminated??  I certainly can't find 
anything in the Exec that will help me here.

Also, has anybody had problems with the RemSemaphore() function??  As far as 
I know, I'm the only Amiga owner to ever use it's semaphores!  I can init them 
just fine and they seem to work okay, but when I try to remove them from the 
system list, I get a GURU (#00000003.00000000 -OR- #00000004.0000000) .


*-----------------------------------------------------------------*
Dan Cogswell			   "Gangster Fun -- It's the beat 
(313)625-3234			      that you can wig-out to..."
cogswell@unix.secs.oakland.edu.UUCP
*-----------------------------------------------------------------*

karl@sugar.hackercorp.com (Karl Lehenbauer) (10/03/89)

In article <186@egrunix.UUCP> cogswell@unix.secs.oakland.edu.UUCP (Dan Cogswell) writes:
>Does anybody have a neat way of blocking a parent process from terminating
>until all it's child processes have also terminated??  I certainly can't find 
>anything in the Exec that will help me here.

Sure, dude.  Use Peter da Silva's workbench launch code to launch your task's
children as workbench tasks, then wait on the completion messages they send
when they exit.
-- 
-- uunet!sugar!karl	"There is hopeful symbolism in the fact that 
-- 			 flags do not wave in a vacuum."  -- Arthur C. Clarke
-- Usenet access: (713) 438-5018

mks@cbmvax.UUCP (Michael Sinz - CATS) (10/04/89)

In article <186@egrunix.UUCP> cogswell@unix.secs.oakland.edu.UUCP (Dan Cogswell) writes:
>
>Also, has anybody had problems with the RemSemaphore() function??  As far as 
>I know, I'm the only Amiga owner to ever use it's semaphores!  I can init them 
>just fine and they seem to work okay, but when I try to remove them from the 
>system list, I get a GURU (#00000003.00000000 -OR- #00000004.0000000) .
>
Check the bindings and/or pragma for RemSemaphore as some error in older
AutoDocs and AMIGA.LIB files had the parameter in the incorrect register.
I should be in A1.

>
>*-----------------------------------------------------------------*
>Dan Cogswell			   "Gangster Fun -- It's the beat 
>(313)625-3234			      that you can wig-out to..."
>cogswell@unix.secs.oakland.edu.UUCP
>*-----------------------------------------------------------------*



/----------------------------------------------------------------------\
|      /// Michael Sinz -- CATS/Amiga Software Engineer                |
|     ///  PHONE 215-431-9422  UUCP ( uunet | rutgers ) !cbmvax!mks    |
|    ///                                                               |
|\\\///          When people are free to do as they please,            |
| \XX/                they usually imitate each other.                 |
\----------------------------------------------------------------------/

cogswell@egrunix.UUCP (Dan Cogswell) (10/04/89)

In article <8068@cbmvax.UUCP> mks@cbmvax.UUCP (Michael Sinz - CATS) writes:
>Check the bindings and/or pragma for RemSemaphore as some error in older
>AutoDocs and AMIGA.LIB files had the parameter in the incorrect register.
>I should be in A1.
>

I'm using Benchmark M2 and I gave Leon Frenkl a call down there and he says
his glue routines load into A1.  Without a debugger, I have no good way of
checking if this is true, but I trust him.

Here's an example that fails:

MODULE Junk.

FROM Semaphores 	IMPORT	(etc...)

VAR
 mutex:SignalSemaphore;
BEGIN
  InitSemaphore(mutex);
  AddSemaphore(mutex);

  RemSemaphore(mutex);	(* CRASH CITY!!! *)
END Junk.

Am I doing something wrong??  


*-----------------------------------------------------------------*
|Dan Cogswell			   "Gangster Fun -- It's the beat |
|(313)625-3234			      that you can wig-out to..." |
|cogswell@unix.secs.oakland.edu					  |
*-----------------------------------------------------------------*

mks@cbmvax.UUCP (Michael Sinz - CATS) (10/04/89)

In article <191@egrunix.UUCP> cogswell@unix.secs.oakland.edu.UUCP (Dan Cogswell) writes:
>In article <8068@cbmvax.UUCP> mks@cbmvax.UUCP (Michael Sinz - CATS) writes:
>>Check the bindings and/or pragma for RemSemaphore as some error in older
>>AutoDocs and AMIGA.LIB files had the parameter in the incorrect register.
>>I should be in A1.
>>
>
>I'm using Benchmark M2 and I gave Leon Frenkl a call down there and he says
>his glue routines load into A1.  Without a debugger, I have no good way of
>checking if this is true, but I trust him.
>
>Here's an example that fails:
>
>MODULE Junk.
>
>FROM Semaphores 	IMPORT	(etc...)
>
>VAR
> mutex:SignalSemaphore;
>BEGIN
>  InitSemaphore(mutex);
>  AddSemaphore(mutex);
>
>  RemSemaphore(mutex);	(* CRASH CITY!!! *)
>END Junk.
>
>Am I doing something wrong??  
>

Unfortunately, the AddSemaphore() call is broken in the V33/V34 kickstart.
(That is V1.2 and V1.3)  The only real way to add a Semaphore to a public
Semaphore list is to do it yourself with something like:

InitSemaphore(mutex);
Forbid();
Enqueue(&ExecBase->SemaphoreList,mutex);
Permit();

Use those four lines insted of AddSemaphore()...

Also, there is the problem of other tasks waiting for the Semaphore and
you go and remove it...  Just things you may need to watch out for.

/----------------------------------------------------------------------\
|      /// Michael Sinz -- CATS/Amiga Software Engineer                |
|     ///  PHONE 215-431-9422  UUCP ( uunet | rutgers ) !cbmvax!mks    |
|    ///                                                               |
|\\\///          When people are free to do as they please,            |
| \XX/                they usually imitate each other.                 |
\----------------------------------------------------------------------/

cogswell@egrunix.UUCP (Dan Cogswell) (10/09/89)

In article <4261@sugar.hackercorp.com> karl@sugar.hackercorp.com (Karl Lehenbauer) writes:
>In article <186@egrunix.UUCP> cogswell@unix.secs.oakland.edu.UUCP (Dan Cogswell) writes:
>>Does anybody have a neat way of blocking a parent process from terminating
>>until all it's child processes have also terminated??  I certainly can't find 
>>anything in the Exec that will help me here.
>
>Sure, dude.  Use Peter da Silva's workbench launch code to launch your task's
>children as workbench tasks, then wait on the completion messages they send
>when they exit.

Excuse my ignorance, but could I don't know of the code you're speaking of.
Could you be more specific for us Workbench-haters :-) ??

*-----------------------------------------------------------------*
Dan Cogswell			   "Gangster Fun -- It's the beat 
(313)625-3234			      that you can wig-out to..."
cogswell@unix.secs.oakland.edu
*-----------------------------------------------------------------*