Beispiel #1
0
tstbarrier()
{
    int i;
    int retval;
   int pTmpId, TmpPrior;
    int status;

   pTmpId = taskIdSelf();
   taskPriorityGet(pTmpId,&TmpPrior);
   taskPrioritySet(pTmpId,132);
   status = nddsPublicationIssuesWait(pUploadSyncPub, 5, 0);
   if ( status == -1)
        DPRINT(-1,"sendDDRSync: error in waiting\n");
    for(i=0; i < 100; i++)
    {
       /* DPRINT1(-1," %d: call barrier wait\n",i); */
       retval = barrierWait();
       if (retval == 42)
          DPRINT1(-1,">>>> %d: <<<<<<   returned from barrier wait\n",i);
    }
   taskPrioritySet(pTmpId,TmpPrior);
}
Beispiel #2
0
LOCAL int translatePriority
    (
    UINT16 priority
    )

    {
    int curPriority;

    switch (priority)
	{
	case OSS_PRIORITY_LOW:
	case OSS_PRIORITY_TYPICAL:
	case OSS_PRIORITY_HIGH:
	case OSS_PRIORITY_INTERRUPT:

	    return priority;

	case OSS_PRIORITY_INHERIT:
	default:

	    taskPriorityGet (0, &curPriority);
	    return curPriority;
	}
    }
