示例#1
0
文件: vx_osl.c 项目: ariavie/bcm
/* Free some buffers every 1 second */
static void
osl_cachereclaim(void * data)
{
	osl_t *osh = (osl_t *)data;
	uint ticks = TAGCACHE_RECLAIM_TIME / (1000/ sysClkRateGet());
	if (TAGCACHE_RECLAIM_TIME % (1000 / sysClkRateGet()))
		ticks++;

	TAGCACHE_LOCK(osh);
	bcmcache_reclaim(osh->pkttag_memp);
	TAGCACHE_UNLOCK(osh);

	wdStart(osh->cache_wd, ticks, (FUNCPTR) osl_cachereclaim_timer, (int) osh);
}
示例#2
0
/*----------------------------------------------------------------------*/
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
   */

   retrys=0;

   /* start wdog timeout of 7 seconds */ 
#ifdef INOVA
   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);
   }
   wdCancel(pHandlerWdTimeout);
#endif
}
示例#3
0
/* --------------------------------------------------------------------------------------
Name: OS_ShellOutputToFile

Purpose: Takes a shell command in and writes the output of that command to the specified file

Returns: OS_SUCCESS if success
         OS_FS_ERR_INVALID_FD if the file descriptor passed in is invalid
         OS_FS_ERROR if Error
---------------------------------------------------------------------------------------*/
int32 OS_ShellOutputToFile(char* Cmd, int32 OS_fd)
{
    char LocalCmd [OS_MAX_CMD_LEN];
    int32 Result;
    int32 ReturnCode = OS_FS_SUCCESS;
    int32 fdCmd;
    char * shellName;

    /*
    ** Check parameters
    */
    if (Cmd == NULL)
    {
        return(OS_FS_ERR_INVALID_POINTER);
    }

    /* Make sure the file descriptor is legit before using it */
    if (OS_fd < 0 || OS_fd >= OS_MAX_NUM_OPEN_FILES || OS_FDTable[OS_fd].IsValid == FALSE)
    {
        ReturnCode = OS_FS_ERR_INVALID_FD;
    }
    else
    {
        /* Create a file to write the command to (or write over the old one) */
        fdCmd = OS_creat(OS_SHELL_CMD_INPUT_FILE_NAME,OS_READ_WRITE);

        if (fdCmd < OS_FS_SUCCESS)
        {
            Result = OS_FS_ERROR;
        }

        else
        {
            /* copy the command to the file, and then seek back to the beginning of the file */

            strncpy(LocalCmd,Cmd, OS_MAX_CMD_LEN);
            OS_write(fdCmd,Cmd, strlen(LocalCmd));
            OS_lseek(fdCmd,0,OS_SEEK_SET);

            /* Create a shell task the will run the command in the file, push output to OS_fd */
            Result = shellGenericInit("INTERPRETER=Cmd",0,NULL, &shellName, FALSE, FALSE, OS_FDTable[fdCmd].OSfd,	OS_FDTable[OS_fd].OSfd, OS_FDTable[OS_fd].OSfd);

            /* Wait for the command to terminate */
           do{
              taskDelay(sysClkRateGet());
            }while (taskNameToId(shellName) != ERROR);

            /* Close the file descriptor */
            OS_close(fdCmd);

        } /* else */

        if (Result != OK)
        {
             ReturnCode =  OS_FS_ERROR;
        }

    }
    return ReturnCode;
}/* end OS_ShellOutputToFile */
示例#4
0
void periodHost
    (
    int		secs,		/* no. of seconds to delay between calls */
    FUNCPTR	func,		/* function to call repeatedly */
    int		arg1,		/* first of eight args to pass to func */
    int		arg2,		
    int		arg3,	
    int		arg4,
    int		arg5,
    int		arg6,
    int		arg7,
    int		arg8
    )
    {
#if ((CPU_FAMILY == ARM) && ARM_THUMB)
    func = (FUNCPTR)((UINT32)func | 1);
#endif

    FOREVER
	{
	(* func) (arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8);

	taskDelay (secs * sysClkRateGet ());
	}
    }
