//------------------------------------------------------------------------------
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;
}
Пример #2
0
bool Clean(Id*& id)
{
	bool ret = true;
	if (id && taskIdVerify(id->TaskId) == OK)
	{
	  Id me(taskIdSelf());
		if (me == *id)  // this mean just release the resources that we allocated here (not the task itself)
		{
			delete id;   // we can deallocate our task resources, but we cannot delete the task itself
			id = 0;
		}
		else
		{
		  //printf("deleting task id %d\r\n", id->TaskId);
			if (taskDelete(id->TaskId) != OK)
			{
				ret = HandleDeleteErrors(errnoGet(), __LINE__);
			}
			
			if (ret)
			{
				delete id;
				id = 0;
			}
		}
	}
	return ret;
}
Пример #3
0
void zmq::thread_t::stop ()
{
    if (started)
        while ((descriptor != NULL || descriptor > 0)
               && taskIdVerify (descriptor) == 0) {
        }
}
s32 edma2_stress_test_stop()
{
    set_test_switch_stat(EDMAC, TEST_STOP);

    while(OK == taskIdVerify(g_edma2_busstress_info.edma_stress_test_task_id))
    {
        taskDelay(100);
    }

    if (NULL != g_edma2_busstress_info.edma_send_sem)
    {
        /*sema_delete(g_edma2_busstress_info.edma_send_sem);*/
        semDelete(g_edma2_busstress_info.edma_send_sem);
    }


    bsp_softtimer_delete_sync(&g_edma2_busstress_info.edma_softtimer_list);
    bsp_softtimer_free(&g_edma2_busstress_info.edma_softtimer_list);

    cacheDmaFree(g_edma2_busstress_info.stDMATaskHandle[0].u32SrcAddr);
    cacheDmaFree(g_edma2_busstress_info.stDMATaskHandle[0].u32DstAddr);
    cacheDmaFree(g_edma2_busstress_info.stDMATaskHandle[1].u32SrcAddr);
    cacheDmaFree(g_edma2_busstress_info.stDMATaskHandle[3].u32DstAddr);
    return OK;
}
void blasteeUDPQuit(void)
{
    blasteeUDPquitFlag = 1;
    taskDelay(60);               /* try to end gracefully */
    if (taskIdVerify(tid) == OK) /* blasteeUDP still trying to receive */
    {
        close (sock);
        wdDelete (blastWd);
        free (buffer);
        taskDelete (tid);
        printf ("blasteeUDP forced stop.\n");
    }
}
Пример #6
0
/*
    Check the CGI process.  Return 0 if it does not exist; non 0 if it does.
 */
static int checkCgi(int handle)
{
    STATUS stat;

    /*
        Verify the existence of a VxWorks task
     */
    stat = taskIdVerify(handle);
    if (stat == OK) {
        return 1;
    } else {
        return 0;
    }
}
Пример #7
0
static int __wind_task_verifyid(struct task_struct *curr, struct pt_regs *regs)
{
	xnhandle_t handle = __xn_reg_arg1(regs);
	WIND_TCB *pTcb;

	pTcb = (WIND_TCB *)xnregistry_fetch(handle);

	if (!pTcb)
		return S_objLib_OBJ_ID_ERROR;

	if (taskIdVerify((TASK_ID) pTcb) == ERROR)
		return wind_errnoget();

	return 0;
}
Пример #8
0
static void
os_procAwaitThreads()
{
    os_threadContextData threadContextData;
    os_procContextData currentProcContext = (os_procContextData)readTLSVarSelf(procContextData);
    threadContextData = (void *) os_iterTakeFirst(currentProcContext->procThreadList);
    while ((threadContextData != (void *)NULL) &&
           (threadContextData->threadValidity == thread_ValRunning)) {
        os_threadAwaitTermination(threadContextData);
#ifdef DEL
        while (taskIdVerify(threadContextData->threadTaskId) == OK) {
             taskDelay (10); /* To do trigger */
        }
#endif
        threadContextData = (void *) os_iterTakeFirst (currentProcContext->procThreadList);
    }
}
Пример #9
0
/**
 * Verifies a task still exists.
 * @returns true on success.
 */