Beispiel #3
0
PUBLIC IxPerfProfAccStatus
ixPerfProfAccXcycleBaselineRun(
                   UINT32 *numBaselineCycle)
{
    int i,
        priority ;      /* task priority. Value is OS dependent */
    UINT32 interruptLockKey;

    UINT32 temp,
        startTime,      /* used to store start time */
        stopTime,       /* used to store stop time */
        duration;       /* difference between stop and start time */

#ifdef __vxworks
    IxOsalThread threadId;
    IX_STATUS result;
#endif

    /*error check the parameter*/
    if (NULL == numBaselineCycle)
    {
	/* report the error */ 
        IX_PERFPROF_ACC_LOG(
            IX_OSAL_LOG_LVL_ERROR, IX_OSAL_LOG_DEV_STDERR,
            "ixPerfProfAccXcycleBaselineRun - numBaselineCycle is invalid\n",
            0, 0, 0, 0, 0, 0);
	/* return error */
        return IX_PERFPROF_ACC_STATUS_FAIL;
    }

    if (IX_PERFPROF_ACC_STATUS_ANOTHER_UTIL_IN_PROGRESS
        == ixPerfProfAccLock())
    {
        return IX_PERFPROF_ACC_STATUS_ANOTHER_UTIL_IN_PROGRESS;
    }

    /*
     * If the tool is running, then do not allow baselining to progress
     */
    if (ixPerfProfAccXcycleMeasurementInProgress)
    {
        ixPerfProfAccUnlock();
        return IX_PERFPROF_ACC_STATUS_XCYCLE_MEASUREMENT_IN_PROGRESS;
    }

    /*
     * Find out how many loops is needed to to complete
     * 1/IX_PERFPROF_ACC_XCYCLE_TIME_SLICES_PER_SEC seconds
     */
    ixNumLoopPerTimeSlice= ixPerfProfAccXcycleComputeLoopsPerSlice();

    /*
     * Disable interrupts so that no ISR can run. We get all the CPU
     * cycles.
     */
    interruptLockKey = ixOsalIrqLock();

#ifdef __linuxapp
    priority = getpriority(PRIO_PROCESS,0);
    if(0 != setpriority( PRIO_PROCESS, 0,
            IX_PERFPROF_ACC_XCYCLE_LINUXAPP_PRIORITY_HIGHEST )
            )
    {
        ixPerfProfAccUnlock();
        return IX_PERFPROF_ACC_STATUS_XCYCLE_PRIORITY_SET_FAIL;
    }

#else

    result = ixOsalThreadIdGet (&threadId);
    if (IX_SUCCESS != result)
    {
        ixPerfProfAccUnlock();
        return IX_PERFPROF_ACC_STATUS_XCYCLE_PRIORITY_SET_FAIL;
    }
    taskPriorityGet (threadId, &priority);
    result = ixOsalThreadPrioritySet (
            &threadId,
            IX_PERFPROF_ACC_XCYCLE_VXWORKS_PRIORITY_HIGHEST );
    if (IX_SUCCESS != result)
    {
        return IX_PERFPROF_ACC_STATUS_XCYCLE_PRIORITY_SET_FAIL;
    }
#endif

    /*
     * Perform a measure of time needed for one measurement without
     * load.
     */
    startTime = ixPerfProfAccXcycleApbTimerGet();
    for (i = 0; IX_PERFPROF_ACC_XCYCLE_TIME_SLICES_PER_SEC > i; i++)
    {
        temp = ixNumLoopPerTimeSlice;
        ixPerfProfAccXcycleLoopIter(temp);
    }
    stopTime = ixPerfProfAccXcycleApbTimerGet();

    /*
     * Rollover situation is handled through the fact that the different
     * between start and stop time is a fraction of 32bit storage
     * The duration of time stored in 32 bits is 65 sec
     * We expect difference between start and stop time to be
     * ~ 1 sec
     */
    duration = stopTime - startTime;

    ixOsalIrqUnlock(interruptLockKey);

#ifdef __linuxapp
    if(setpriority(PRIO_PROCESS, 0, priority) != 0)
    {
        ixPerfProfAccUnlock();
        return IX_PERFPROF_ACC_STATUS_XCYCLE_PRIORITY_RESTORE_FAIL;
    }
#else /* ifdef __linuxapp */
    /*
     * Restore the calling thread to previous priority
     */
    result = ixOsalThreadPrioritySet (&threadId, priority);

    if (IX_SUCCESS != result)
    {
        ixPerfProfAccUnlock();
        return IX_PERFPROF_ACC_STATUS_XCYCLE_PRIORITY_RESTORE_FAIL;
    }

#endif /* ifdef __linuxapp */

    ixPerfProfAccXcycleCurrentBaseline = duration;
    *numBaselineCycle = duration;
    ixPerfProfAccUnlock();
    return IX_PERFPROF_ACC_STATUS_SUCCESS ;
} /* end of ixPerfProfAccXcycleBaselineRun() */
Beispiel #4
0
/*
    Launch the CGI process and return a handle to it. Process spawning is not supported in VxWorks.  Instead, we spawn a
    "task".  A major difference is that we have to know the entry point for the taskSpawn API.  Also the module may have
    to be loaded before being executed; it may also be part of the OS image, in which case it cannot be loaded or
    unloaded.  
    The following sequence is used:
    1. If the module is already loaded, unload it from memory.
    2. Search for a query string keyword=value pair in the environment variables where the keyword is cgientry.  If
        found use its value as the the entry point name.  If there is no such pair set the entry point name to the
        default: basename_cgientry, where basename is the name of the cgi file without the extension.  Use the entry
        point name in a symbol table search for that name to use as the entry point address.  If successful go to step 5.
    3. Try to load the module into memory.  If not successful error out.
    4. If step 3 is successful repeat the entry point search from step 2. If the entry point exists, go to step 5.  If
        it does not, error out.
    5. Use taskSpawn to start a new task which uses vxWebsCgiEntry as its starting point. The five arguments to
        vxWebsCgiEntry will be the user entry point address, argp, envp, stdIn and stdOut.  vxWebsCgiEntry will convert
        argp to an argc argv pair to pass to the user entry, it will initialize the task environment with envp, it will
        open and redirect stdin and stdout to stdIn and stdOut, and then it will call the user entry.
    6.  Return the taskSpawn return value.
 */