示例#5
0
/**************************************************************
*
*  dataGetState - Obtains the current DATA Status
*
*  This routines Obtains the status of the DATA via 3 different modes.
*
*   NO_WAIT - return the present value immediately.
*   WAIT_FOREVER - waits till the STM Status has changed 
*			and and returns this new value.
*   TIME_OUT - waits till the STM Status has changed or 
*		    the number of <secounds> has elasped 
*		    (timed out) before returning.
*
*  NOTE: The Task that calls this routine with 
*	 STM_WAIT_FOREVER or STM_TIME_OUT will block !!
*     
*
*
* RETURNS:
* STM state - if no error, TIME_OUT - if in STM_TIME_OUT mode call timed out
*	      or ERROR if called with invalid mode;
*
*/ 
int dataGetState(DATAOBJ_ID pStmId, int mode, int secounds)
{
   int state;

   if (pStmId == NULL)
     return(ERROR);

   switch(mode)
   {
     case NO_WAIT:
          state = pStmId->dataState;
	  break;

     case WAIT_FOREVER: /* block if state has not changed */
	  semTake(pStmId->pSemStateChg, WAIT_FOREVER);  
          state = pStmId->dataState;
	  break;

     case TIME_OUT:     /* block if state has not changed, until timeout */
          if ( semTake(pStmId->pSemStateChg, (sysClkRateGet() * secounds) ) != OK )
	     state = TIME_OUT;
          else 
             state = pStmId->dataState;
          break;

     default:
	  state = ERROR;
	  break;
   }
   return(state);
}
示例#6
0
/*
	OS dependent Open.
 */
int sslOpenOsdep(void)
{
	tickspersec = sysClkRateGet();

	psOpenMalloc(MAX_MEMORY_USAGE);
	return 0;
}
示例#7
0
int adcGetState(ADC_ID pAdcId, int mode, int secounds)
/* ADC_ID pAdcId;   ADC Object */
/* int mode;	    mode of call, see above */
/* int secounds;    number of secounds to wait before timing out */
{
   int state;
   if (pAdcId == NULL)
     return(ERROR);
   switch(mode)
   {
     case NO_WAIT:
          state = pAdcId->adcState;
	  break;

     case WAIT_FOREVER: /* block if state has not changed */
	      semTake(pAdcId->pSemAdcStateChg, WAIT_FOREVER);  
          state = pAdcId->adcState;
	  break;

     case TIME_OUT:     /* block if state has not changed, until timeout */
          if ( semTake(pAdcId->pSemAdcStateChg, (sysClkRateGet() * secounds) ) != OK )
	         state = TIME_OUT;
          else 
             state = pAdcId->adcState;
          break;

     default:
	  state = ERROR;
	  break;
   }
   return(state);
}
示例#8
0
文件: bsp_start.c 项目: iamjy/osal
void OS_BSPMain( void )
{
   int    TicksPerSecond;
   
   /*
   ** Initialize the OS API
   */
   OS_API_Init();

   /* 
   ** Delay for one second. 
   */
   TicksPerSecond = sysClkRateGet();
   (void) taskDelay( TicksPerSecond );

   OS_printf("Starting Up OSAPI App.\n");
   
   /*
   ** Call OSAL entry point.    
   */
   OS_Application_Startup();

   /*
   ** Exit the main thread.
   ** in VxWorks we can delete all of the OS tasks if we want.
   */

}
示例#9
0
/* release semaphore when done  */
int
release_access (short int *sem, double timeout)
{
  int tst;
  ULONG timeout_ticks, start_ticks, current_ticks, elapsed_ticks;
  timeout_ticks = (ULONG) (timeout * sysClkRateGet ());
  start_ticks = tickGet ();
  elapsed_ticks = 0;

  while (elapsed_ticks <= timeout_ticks)
    {
      tst = decrement_read_status (sem);
      if (tst == 0)
	{
	  taskUnlock ();
	  return 0;		/* success */
	}
      else
	{
	  if (tst < 0)
	    {
	      taskUnlock ();
	      rcs_print_error ("invalid semaphore on 0x%x", (int) sem);
	      return -1;	/* invalid semaphore  */
	    }
	}
      current_ticks = tickGet ();
      elapsed_ticks = current_ticks - start_ticks;
    }

  taskUnlock ();
  rcs_print_error ("timed out while releasing access on semphore 0x%x",
		   (int) sem);
  return -1;			/* timeout failure */
}
示例#10
0
文件: socdiag.c 项目: ariavie/bcm
/*
 * Main: start the diagnostics and CLI shell under vxWorks.
 */