bool Task::Verify()
{
    return taskIdVerify(m_taskID) == OK;
}
Пример #10
0
/* Start an Erlang node. return value 0 indicates that node was
 * started successfully, negative values indicate error. 
 * 
 * node -  the name of the remote node to start (alivename@hostname).
 * flags - turn on or off certain options. See erl_start.h for a list.
 * erl -  is the name of the erl script to call. If NULL, the default
 * name "erl" will be used.
 * args - a NULL-terminated list of strings containing
 * additional arguments to be sent to the remote Erlang node. These
 * strings are simply appended to the end of the command line, so any
 * quoting of special characters, etc must be done by the caller.
 * There may be some conflicts between some of these arguments and the
 * default arguments hard-coded into this function, so be careful. 
 */
int erl_start_sys(ei_cnode *ec, char *alive, Erl_IpAddr adr, int flags,
		  char *erl, char *args[])
{
  struct timeval timeout;
  struct sockaddr_in addr;
  SocklenType namelen;
  int port;
  int sockd = 0;
  int one = 1;
#if defined(VXWORKS) || defined(__WIN32__)
  unsigned long pid = 0;
#else
  int pid = 0;
#endif
  int r = 0;

  if (((sockd = socket(AF_INET, SOCK_STREAM, 0)) < 0) ||
      (setsockopt(sockd, SOL_SOCKET, SO_REUSEADDR, (char *)&one, sizeof(one)) < 0)) {
    r = ERL_SYS_ERROR;
    goto done;
  }
  
  memset(&addr,0,sizeof(addr));
  addr.sin_family = AF_INET;              
  addr.sin_addr.s_addr = htonl(INADDR_ANY); 
  addr.sin_port = 0;

  if (bind(sockd,(struct sockaddr *)&addr,sizeof(addr))<0) {
      return ERL_SYS_ERROR;
  }
  namelen = sizeof(addr);
  if (getsockname(sockd,(struct sockaddr *)&addr,&namelen)<0) {
      return ERL_SYS_ERROR;
  }
  port = ntohs(addr.sin_port);

  listen(sockd,5);

#if defined(VXWORKS) || defined(__WIN32__)
  if((pid = spawn_erlang_epmd(ec,alive,adr,flags,erl,args,port,1)) 
      == 0)
     return ERL_SYS_ERROR;
  timeout.tv_usec = 0;
  timeout.tv_sec = 10; /* ignoring ERL_START_TIME */
  if((r = wait_for_erlang(sockd,unique_id(),&timeout)) 
     == ERL_TIMEOUT) {
#if defined(VXWORKS)
      taskDelete((int) pid);
      if(taskIdVerify((int) pid) != ERROR)
	  taskDeleteForce((int) pid);
#else /* Windows */
      /* Well, this is not a nice way to do it, and it does not 
	 always kill the emulator, but the alternatives are few.*/
      TerminateProcess((HANDLE) pid,1);
#endif /* defined(VXWORKS) */
  }
#else /* Unix */
  switch ((pid = fork())) {
  case -1:
    r = ERL_SYS_ERROR;
    break;

  case 0:
    /* child - start the erlang node */
    exec_erlang(ec, alive, adr, flags, erl, args, port);

    /* error if reached - parent reports back to caller after timeout
       so we just exit here */
    exit(1);
    break;

  default:

    /* parent - waits for response from Erlang node */
    /* child pid used here as magic number */
    timeout.tv_usec = 0;
    timeout.tv_sec = 10; /* ignoring ERL_START_TIME */
    if ((r = wait_for_erlang(sockd,pid,&timeout)) == ERL_TIMEOUT) {
      /* kill child if no response */
      kill(pid,SIGINT);
      sleep(1);
      if (waitpid(pid,NULL,WNOHANG) != pid) {
	/* no luck - try harder */
	kill(pid,SIGKILL);
	sleep(1);
	waitpid(pid,NULL,WNOHANG);
      }
    }

  }
#endif /* defined(VXWORKS) || defined(__WIN32__) */

done:
#if defined(__WIN32__)
  if (sockd) closesocket(sockd);
#else
  if (sockd) close(sockd);
#endif
  return r;
} /* erl_start_sys() */