static int launchCgi(char *cgiPath, char **argp, char **envp, char *stdIn, char *stdOut)
{
    SYM_TYPE    ptype;
    char      *p, *basename, *pEntry, *pname, *entryAddr, **pp;
    int         priority, rc, fd;

    /*
        Determine the basename, which is without path or the extension.
     */
    if ((int)(p = strrchr(cgiPath, '/') + 1) == 1) {
        p = cgiPath;
    }
    basename = sclone(p);
    if ((p = strrchr(basename, '.')) != NULL) {
        *p = '\0';
    }
    /*
        Unload the module, if it is already loaded.  Get the current task priority.
     */
    unld(cgiPath, 0);
    taskPriorityGet(taskIdSelf(), &priority);
    rc = fd = -1;

    /*
         Set the entry point symbol name as described above.  Look for an already loaded entry point; if it exists, spawn
         the task accordingly.  
     */
    for (pp = envp, pEntry = NULL; pp != NULL && *pp != NULL; pp++) {
        if (strncmp(*pp, "cgientry=", 9) == 0) {
            pEntry = sclone(*pp + 9);
            break;
        }
    }
    if (pEntry == NULL) {
        pEntry = sfmt("%s_%s", basename, "cgientry");
    }
    entryAddr = 0;
    if (symFindByName(sysSymTbl, pEntry, &entryAddr, &ptype) == -1) {
        pname = sfmt("_%s", pEntry);
        symFindByName(sysSymTbl, pname, &entryAddr, &ptype);
        wfree(pname);
    }
    if (entryAddr != 0) {
        rc = taskSpawn(pEntry, priority, 0, 20000, (void*) vxWebsCgiEntry, (int) entryAddr, (int) argp, 
            (int) envp, (int) stdIn, (int) stdOut, 0, 0, 0, 0, 0);
        goto done;
    }

    /*
        Try to load the module.
     */
    if ((fd = open(cgiPath, O_RDONLY | O_BINARY, 0666)) < 0 ||
        loadModule(fd, LOAD_GLOBAL_SYMBOLS) == NULL) {
        goto done;
    }
    if ((symFindByName(sysSymTbl, pEntry, &entryAddr, &ptype)) == -1) {
        pname = sfmt("_%s", pEntry);
        symFindByName(sysSymTbl, pname, &entryAddr, &ptype);
        wfree(pname);
    }
    if (entryAddr != 0) {
        rc = taskSpawn(pEntry, priority, 0, 20000, (void*) vxWebsCgiEntry, (int) entryAddr, (int) argp, 
            (int) envp, (int) stdIn, (int) stdOut, 0, 0, 0, 0, 0);
    }
done:
    if (fd != -1) {
        close(fd);
    }
    wfree(basename);
    wfree(pEntry);
    return rc;
}
Beispiel #5
0
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;
}
Beispiel #6
0
int websLaunchCgiProc(char_t *cgiPath, char_t **argp, char_t **envp,
					  char_t *stdIn, char_t *stdOut)
{
	SYM_TYPE	ptype;
	char_t		*p, *basename, *pEntry, *pname, *entryAddr, **pp;
	int			priority, rc, fd;

/*
 *	Determine the basename, which is without path or the extension.
 */
	if ((int)(p = gstrrchr(cgiPath, '/') + 1) == 1) {
		p = cgiPath;
	}
	basename = bstrdup(B_L, p);
	if ((p = gstrrchr(basename, '.')) != NULL) {
		*p = '\0';
	}

/*
 *	Unload the module, if it is already loaded.  Get the current task
 *	priority.
 */
	unld(cgiPath, 0);
	taskPriorityGet(taskIdSelf(), &priority);
	rc = fd = -1;

/*
 *	Set the entry point symbol name as described above.  Look for an already
 *	loaded entry point; if it exists, spawn the task accordingly.
 */
	for (pp = envp, pEntry = NULL; pp != NULL && *pp != NULL; pp++) {
		if (gstrncmp(*pp, T("cgientry="), 9) == 0) {
			pEntry = bstrdup(B_L, *pp + 9);
			break;
		}
	}
	if (pEntry == NULL) {
		fmtAlloc(&pEntry, LF_PATHSIZE, T("%s_%s"), basename, T("cgientry"));
	}

	entryAddr = 0;
	if (symFindByName(sysSymTbl, pEntry, &entryAddr, &ptype) == -1) {
		fmtAlloc(&pname, VALUE_MAX_STRING, T("_%s"), pEntry);
		symFindByName(sysSymTbl, pname, &entryAddr, &ptype);
		bfreeSafe(B_L, pname);
	}
	if (entryAddr != 0) {
		rc = taskSpawn(pEntry, priority, 0, 20000, (void *)vxWebsCgiEntry,
			(int)entryAddr, (int)argp, (int)envp, (int)stdIn, (int)stdOut,
			0, 0, 0, 0, 0);
		goto DONE;
	}

/*
 *	Try to load the module.
 */
	if ((fd = gopen(cgiPath, O_RDONLY | O_BINARY, 0666)) < 0 ||
		loadModule(fd, LOAD_GLOBAL_SYMBOLS) == NULL) {
		goto DONE;
	}
	if ((symFindByName(sysSymTbl, pEntry, &entryAddr, &ptype)) == -1) {
		fmtAlloc(&pname, VALUE_MAX_STRING, T("_%s"), pEntry);
		symFindByName(sysSymTbl, pname, &entryAddr, &ptype);
		bfreeSafe(B_L, pname);
	}
	if (entryAddr != 0) {
		rc = taskSpawn(pEntry, priority, 0, 20000, (void *)vxWebsCgiEntry,
			(int)entryAddr, (int)argp, (int)envp, (int)stdIn, (int)stdOut,
			0, 0, 0, 0, 0);
	}

DONE:
	if (fd != -1) {
		gclose(fd);
	}
	bfree(B_L, basename);
	bfree(B_L, pEntry);
	return rc;
}
Beispiel #7
0
/*
    Start the command to run (stdIn and stdOut are named from the client's perspective)
 */
