[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

MPW C Help




I seem to be having some trouble hacking into the Mac's Time Manager from MPW.

While I ame clear that this is not an MPW mailing list I thought that someone
might have a lead on either another mailing list that is appropriate for the
question or a diagnosis.

Thanks,
Marc.

----------------------------------------

Here is the code.

It seems to run fine if the count in gCounter is < ~1200 but if let run for
longer periods of time it locksup the machine.  






#include <stdlib.h>
#include <stdio.h>
#include <timer.h>
#include <events.h>

long kDelay = 10; // Milliseconds

static int       			gCounter = 0;
static TMTaskPtr  			gTMTaskPtr;

pascal void MyTask(void)
{	static int			first_p = 1;
	static long 		a5Value;
	static TMTaskPtr	theTMTaskPtr;
	long				oldA5;
	
	if (first_p)
	{	first_p   		= 0;
		a5Value   		= SetCurrentA5();
		theTMTaskPtr    = gTMTaskPtr;
	}
	else
	{	oldA5 = SetA5(a5Value);            			// Grab
	the current A5 Envt
	
		gCounter++;	                        		// Do
		somthing which may include globals
				
		PrimeTime((QElemPtr)theTMTaskPtr, kDelay); 	// Schedule
		next execution of this routine

		oldA5 = SetA5(oldA5);               		// Restore the
		A5 environment
		
	}
}

main()
{	TMTask 		aTMTask;
	
	gTMTaskPtr = &aTMTask;
	
	aTMTask.tmAddr 		= MyTask;
	aTMTask.tmWakeUp 	= 0;
	aTMTask.tmReserved 	= 0;
		
	MyTask(); // Init the task setting up the A5 and task references
	
	InsTime((QElemPtr)gTMTaskPtr);
	
	PrimeTime((QElemPtr)gTMTaskPtr, kDelay);

	while (!Button());
		
	RmvTime((QElemPtr)gTMTaskPtr);

	printf("%d\n", gCounter); fflush(stdout);


}