void
vxSpawn(void)
{
    extern void diag_shell(void *);

#ifdef WIND_DEBUG
    IMPORT taskDelay(int ticks);
    printf("Waiting for CrossWind attach ...\n");
    taskDelay(sysClkRateGet()*60);
#endif

    sal_core_init();
    sal_appl_init();

#ifdef BCM_BPROF_STATS
    shr_bprof_stats_time_init();
#endif

#ifdef DEBUG_STARTUP
    debugk_select(DEBUG_STARTUP);
#endif
    printk ("SOC BIOS (VxWorks) %s v%s.\n", sysModel(), vxWorksVersion);
    printk ("Kernel: %s.\n", kernelVersion());
    printk ("Made on %s.\n", creationDate);
    sal_thread_create("bcmCLI", 128*1024,100, diag_shell, 0);
    sal_thread_create("bcmLED", 8192, 99, led_beat, 0);
}
void __mg_os_time_delay (int ms)
{
#ifndef __NOUNIX__
    /* use select instead of usleep */
    struct timeval timeout;
    timeout.tv_sec=0;
    timeout.tv_usec=ms*1000;
    while (select (0, NULL, NULL, NULL, &timeout) < 0);
#elif defined (__UCOSII__)
    OSTimeDly (OS_TICKS_PER_SEC * ms / 1000);
#elif defined (__VXWORKS__) 
    taskDelay (sysClkRateGet() * ms / 1000);
#elif defined (__PSOS__) || defined (__ECOS__)
    struct timespec ts;
    ts.tv_sec = 0;
    ts.tv_nsec = ms * 1000000;
    nanosleep (&ts, NULL);
#elif defined (WIN32)
    void __stdcall Sleep (DWORD dwMilliSeconds);
    Sleep (ms);
#elif defined (__THREADX__)
    tx_thread_sleep (ms/10);
#elif defined (__NUCLEUS__)
    NU_Sleep (ms/10);
#elif defined (__OSE__)
    delay(ms);
#endif
}
示例#12
0
/* Test routine, increase avg. cpu load by exactly 50% */
int cpuBurnLoad50(int seconds)
{
    test_wd = wdCreate();
    if (!test_wd) {
        printf("Error: cannot create watchdog timer\n");
        return -1;
    }

    test_sem = semBCreate(SEM_Q_FIFO, SEM_EMPTY);
    if (!test_sem) {
        printf("Error: cannot create semaphore\n");
        wdDelete(test_wd);
        return -1;
    }

    test_ticks = seconds*sysClkRateGet();
    test_burn = FALSE;
    wdStart(test_wd, 1, testTick, 0);
    while (test_ticks) {
        /* sleep for one tick */
        semTake(test_sem, WAIT_FOREVER);
        /* burn cpu for one tick */
        while (test_burn) {
            test_counter++;
        }
    }

    semDelete(test_sem);
    wdDelete(test_wd);
    return 0;
}
/*lint -save -e685 -e568*/
MAILBOX_EXTERN int mailbox_scene_delay(unsigned int scene_id,  int *try_times)
{
    unsigned int go_on = MAILBOX_FALSE;
    unsigned int delay_ms = 0;
    unsigned int ticks = 0;

    switch (scene_id) {
        case MAILBOX_DELAY_SCENE_MSG_FULL:
        case MAILBOX_DELAY_SCENE_IFC_FULL:
            delay_ms = MAILBOX_VXWORKS_SEND_FULL_DELAY_MS;
            /* coverity[unsigned_compare] */
            go_on = (*try_times >= MAILBOX_VXWORKS_SEND_FULL_DELAY_TIMES) ?
                     MAILBOX_FALSE : MAILBOX_TRUE;
            break;
        default:
            break;
    }

    if (MAILBOX_TRUE == go_on) {
        ticks = (delay_ms * sysClkRateGet()) / MAILBOX_MILLISEC_PER_SECOND; /*lint !e737*/
        ticks++;

    #ifndef _DRV_LLT_ /*taskDelay()影响UT覆盖率和测试效率*/
        (void)taskDelay((int)ticks);
    #endif
    }

    *try_times = *try_times + 1;
    return (int)go_on;
}
示例#14
0
int getOmtShimStatus()
{
    int rtn = 0;
    char *buf;
    int i;

    taskDelay(sysClkRateGet() / 10); /* Wait 100ms for any msgs to finish */
    clearport(shimPort);	/* Empty the serial FIFO */
    putstring(shimPort,"\rSTS\r"); /* Ask for status */
    buf = getOmtSerialShimMsg(OMT_STATUS_MSG); /* Read status */
    if (!buf){
	errLogRet(LOGIT,debugInfo,"getOmtShimStatus: No status returned\n");
	rtn = -1;
    }else{
	for (rtn=i=0; i<(8*sizeof(int)); i++, buf++){
	    if (*buf == '+'){
		rtn |= 1 << i;
	    }else if (*buf == '\0'){
		break;
	    }else if (*buf != '.'){
		errLogRet(LOGIT,debugInfo,
			  "getOmtShimStatus: Non-status message received\n");
		break;
	    }
	}
    }
    return rtn;
}
示例#15
0
文件: vsLib.c 项目: andy345/vxworks5
void virtualStackTestDummy
    (
    vsNum
    )
    {

    numTestTasks++;
    
    taskDelay (vsNum * sysClkRateGet());

    printf ("Attempting to set myself to Stack %d\n", vsNum);
    
    if (virtualStackNumTaskIdSet(vsNum) == ERROR)
        {
        printf ("Task for stack %d failed.\n", vsNum);
        return;
        }

    printf ("Task %d has myStackNum of %d\n", vsNum, myStackNum);

    printf ("Task %d has stack info of...\n", vsNum);

    virtualStackInfo (vsTbl[myStackNum]);

    numTestTasks--;
    
    if (numTestTasks == 0)
        semGive(virtualStackTestSem);

    }