int startProcess(MprCmd *cmd)
{
    MprCmdTaskFn    entryFn;
    SYM_TYPE        symType;
    char            *entryPoint, *program;
    int             i, pri;

    mprLog(cmd, 4, "cmd: start %s", cmd->program);

    entryPoint = 0;
    if (cmd->env) {
        for (i = 0; cmd->env[i]; i++) {
            if (strncmp(cmd->env[i], "entryPoint=", 11) == 0) {
                entryPoint = mprStrdup(cmd, cmd->env[i]);
            }
        }
    }
    program = mprGetPathBase(cmd, cmd->program);
    if (entryPoint == 0) {
        program = mprTrimPathExtension(cmd, program);
#if BLD_HOST_CPU_ARCH == MPR_CPU_IX86 || BLD_HOST_CPU_ARCH == MPR_CPU_IX64
        entryPoint = mprStrcat(cmd, -1, "_", program, "Main", NULL);
#else
        entryPoint = mprStrcat(cmd, -1, program, "Main", NULL);
#endif
    }

    if (symFindByName(sysSymTbl, entryPoint, (char**) &entryFn, &symType) < 0) {
        if (mprLoadModule(cmd, cmd->program, NULL) == 0) {
            mprError(cmd, "start: can't load DLL %s, errno %d", program, mprGetOsError());
            return MPR_ERR_CANT_READ;
        }
        if (symFindByName(sysSymTbl, entryPoint, (char**) &entryFn, &symType) < 0) {
            mprError(cmd, "start: can't find symbol %s, errno %d", entryPoint, mprGetOsError());
            return MPR_ERR_CANT_ACCESS;
        }
    }
    taskPriorityGet(taskIdSelf(), &pri);

    /*
     *  Pass the server output file to become the client stdin.
     */
    cmd->pid = taskSpawn(entryPoint, pri, VX_FP_TASK, MPR_DEFAULT_STACK, (FUNCPTR) cmdTaskEntry, 
        (int) cmd->program, (int) entryFn, (int) cmd, 0, 0, 0, 0, 0, 0, 0);

    if (cmd->pid < 0) {
        mprError(cmd, "start: can't create task %s, errno %d", entryPoint, mprGetOsError());
        mprFree(entryPoint);
        return MPR_ERR_CANT_CREATE;
    }

    mprLog(cmd, 7, "cmd, child taskId %d", cmd->pid);
    mprFree(entryPoint);

    if (semTake(cmd->startCond, MPR_TIMEOUT_START_TASK) != OK) {
        mprError(cmd, "start: child %s did not initialize, errno %d", cmd->program, mprGetOsError());
        return MPR_ERR_CANT_CREATE;
    }
    semDelete(cmd->startCond);
    cmd->startCond = 0;

    return 0;
}