Frank is a Software Engineer with rich experiences on messeging system, embedded system and communication system development. This is his work notes.

Tuesday, June 27, 2006

Unstable issue in Palm ARM multithreading program

Recently we got our ARM multithreading application running unstable in the device. After we learned from Palm that how to save the enviroment from the crashed device by using serial cable and Palm ARM OS debugger(very useful way!), we found the device crashed could be anywhere, very weird. Then after Palm review our code and point it out that we didn't initial the thread correctly, we fixed the unstable issue.

This is the sample thread callback function.

static void
TaskMailboxThread(void * paramP)
{
Err err = errNone;
SysAppInfoType* appInfoP;
SysAppInfoType* dummyP;
KernelID taskid;
KALTaskInfoType info;
EmulStateRef emulStateRef = 0;
UInt32 mailboxMessage = 0;

//HsExtTraceFunction (gTraceContextP, "TaskMailboxProcCallback", NULL);

KALTaskGetCurrentID(&taskid);
KALTaskGetInfo(taskid, &info);


// Fix AppInfo, since SysTaskCreate just copies it from the creating task
appInfoP = SysGetAppInfo(&dummyP, &dummyP);
MemSet(appInfoP, sizeof(SysAppInfoType), 0);

// Put in pre-opened system databases into the DmAccess List
// appInfoP->dmAccessP = ((SysAppInfoPtr)GSysAppInfoP)->dmAccessP; //DOLATER: really need this?
appInfoP->memOwnerID = 0; // Assume that we're only creating threads for the system

// Set the stack fields
appInfoP->stackP = (UInt8 *) info.stack;
appInfoP->stackEndP = appInfoP->stackP + info.stackSize - 1;


if(PceAllocEmulState(0, &emulStateRef) == errNone)
{
PceSetCurrAppEmulState(emulStateRef);
}

……

}

No comments:

Followers