//------------------------------------------------------------------------------
tOplkError timeru_delInstance(void)
{
    ULONG               msg;
    tTimeruData*        pTimer;

    /* send message to timer task to signal shutdown */
    msg = 0;
    msgQSend(timeruInstance_l.msgQueue, (char*)&msg, sizeof(ULONG),
             NO_WAIT, MSG_PRI_NORMAL);

    /* wait for timer task to end */
    while (taskIdVerify(timeruInstance_l.taskId) == OK)
        taskDelay(sysClkRateGet());

    /* free up timer list */
    resetTimerList();
    while ((pTimer = getNextTimer()) != NULL)
    {
        hrtimer_delete (pTimer->timer);
        removeTimer(pTimer);
        OPLK_FREE(pTimer);
    }

    /* cleanup resources */
    semDelete(timeruInstance_l.mutex);
    msgQDelete(timeruInstance_l.msgQueue);

    timeruInstance_l.pFirstTimer = NULL;
    timeruInstance_l.pLastTimer = NULL;

    return kErrorOk;
}
示例#17
0
static int printTask(int t1, int t2, int t3, int t4, int t5,
                int t6, int t7, int t8, int t9, int t10)
{
        char msg[LOG_MSGQ_ITEM_LEN+1];
        int l;
        int lastTick;
        int thisTick;
        int Hz;
        int qHz;

        Hz = sysClkRateGet();
        qHz = Hz / 4;
#define LOG_ANNOUNCE_MINUTES 5

        lastTick = (int) tickGet() - (LOG_ANNOUNCE_MINUTES * 61 * Hz);

        while (1) {
            while (!printingLog) taskDelay(qHz);
            l = msgQReceive(MpMisc.LogQ, msg, LOG_MSGQ_ITEM_LEN, VX_WAIT_FOREVER);
            thisTick = (int) tickGet();
            if ((LOG_ANNOUNCE_MINUTES * 60 * Hz) < (thisTick - lastTick)) {
                lastTick = thisTick;
                fprintf(stderr, "MsgLogger: %d.%03d seconds since boot\n",
                    thisTick/Hz, ((thisTick % Hz) * 1000) / Hz);
            }
            if (l > 0) {
                msg[l] = 0;
                fwrite(msg, 1, l, stderr);
            } else {
                osPrintf("\n\nLogger: quitting!\n\n");
                return 0;
            }
        }
}
bool ControleurDAxe::procedureDInitialisation()
{
	float pressionMuscle1 = _pActionneur->pressionMuscle1();
	float pressionMuscle2 = _pActionneur->pressionMuscle2();
	float pressionDeBase  = _pActionneur->pressionDeBase();
	
	//printf("Pression axe : %f %f \n", pressionMuscle1, pressionMuscle2);
	while (pressionMuscle1 < (pressionDeBase + _commandeRepos)|| pressionMuscle2 < (pressionDeBase - _commandeRepos))
  {
    if (pressionMuscle1<(pressionDeBase + _commandeRepos))
			pressionMuscle1 += 0.05;
    else
    	pressionMuscle1 = pressionDeBase + _commandeRepos;

		if (pressionMuscle2<(pressionDeBase - _commandeRepos))
			pressionMuscle2 += 0.05;
    else pressionMuscle2 = pressionDeBase - _commandeRepos;

    _pActionneur->envoyerCommandeDecouplee(pressionMuscle1,pressionMuscle2);
			
    taskDelay(sysClkRateGet()/10);
  }
  _deltaCommande = _commandeRepos;
  //printf("Commande precedente : %f\n", _deltaCommande);
  
  return true;
}
示例#19
0
LOCAL void sysTffsInit (void)
    {
    UINT32 ix = 0;
    UINT32 iy = 1;
    UINT32 iz = 2;
    int oldTick;

    /* we assume followings:
     *   - no interrupts except timer is happening.
     *   - the loop count that consumes 1 msec is in 32 bit.
     * it is done in the early stage of usrRoot() in tffsDrv().  */

    oldTick = tickGet();
    while (oldTick == tickGet())	/* wait for next clock interrupt */
	;

    oldTick = tickGet();
    while (oldTick == tickGet())	/* loop one clock tick */
	{
	iy = KILL_TIME_FUNC;		/* consume time */
	ix++;				/* increment the counter */
	}

    sysTffsMsecLoopCount = ix * sysClkRateGet() / 1000;

    /* TODO:
     * Call each sockets register routine here
     */

    rfaRegister ();	/* RFA socket interface register */
    }
