/*----------------------------------------------------------------------*/ static void resetNameBufs() /* free all named buffers */ { int retrys; int callTaskId,DwnLkrTaskId; int callTaskPrior; /* Since reset2SafeState should have left the downLinker in a ready state we now longer need change priority/etc. here to get it to clean up. 8/6/97 */ #ifdef XXX callTaskId = taskIdSelf(); DwnLkrTaskId = taskNameToId("tDownLink"); taskPriorityGet(callTaskId,&callTaskPrior); #endif retrys=0; /* start wdog timeout of 7 seconds */ pHandlerTimeout = 0; wdStart(pHandlerWdTimeout,sysClkRateGet() * 7, pHandlerWdISR, 0); /* free buffers until all are free or watch-dog timeout has occurred */ while ( ((dlbUsedBufs(pDlbDynBufs) > 0) || (dlbUsedBufs(pDlbFixBufs) > 0)) && (!pHandlerTimeout) ) { retrys++; DPRINT(0,"dlbFreeAll Dyn"); dlbFreeAll(pDlbDynBufs); DPRINT(0,"dlbFreeAll Fix"); dlbFreeAll(pDlbFixBufs); Tdelay(1); DPRINT1(0,"resetNameBufs: retrys: %d\n",retrys); #ifdef XXX /* Lower priority to allow downlinker in */ if (callTaskPrior <= DOWNLINKER_TASK_PRIORITY) taskPrioritySet(callTaskId,(DOWNLINKER_TASK_PRIORITY+1)); Tdelay(10); DPRINT1(-1,"resetNameBufs: retrys: %d\n",retrys); if (retrys > 7) { if (taskIsSuspended(DwnLkrTaskId)) { DPRINT(-1,"resetNameBufs: clearCurrentNameBuffer()\n"); clearCurrentNameBuffer(); } } #endif } wdCancel(pHandlerWdTimeout); /* taskPrioritySet(callTaskId,callTaskPrior); */ /* resumeDownLink(); */ }
/** * Returns true if the task was explicitly suspended by calling Suspend() * @return true if suspended, false if not suspended. */ bool Task::IsSuspended() { return taskIsSuspended(m_taskID); }
static void reset2SafeState( int why ) /* argument is the type of exception */ { int pTmpId, TmpPrior; int tuneactive = 0; DPRINT(1,"reset2SafeState"); DPRINT(1,"stopAPint"); pcsAbortSort(); /* parallel channel sort to stop and return to APint() */ abortAPint(); /* like stopAPint() but also cause the Parser to suspend itself */ /* stopAPint(); */ DPRINT(1,"stop downLinker"); setDwnLkAbort(); /* like stop downLinker and set to dump further download to bit bucket */ DPRINT(1,"reset2SafeState"); DPRINT(0,"fifoSetNoStuff\n"); fifoSetNoStuff(pTheFifoObject); /* stop the stuffer in it's tracks */ DPRINT(0,"Disable STM Intrps"); stmItrpDisable(pTheStmObject, STM_ALLITRPS); /* reset fifo Object not to use parallel channels */ fifoClearPChanId(pTheFifoObject); DPRINT(0,"fifoReset"); /* Keep the MTS gradient amp disabled whenever possible! */ gpaTuneSet(pTheAutoObject, SET_GPAENABLE, GPA_DISABLE_DELAY); /* if an interactive abort do not reset the apbus, thus preventing the all amplifier from going to Pulse Mode, thus amps that are in CW will stay that way. This is/was a lockdisplay/shimming issue. Where exiting lock display set all the amps to Pulse Mode or blanked!, then one shimmed and obtain a certain lock level. After su command then amps would go back to CW thus injecting noise and lowing the lock level, If use wht directly to shimming they could neer re-attain the lock level they had before. But when enter and exit lock display the level would jump back up. Thus causing no end of confusion.... Thus for INTERACTIVE_ABORT the reset apbus bit is left out when reseting the FIFO. Oooops, but wait, we found an exception (of course), when exiting qtune the reset of the apbus reset all the tune relays back to noraml, now of course this does not happen thus leaving the console in tuning mode. Thus we added the following test isTuneActive() and if it is then a full reset including the apbus is done. */ tuneactive = isTuneActive(); /* DPRINT1(-3,"Is Tune active: %d\n",tuneactive); */ if ((why != INTERACTIVE_ABORT) || (tuneactive == 1)) fifoReset(pTheFifoObject, RESETFIFOBRD); /* this now also clear the Fifo Buffer & restart the Stuffer */ else fifoReset(pTheFifoObject, RESETFIFO | RESETSTATEMACH | RESETTAGFIFO | RESETAPRDBKFIFO ); /* no apbus reset */ /* set initial value of parallel channel free buffer pointer to null */ clearParallelFreeBufs(); DPRINT(0,"Stuff FIFO DIRECTLY with Safe State & Run fifo"); fifoLoadHsl(pTheFifoObject, STD_HS_LINES, pTheFifoObject->SafeHSLines); fifoLoadHsl(pTheFifoObject, EXT_HS_LINES, pTheFifoObject->SafeHSLinesExt); /* Each SafeState Code is actually two long words */ if (numSafeStatCodes > 0) { /* WARNING: Does not pend for FF Almost Full, BEWARE !! */ /* Should only be used in phandler's reset2SafeState() */ fifoStuffCode(pTheFifoObject, pSafeStateCodes, numSafeStatCodes); fifoStuffCode(pTheFifoObject, pTurnOffSshaCodes, numTurnOffSshaCodes); fifoStuffCode(pTheFifoObject, pHaltOpCodes, numHaltOpCodes); DPRINT(1,"Ready to start FIFO in reset to safe state\n" ); fifoStart(pTheFifoObject); /* fifoWait4Stop(pTheFifoObject); /* use BusyWait don't what any other lower priority tasks to run ! */ fifoBusyWait4Stop(pTheFifoObject); /* use BusyWait don't what any other lower priority tasks to run ! */ DPRINT(1,"FIFO wait for stop completes in reset to safe state\n" ); } activate_ssha(); DPRINT(0,"getnGiveShimMutex\n"); /* allow any pending serial Shim commands to finish */ getnGiveShimMutex(); DPRINT(0,"getnGiveVTMutex\n"); /* allow any pending serial VT commands to finish */ getnGiveVTMutex(); /* Now Bump Priority of DownLiner so that it can Dump the remaining Data that SendProc wants to send it */ /* If we lost the connection to the host computer, the downlinker is is not going to get any more data; nor should this task (problem handler) wait for the downlinker to become ready. April 1997 */ DPRINT(0,"dlbFreeAllNotLoading Dyn"); dlbFreeAllNotLoading(pDlbDynBufs); DPRINT(0,"dlbFreeAllNotLoading Fix"); dlbFreeAllNotLoading(pDlbFixBufs); if (why != LOST_CONN) { pTmpId = taskNameToId("tDownLink"); taskPriorityGet(pTmpId,&TmpPrior); taskPrioritySet(pTmpId,(pHandlerPriority-1)); /* downLinker has now A. ran and is suspended, B. Done and in READY state or C. still waiting in a read of a socket */ /* start wdog timeout of 20 seconds */ wdStart(pHandlerWdTimeout,sysClkRateGet() * 20, pHandlerWdISR, 0); /* if it is busy and not suspend then wait till /* it is Ready or Suspended, or Time-Out */ while (downLinkerIsActive() && !taskIsSuspended(pTmpId) && !pHandlerTimeout) taskDelay(1); /* wait one tick , 16msec */ wdCancel(pHandlerWdTimeout); if (taskIsSuspended(pTmpId)) { taskResume(pTmpId); wait4DownLinkerReady(); } taskPrioritySet(pTmpId,TmpPrior); DPRINT(0,"downlinker resynchronized\n"); } DPRINT(0,"dlbFreeAll Dyn"); dlbFreeAll(pDlbDynBufs); DPRINT(0,"dlbFreeAll Fix"); dlbFreeAll(pDlbFixBufs); /* Now Bump Priority of Parser so that it can Finish Up We don't have to worry as much about the state of the parser since it will completely restarted very soon. */ pTmpId = taskNameToId("tParser"); taskPriorityGet(pTmpId,&TmpPrior); taskPrioritySet(pTmpId,(pHandlerPriority-1)); if (taskIsSuspended(pTmpId)) { taskResume(pTmpId); wait4ParserReady(); } taskPrioritySet(pTmpId,TmpPrior); resetAPint(); DPRINT(0,"A-code parser resynchronized\n"); /* Parser might of made a buffer ready to stuff, so better clear it just incase */ if (why != INTERACTIVE_ABORT) fifoReset(pTheFifoObject, RESETFIFOBRD); /* this now also clear the Fifo Buffer & restart the Stuffer */ else fifoReset(pTheFifoObject, RESETFIFO | RESETSTATEMACH | RESETTAGFIFO | RESETAPRDBKFIFO ); /* no apbus reset */ return; }
void rootTask (long a0, long a1, long a2, long a3, long a4, long a5, long a6, long a7, long a8, long a9) { WIND_TCB *pTcb; TEST_START(0); pTcb = taskTcb(taskIdSelf()); TEST_ASSERT(pTcb != NULL); bsemid = semBCreate(0xffffffff,0); TEST_ASSERT(bsemid == 0 && errno == S_semLib_INVALID_QUEUE_TYPE); bsemid = semBCreate(SEM_Q_PRIORITY,0); TEST_ASSERT(bsemid != 0); mutexid = semMCreate(0xffffffff); TEST_ASSERT(mutexid == 0 && errno == S_semLib_INVALID_QUEUE_TYPE); mutexid = semMCreate(SEM_Q_PRIORITY|SEM_DELETE_SAFE|SEM_INVERSION_SAFE); TEST_ASSERT(mutexid != 0); taskSpawn("Test1", 20, /* low-pri */ 0, 32768, sem1Task, taskIdSelf(),0,0,0,0,0,0,0,0,0); taskSpawn("Test2", 10, /* intermediate-pri */ 0, 32768, sem2Task, taskIdSelf(),0,0,0,0,0,0,0,0,0); /* This runs at high-pri */ TEST_MARK(); TEST_ASSERT_OK(semTake(bsemid,WAIT_FOREVER)); TEST_MARK(); TEST_ASSERT_OK(taskSuspend(0)); TEST_MARK(); TEST_ASSERT_OK(semTake(mutexid,WAIT_FOREVER)); TEST_MARK(); TEST_ASSERT_OK(semGive(mutexid)); TEST_MARK(); TEST_ASSERT(taskIsReady(taskNameToId("Test2"))); TEST_ASSERT(!taskIsSuspended(taskNameToId("Test2"))); TEST_ASSERT_OK(taskDelay(1)); TEST_MARK(); TEST_CHECK_SEQUENCE(SEQ("root",1), SEQ("Test2",1), SEQ("root",1), SEQ("Test2",1), SEQ("Test1",2), SEQ("Test2",1), SEQ("root",1), SEQ("Test1",1), SEQ("root",2), SEQ("Test2",1), SEQ("root",1), END_SEQ); TEST_FINISH(); }