[comp.sys.amiga.tech] Got a resident-problem...

d5kwedb@dtek.chalmers.se. (Kristian Wedberg) (02/01/90)

I can't get my first multitaskingly re-entrant program to work, so I thought
I'd try it out on you guys...

The problem:

	The program "hack" seems to multitask (with itself) ok, seems to be
	serially re-entrant, but if multiple invocations are running the
	same resident code, I can only exit one invocation. When exiting
	another invocation I crash with different guru#'s.

The setup:
	
	"hack" opens GfxBase & IntuitionBase using local variables
	some ports are opened, onbreak() is called, sprintf() used
	CreateTask(child)
	"hack" gives timing-information to 'child' with messages
	close libraries & ports, call onbreak(NULL) & exit()

	child open ports, uses sprintf()
	fools around with WB using GetRGB4()/SetRGB4()
	closes ports
	DeleteTask(NULL)

I'm using Lattice C 5.04, with lc-flag '-v' and linking with lc.lib, and
the child-function uses __saveds.
__saveds makes cres.o unusable, since you get an absolute reference to
_LinkerDB. Any way to get around this? So I remove all globals (except the
librarybases), but ARP's ARes still complains of 'Checksum error', why is that?
With ARes NOCHECK, or Commodores Resident it runs ok (serially, mind you!).

Biggish problem:
	
	Even with ARes NOCHECK I get 'Checksum error' if I try 2 simultaneous
	invocations of the same resident code. What checks does AShell do
	when NOCHECK is set? How do you remove the 'Checksum error' that
	(I assume) pertains to the librarybases?

	With Commodore Resident/Shell I can have multiple invocations running,
	but as mentioned I crash when exiting the SECOND time.

All comments & tricks will be duly received, tried, appreciated, gurued, 
reported, whatever seems apropriate.

    Kristian Wedberg				d5kwedb@dtek.chalmers.se