示例#20
0
LOCAL void timexScale
    (
    int ticks,          /* total ticks required for all reps */
    int reps,           /* number of reps performed */
    FAST int *pScale,   /* ptr where to return scale:
                         *   0 = secs, 1 = millisecs, 2 = microsecs */
    FAST int *pTime,    /* ptr where to return time per rep in above units */
    int *pError,        /* ptr where to return error margin in above units */
    int *pPercent       /* ptr where to return percent error (0..100) */
    )
    {
    FAST int scalePerSec;

    /* calculate time per rep in best scale */

    *pScale = 0;		/* start with "seconds" scale */
    scalePerSec = 1;

    *pTime = ticks * scalePerSec / sysClkRateGet () / reps;

    while ((*pScale < 2) && (*pTime < 100))
	{
	(*pScale)++;
	scalePerSec = scalePerSec * 1000;
	*pTime = ticks * scalePerSec / sysClkRateGet () / reps;
	}


    /* adjust for overhead if in microseconds scale */

    if (*pScale == 2)
	{
	*pTime -= overhead;
	if (*pTime < 0)
	    *pTime = 0;
	}


    /* calculate error */

    *pError = scalePerSec / sysClkRateGet () / reps;

    if (*pTime == 0)
	*pPercent = 100;
    else
	*pPercent = 100 * *pError / *pTime;
    }
