/* 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; }
int pocoregress_init() { long t1, t2; WDOG_ID wd; wd = wdCreate(); if (!wd) { logMsg("cannot create watchdog\n"); return 0; } sem = semBCreate(0, SEM_EMPTY); if (!sem) { logMsg("cannot create semaphore\n"); return 0; } logMsg("waiting %d ticks...\n", 10); t1 = tickGet(); wdStart(wd, 10, wddone, 0); semTake(sem, WAIT_FOREVER); t2 = tickGet(); logMsg("watchodog triggered after %d ticks (should be %d)\n", t2-t1, 10); wdDelete(wd); return 0; }
STATUS i8042MseDrvInit( void ) { STATUS status; if (i8042MseLibInstalled == TRUE) { status = OK; } else { i8042Wdid = wdCreate(); if (i8042Wdid == NULL) { status = ERROR; } else { i8042MseLibInstalled = TRUE; status = OK; } } return status; }
void sysAuxClkInit(void) { if((auxDog = wdCreate()) == NULL){ logMsg("watchDog create failed!\n", 0, 0, 0, 0, 0, 0); return; } sysAuxClkTicksPerSecond = sysClkRateGet(); }
DiaTimer :: DiaTimer(StateMachine * stateMachine) { myStateMachine = stateMachine; // Assign pointer of parent state machnine class #ifdef POSIX timer_create (CLOCK_REALTIME, NULL, &myTimer); #else timerId = wdCreate(); // Create the VxWorks Watchdog timer #endif return; }
startPhandler(int priority, int taskoptions, int stacksize) { int pHandler(); if (taskNameToId("tPHandlr") == ERROR) { pHandlerPriority = priority; pHandlerTid = taskSpawn("tPHandlr",priority,taskoptions,stacksize,pHandler, pMsgesToPHandlr,2, 3,4,5,6,7,8,9,10); pHandlerWdTimeout = wdCreate(); pHandlerTimeout = 0; } }
static int __wind_wd_create(struct pt_regs *regs) { WDOG_ID wdog_id; wind_wd_t *wd; wd = (wind_wd_t *)wdCreate(); if (!wd) return wind_errnoget(); wdog_id = wd->handle; return __xn_safe_copy_to_user((void __user *)__xn_reg_arg1(regs), &wdog_id, sizeof(wdog_id)); }
STATUS endPollStatsInit ( void * pCookie, FUNCPTR pIfPollRtn ) { END_IFDRVCONF * pDrvConf; int error; PROTOCOL_BINDING tmpBinding; /* Sanity check */ if (pCookie == NULL || pIfPollRtn == NULL) return (ERROR); tmpBinding.pEnd = PDEVCOOKIE_TO_ENDOBJ(pCookie); if (tmpBinding.pEnd == NULL) return (ERROR); /* Get this driver's configuration info */ error = muxIoctl ((void *)&tmpBinding, EIOCGPOLLCONF, (caddr_t) &pDrvConf); /* Return error if driver doesn't support stats polling. */ if (error) return (error); /* Create the watchdog. */ pDrvConf->ifWatchdog = wdCreate (); if (pDrvConf->ifWatchdog == NULL) return (ERROR); pDrvConf->ifEndObj = NULL; pDrvConf->ifMuxCookie = pCookie; pDrvConf->ifPollRtn = pIfPollRtn; /* Kick off the watchdog. */ wdStart (pDrvConf->ifWatchdog, pDrvConf->ifPollInterval, (FUNCPTR) endPollStatsJobQueue, (int) (pDrvConf)); return (OK); }
static long ai_init(int pass) { int i; if(pass) return 0; for(i=0;i<TOTAL_TYPES;i++) { scanIoInit(&scan[i].ioscan); scan[i].wd=wdCreate(); scan[i].total=0; scan[i].on=0; scan[i].rate_sec=scan_rate_sec[i]; scan[i].rate_tick=scan_rate_sec[i]*sysClkRateGet(); scan[i].last_read_sec=1000000; } cpuUsageInit(); return 0; }
/* 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; }
void arpLibInit (void) { #ifdef VIRTUAL_STACK /* * Make sure arpLibInit has not been called before. This can happen * when INCLUDE_ARP_API has been included in a build. */ if (arptimerWd == NULL) { _llinfo_arp.la_next = &_llinfo_arp; _llinfo_arp.la_prev = &_llinfo_arp; arpRxmitTicks = -1; arptimerWd = wdCreate (); arptimer(myStackNum); } #endif /* VIRTUAL_STACK */ return; }
static int __wind_wd_create(struct task_struct *curr, struct pt_regs *regs) { WDOG_ID wdog_id; wind_wd_t *wd; if (!__xn_access_ok (curr, VERIFY_WRITE, __xn_reg_arg1(regs), sizeof(wdog_id))) return -EFAULT; wd = (wind_wd_t *)wdCreate(); if (!wd) return wind_errnoget(); wd->rh = wind_get_rholder(); wdog_id = wd->handle; __xn_copy_to_user(curr, (void __user *)__xn_reg_arg1(regs), &wdog_id, sizeof(wdog_id)); return 0; }
int initConditionnement(Lot* premierLot) { semCapteurCarton = semMCreate(SEM_Q_FIFO); semEtatImp = semMCreate(SEM_Q_FIFO); semCapteurPalette = semMCreate(SEM_Q_FIFO); semEtatEmb = semMCreate(SEM_Q_FIFO); semCompteurPalette = semMCreate(SEM_Q_FIFO); semClapet = semMCreate(SEM_Q_FIFO); fileConvoyage = msgQCreate(MAXFILECONVOYAGE, sizeof(Carton), MSG_Q_FIFO | MSG_Q_INTERRUPTIBLE); tidTraitementCarton = taskSpawn("traitement_carton", 100, 0, 128, (FUNCPTR) traitementCarton, (int) fileConvoyage, (int) semCapteurCarton, (int) semEtatImp, (int) semCompteurPalette, (int) premierLot, 0, 0, 0, 0, 0); tidTraitementPalette = taskSpawn("traitement_palette", 100, 0, 128, (FUNCPTR) traitementPalette, (int) fileConvoyage, (int) semCapteurPalette, (int) semEtatEmb, (int) semCompteurPalette, 0, 0, 0, 0, 0, 0); wdReparation = wdCreate(); return OK; }
int timer_create ( clockid_t clock_id, /* clock ID (always CLOCK_REALTIME) */ struct sigevent *evp, /* user event handler */ timer_t * pTimer /* ptr to return value */ ) { timer_t timerid; struct sigevent sevp; if (intContext ()) return (ERROR); (void)clockLibInit (); /* make sure clock "running" */ timerid = (timer_t) calloc (1, sizeof(*timerid)); if (timerid == NULL) { /* errno = EMTIMERS; * S_memLib_NOT_ENOUGH_MEMORY will be lost */ return (ERROR); } if ((timerid->wdog = wdCreate ()) == NULL) { free ((char *) timerid); return (ERROR); } timerid->active = FALSE; timerid->taskId = taskIdSelf (); timerid->clock_id = clock_id; /* should check for known clock_id? */ if (evp == NULL) { sevp.sigev_signo = SIGALRM; /* remember value possibly set in timer_connect() */ /* XXX sevp.sigev_value.sival_int = timerid->sevent.sigev_value.sival_int; */ sevp.sigev_value.sival_ptr = timerid; } else { if (evp->sigev_signo < 1 || evp->sigev_signo > _NSIGS) { errno = EINVAL; return (ERROR); } sevp = *evp; } timerid->sevent = sevp; timerid->sigpend.sigp_info.si_signo = sevp.sigev_signo; timerid->sigpend.sigp_info.si_code = SI_TIMER; timerid->sigpend.sigp_info.si_value = sevp.sigev_value; sigPendInit (&timerid->sigpend); TV_ZERO(timerid->exp.it_interval); TV_ZERO(timerid->exp.it_value); *pTimer = timerid; return (OK); }
void blasteeUDP (int port, int size, int blen, int zbuf) { struct sockaddr_in serverAddr, clientAddr; int nrecv; /* number of bytes received */ int sockAddrSize = sizeof(struct sockaddr); // ZBUF_ID zid; /* zero-copy buffer ID */ printf("==> %s port [%d], size [%d]. blen [%d], zbuf [%d]\n", __func__, port, size, blen, zbuf); // tid = taskIdSelf(); buffer = (char *) malloc (size); if (buffer == NULL) { printf ("cannot allocate buffer of size %d\n", size); return; } #if 0 /* setup watchdog to periodically report network throughput */ if ((blastWd = wdCreate ()) == NULL) { printf ("cannot create blast watchdog\n"); free (buffer); //释放掉?? return; } wdStart (blastWd, sysClkRateGet ()*10, (FUNCPTR) blastRate, 0); #endif alarm(10); if ((sock = socket (AF_INET, SOCK_DGRAM, 0)) < 0) { printf ("cannot open socket\n"); // wdDelete (blastWd); free (buffer); return; } //?????????????????????????????????????????????? serverAddr.sin_family = AF_INET; serverAddr.sin_port = htons (port); serverAddr.sin_addr.s_addr = INADDR_ANY; /* auto-fill with my IP */ bzero((char *)&serverAddr.sin_zero, 8); /* zero rest of struct */ //????????????????????????????????????????????????? if (bind (sock, (struct sockaddr *)&serverAddr, sizeof(serverAddr)) < 0)//将一个本地的网络运输层地址和套接字联系起来 { printf ("bind error\n"); close (sock); // wdDelete (blastWd); free (buffer); return; } /* setting buffer size breaks UDP sockets for some reason. This * happens on Linux too (but not Solaris). Hence setsockopt() is * commented till further notice. */ if (setsockopt (sock, SOL_SOCKET, SO_RCVBUF, (char *) &blen, sizeof (blen)) < 0)//插入进程请求的套接字和协议选项 { printf ("setsockopt SO_RCVBUF failed\n"); close (sock); // wdDelete (blastWd); free (buffer); exit (1); } blastNum = 0; blasteeUDPquitFlag = 0; /* loop that reads UDP blasts */ int ct =0; for (;;) { if (blasteeUDPquitFlag) break; /* if (zbuf) { nrecv = size; if ((zid = zbufSockRecvfrom(sock, 0, &nrecv, (struct sockaddr *)&clientAddr, (int *)&sockAddrSize)) == NULL) nrecv = -1; else zbufDelete(zid); } else */ nrecv = recvfrom (sock, (char *)buffer, size, 0, (struct sockaddr *)&clientAddr, (int *)&sockAddrSize);//接收远程主机经指定的socket传来的数据 // printf("setsockopt receive\n");/*LYT*/ if (nrecv < 0) { printf ("blasteeUDP read error %d\n", errno);//errno?????????????????????????????????? break; } // if(++ct%1000==0) // printf ("blasteeUDP received %d--------------\n", nrecv); blastNum += nrecv; } //?????????????????????????????????????????????????????????????? close (sock); // wdDelete (blastWd); free (buffer); printf ("blasteeUDP end.\n"); }
int main(int argCount, char **argString) { char keyPressed = FALSE; int keyboardLock = FALSE; double keyboardLockTime = ojGetTimeSec() + KEYBOARD_LOCK_TIMEOUT_SEC; time_t timeStamp; //Get and Format Time String time(&timeStamp); strftime(timeString, DEFAULT_STRING_LENGTH-1, "%m-%d-%Y %X", localtime(&timeStamp)); system(CLEAR); //cDebug(1, "main: Starting Up %s Node Software\n", simulatorGetName()); // if(simulatorStartup()) // { // printf("main: %s Node Startup failed\n", simulatorGetName()); // //cDebug(1, "main: Exiting %s Node Software\n", simulatorGetName()); //#if defined(WIN32) // system("pause"); //#else // printf("Press ENTER to exit\n"); // getch(); //#endif // return 0; // } vehicleSimStartup(); pd = pdCreate(); gpos = gposCreate(); vss = vssCreate(); wd = wdCreate(); setupTerminal(); mainRunning = TRUE; while(mainRunning) { keyPressed = getUserInput(); if(keyPressed) { keyboardLockTime = ojGetTimeSec() + KEYBOARD_LOCK_TIMEOUT_SEC; } else if(ojGetTimeSec() > keyboardLockTime) { keyboardLock = TRUE; } //if(verbose) //{ // choice = getc(stdin); //} //else // Not in verbose mode //{ // choice = getch(); // Get the key that the user has selected // updateScreen(keyboardLock, choice); //} ojSleepMsec(100); } cleanupConsole(); //cDebug(1, "main: Shutting Down %s Node Software\n", simulatorGetName()); wdDestroy(wd); pdDestroy(pd); gposDestroy(gpos); vssDestroy(vss); vehicleSimShutdown(); if(logFile != NULL) { fclose(logFile); } return 0; }