From: wittb@nextnet.csus.edu (brian witt)
Newsgroups: comp.sys.amiga.programmer
Subject: Re: How to program multi-threaded programs on Amiga ?
Summary: Try one prcess higher priority
Date: 12 Nov 92 19:53:17 GMT
Organization: California State University Sacramento, USA
Cc: uunet.uu.net!dtek.chalmers.se!d9hh

In article <1992Nov9.185443.2011@jato.jpl.nasa.gov> you write:
>In article <d9hh.720829520@dtek.chalmers.se> d9hh@dtek.chalmers.se (Henrik Harmsen) writes:
>>Yes, I know, Intuition has a buffer for all the messages that it wants
>>to send me, but when you have a humungous amount of messages this buffer
>>quite easily overflows.

Message ports don't have a buffer limit.  Because there is no memory
protection and Exec lists have no upper limit, you can exhaust all
memory with messages attached to a message port.

However, I realize you probably also want some sort of low proiorty/
high priorty scheme to handle the mouse and to handle screen updating.
You may want to try this (but you may be flamed).

	Open libraries and such first off.

	Create a private message port and pass it to a new process
	that's running in your code space.  The new process waits for
	work on the private message port.  This process will handle
	lower-priority duties (like word wrapping).  It might also
	manage other project (not current window) that your application
	has opened.

	Have your initial process boost its priority by one.
	This way it will respond quickly to any intuition messages.

	Have the initial process open all windows, screens, etc.

	In the main processing loop for the window, all messages
	are recieved and delt with.  Those requiring instant response
	delta with immediately.  Message of background usefulness
	are SendMsg() to the private port; don't change the ReplyPort!

	When the initial, priority boosted process is idle, the rest of
	the system will operate, including the second process.

	At exit time, send the low priorty process a kill message.
	Then loop with a sleep() call until some global varaible is
	set to indicate OK to die.

	Cleanup gracefully and exit to AmigaDOS!

Good modular programming should make things easier to code.  You
may need some semphores in the case where the normal priority process
is changing a data structure when Intuition (running at high priority)
sends an important message to your window, which is handled by
a high priority process.  The background process is interrupted
while your importnat message is handled to completion. (Can you say
'concurrency' and 'deadlock avoidance' -- knew ya could.)

Note: This may degrade overall system performace for other programs, but if
the user is concentrating on your program, then it *shouldn't* matter if
other programs are running a little slower... (maybe)
(Windows/NT at the Fall 1991 Comdex did something like this.)

>>I also want to use more than one (two, three..) processes for other things.
>>It would be nice to be able to edit one text while you process another :-)

>Jeff

My knowledge goes up to ADOS 1.3 as I still have (and am typing on) an
Amiga 1000  !!!!!!!!!!

PS:  I'm looking for an Amiga 1000 ethernet adapter and a 68020 with MMU
     and memory plug-in (used OK).

--- American Culture:  Cigarettes and Alcohol
--- brian witt

-- 
============================================================================= !
   Brian Witt   Sac State Computer Science]   "Waldo, the pariot, is dead"
   Internet:  wittb@ratserv.ccs.csus.edu              -- Agent Cooper
                #define  POSIX_ME_HARDER     1       <-- GNU