示例#21
0
static double tm_Time_F(int s)
	{
	static double ret;
#ifdef TIMES
	static struct tms tstart,tend;

	if(s == START) {
		//times(&tstart); shilps
		return(0);
	} else {
		//times(&tend); shilpa
		ret=((double)(tend.tms_utime-tstart.tms_utime))/HZ;
		return((ret == 0.0)?1e-6:ret);
	}
#elif defined(OPENSSL_SYS_NETWARE)
    static clock_t tstart,tend;

    if (s == START)
    {
        tstart=clock();
        return(0);
    }
    else
    {
        tend=clock();
        ret=(double)((double)(tend)-(double)(tstart));
        return((ret < 0.001)?0.001:ret);
    }
#elif defined(OPENSSL_SYS_VXWORKS)
        {
	static unsigned long tick_start, tick_end;

	if( s == START )
		{
		tick_start = tickGet();
		return 0;
		}
	else
		{
		tick_end = tickGet();
		ret = (double)(tick_end - tick_start) / (double)sysClkRateGet();
		return((ret == 0.0)?1e-6:ret);
		}
        }
#else /* !times() */
	static struct timeb tstart,tend;
	long i;

	if(s == START) {
		ftime(&tstart);
		return(0);
	} else {
		ftime(&tend);
		i=(long)tend.millitm-(long)tstart.millitm;
		ret=((double)(tend.time-tstart.time))+((double)i)/1000.0;
		return((ret == 0.0)?1e-6:ret);
	}
#endif
}
示例#22
0
void sysAuxClkInit(void)
{
	if((auxDog = wdCreate()) == NULL){
		logMsg("watchDog create failed!\n", 0, 0, 0, 0, 0, 0);
		return;
	}
	sysAuxClkTicksPerSecond = sysClkRateGet();
}
示例#23
0
文件: control.cpp 项目: wycstar/JL3
STATUS control::exit() const
{
	CAN_PACKET sendPack,recvPack;
	memset(&sendPack,0,CP_SIZE);
	memset(&recvPack,0,CP_SIZE);
	driverDisable(ERROR_ALL_NODE);
	faultLEDControl(false,ERROR_ALL_NODE);
	taskDelay(sysClkRateGet() / 2);
	GV::isStopAll = TRUE;
	taskDelay(sysClkRateGet() / 2);
	can.release();
	net.release();
	digitalIO.release();
	DISPLAY_FAULT("关机退出!");
	file.writeLogFile("关机退出!");
	return OK;
}
示例#24
0
/*
 * =====================================================================
 * Function:getSysClkRate()
 * Description: Get system clock Rate, times/second
 * Input:   N/A
 * Output:  N/A
 * Return:  clock rate(perSecond) on SUCCESS, -1 otherwise.
 *======================================================================
 */
