[comp.sys.amiga] Programmer needs advice on multitasking...

pcooper%luke.eecs.WSU.EDU%cs2.cs.WSU.EDU@yoda.eecs.wsu.edu (Phil Cooper - CS495) (11/24/90)

Fellow Amigans:

     I would like some advice/examples on how to set up several functions
in a source code file as independent processes (using ports and messages
for inter-process communications.)  My problem can be described as follows:

main()
{
   /* brilliant code inserted here...*/
}

func_1()
{
  
}

func_2()
{

}

  I would like to set up func_1 and func_2 to run as completely independent
processes.  Also, After they are set up, is anything needed to get them to
actually start executing?  I have a project now where the tasks are being
set up correctly (even show up with TaskX), but they seem to never actually
execute.  Any suggestions?

   Phil

ken@cbmvax.commodore.com (Ken Farinsky - CATS) (11/28/90)

In article <37127@nigel.ee.udel.edu> pcooper%luke.eecs.WSU.EDU%cs2.cs.WSU.EDU@yoda.eecs.wsu.edu (Phil Cooper - CS495) writes:
>Fellow Amigans:
>
>     I would like some advice/examples on how to set up several functions
>in a source code file as independent processes (using ports and messages
>for inter-process communications.)  My problem can be described as follows:
>
>   [ ...brilliant code removed... ]
>
>  I would like to set up func_1 and func_2 to run as completely independent
>processes...
>
>   Phil

There is a very well written article about this subject in AmigaMail,
the article is by Mike Sinz, and is called "Creating Multiple Processes
with Re-entrant Code" (AmigaMail, Nov/Dec 1989)

If you are interested in back-issues of AmigaMail, a subscription to
AmigaMail, or becomming a Certified or Commercial Developer, write
to the following address for information:

CATS Admin
1200 Wilson Drive
West Chester, PA  19380

If you are developing software for the Amiga, and are not a developer,
you are missing out on a lot of good technical information.

The basic information in the article is:

	1.  Use CreateProc() to start a new process.
	2.  CreateProc() takes a BPTR to a seglist, so you have
	to create a fake seglist which points to the function
	that you wish to turn into a process.
	3.  You can use the message port in the process structure
	for syncronization between the two processes.

I would recommend getting the whole article.

Under 2.0, you can use CreateNewProc() to do the same thing without
the fake seglist.
-- 
--
Ken Farinsky - CATS - (215) 431-9421 - Commodore Business Machines
uucp: ken@cbmvax.commodore.com   or  ...{uunet,rutgers}!cbmvax!ken
bix:  kfarinsky