🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.mac
Article #14381

TimeMgr

#14381
From: peirce
Date: Mon, 09 Feb 1987 18:32
89 lines
2999 bytes
Recently I was trying to use the new time manager calls from LightSpeed C.
The thing seemed to work nicely except that a variable stored after
the TMTask record kept getting clobbered.  Upon further examination, I
noticed that there was a field called tmCount in the TMTask record which
is declared as an Int.  Both the LightSpeed C include file and the time
manager chapter of Inside Mac (marked "Final Draft 6/6/86") declare it
that way.  Now, even though it's marked "reserved" it appears to contain
the millisecond countdown set in the PrimeTime() call.  Unfortunately, 
the counting is happening in a long word! (which makes sense since
PrimeTime takes a long word of milliseconds) and clobbers anything stored
just beyond the record.  I changed the declaration to a long and all
seems well.

I talked to tech support at Think, and the guy didn't have any insight into
the problem (in fact he seemed to think that the time manager didn't work -
it does with this change!).

Has anyone else tried the time manager? or is this really a bug in the
documentation (and include file)?

I'll include my little test program that redeclares the TMTask type following
this text...

-- michael

---------------------------------------------------------------------------
#include "stdio.h"
#include "TimeMgr.h"
#include "OSUtil.h"

typedef struct newTMTask {
	struct QElem		*qLink;
	int			qType;
	ProcPtr			tmAddr;
	long			tmCount; /*** was an int (16-bit) ***/
} newTMTask;

newTMTask	Beep1_task;
int		sync;

main()
{
pascal	Beep1();

	printf("Begin...\n");
	sync = 0;

	Beep1_task.tmAddr = (ProcPtr) Beep1;

		printf("tmCnt  = %ld\n",Beep1_task.tmCount);
	InsTime(&Beep1_task);
		printf("tmCnt  = %ld\n",Beep1_task.tmCount);
	Debugger();
	PrimeTime(&Beep1_task,500);
		printf("tmCnt  = %ld\n",Beep1_task.tmCount);
		printf("tmCnt  = %ld\n",Beep1_task.tmCount);
		printf("tmCnt  = %ld\n",Beep1_task.tmCount);
		printf("tmCnt  = %ld\n",Beep1_task.tmCount);
		printf("tmCnt  = %ld\n",Beep1_task.tmCount);
		printf("tmCnt  = %ld\n",Beep1_task.tmCount);
		printf("tmCnt  = %ld\n",Beep1_task.tmCount);
		printf("tmCnt  = %ld\n",Beep1_task.tmCount);
	while (sync==0) {}
	printf("Done\n");
}

pascal Beep1()
{
	SetUpA5();
	SysBeep(1);
	RmvTime(&Beep1_task);
	sync = 1;
	RestoreA5();
}

/***** Observed result...

Begin...
tmCnt  = 500
tmCnt  = 416
tmCnt  = 332
tmCnt  = 248
tmCnt  = 164
tmCnt  = 80
tmCnt  = 0
tmCnt  = 0
Done

*********/
Technical Details
Message-ID: <7981@decwrl.DEC.COM>
Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!rutgers!mit-eddie!genrad!decvax!decwrl!the780.dec.com!peirce

Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!rutgers!mit-eddie!genrad!decvax!decwrl!the780.dec.com!peirce
From: peirce@the780.dec.com.UUCP
Newsgroups: comp.sys.mac
Subject: TimeMgr
Message-ID: <7981@decwrl.DEC.COM>
Date: Mon, 9-Feb-87 13:32:24 EST
Article-I.D.: decwrl.7981
Posted: Mon Feb  9 13:32:24 1987
Date-Received: Tue, 10-Feb-87 06:05:41 EST
Sender: daemon@decwrl.DEC.COM
Organization: Digital Equipment Corporation
Lines: 89