int getSysClkRate(void)
{
#ifdef LINUX_OS
    return 100;
#elif VXWORKS_OS
    return sysClkRateGet();
#endif
}
示例#25
0
void
tsleep(int n)
{
#ifdef VXWORKS
  taskDelay ((sysClkRateGet() / NTICKS) * n);
#else
#endif
}
示例#26
0
UGL_LOCAL void initGL (GLsizei width, GLsizei height)
    {
    UGL_LOCAL GLfloat pos[4] = {5.0, 5.0, 10.0, 1.0 };
    UGL_LOCAL GLfloat red[4] = {0.8, 0.1, 0.0, 1.0 };
    UGL_LOCAL GLfloat green[4] = {0.0, 0.8, 0.2, 1.0 };
    UGL_LOCAL GLfloat blue[4] = {0.2, 0.2, 1.0, 1.0 };

    glLightfv (GL_LIGHT0, GL_POSITION, pos);
    glEnable (GL_CULL_FACE);
    glEnable (GL_LIGHTING);
    glEnable (GL_LIGHT0);
    glEnable (GL_DEPTH_TEST);

    /* make the gears */
    gear1 = glGenLists (1);
    glNewList (gear1, GL_COMPILE);
    glMaterialfv (GL_FRONT, GL_AMBIENT_AND_DIFFUSE, red);
    gear (1.0, 4.0, 1.0, 20, 0.7);
    glEndList ();

    gear2 = glGenLists (1);
    glNewList (gear2, GL_COMPILE);
    glMaterialfv (GL_FRONT, GL_AMBIENT_AND_DIFFUSE, green);
    gear (0.5, 2.0, 2.0, 10, 0.7);
    glEndList ();

    gear3 = glGenLists (1);
    glNewList (gear3, GL_COMPILE);
    glMaterialfv (GL_FRONT, GL_AMBIENT_AND_DIFFUSE, blue);
    gear (1.3, 2.0, 0.5, 10, 0.7);
    glEndList ();

    glEnable (GL_NORMALIZE);

    glViewport (0, 0, width, height);

    glMatrixMode (GL_PROJECTION);
    glLoadIdentity ();
    if (width>height)
        {
	GLfloat w = (GLfloat) width / (GLfloat) height;
	glFrustum (-w, w, -1.0, 1.0, 5.0, 60.0);
        }
    else
        {
	GLfloat h = (GLfloat) height / (GLfloat) width;
	glFrustum (-1.0, 1.0, -h, h, 5.0, 60.0);
        }

    glMatrixMode (GL_MODELVIEW);
    glLoadIdentity ();
    glTranslatef (0.0, 0.0, -40.0);

#ifdef COUNT_FRAMES
    tickStart = tickGet ();
    tickBySec = sysClkRateGet ();
#endif
}
示例#27
0
bool EventImpl::waitImpl(long milliseconds)
{
	if (!_state)
	{
		int ticks = milliseconds*sysClkRateGet()/1000;
		return semTake(_sem, ticks) == OK;
	}
	else return true;
}
示例#28
0
/*----------------------------------------------------------------------*/
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(); */
}
void bhs_MutexRobot::infiniteTimerTask() {
	int lnTicksToWaitBetweenRobotCycles = sysClkRateGet() / 25;

	semTake(m_startSem, WAIT_FOREVER);
	while (true) {
		semGive(m_periodSem);
		taskDelay(lnTicksToWaitBetweenRobotCycles);
	}
}
示例#30
0
文件: vx_osl.c 项目: ariavie/bcm
/* Start the 1 second timer */
static bool
osl_cachereclaim_timer_start(osl_t *osh)
{
	uint ticks;

	if ((osh->cache_lock = semBCreate(SEM_Q_FIFO, SEM_FULL)) == NULL)
		return FALSE;

	if ((osh->cache_wd = wdCreate()) == NULL)
		return FALSE;

	ticks = TAGCACHE_RECLAIM_TIME / (1000/ sysClkRateGet());
	if (TAGCACHE_RECLAIM_TIME % (1000 / sysClkRateGet()))
		ticks++;

	if ((wdStart(osh->cache_wd, ticks, (FUNCPTR) osl_cachereclaim_timer, (int) osh)) != OK)
		return FALSE;
	return TRUE;
}