Example #1
0
void rtExtModeTornadoCleanup(int_T numSampTimes)
{
    taskDelete(extern_upload_tid);
    taskDelete(extern_pkt_tid);
    rt_ExtModeShutdown(numSampTimes);
    semDelete(uploadSem);
    semDelete(commSem);
    semDelete(pktSem);
}
Example #2
0
/**
 * Start the task that is responsible for sending images to the PC.
 */
int PCVideoServer::StartServerTask()
{
	if (StatusIsFatal())
	{
		return -1;
	}
	int id = 0;
	m_stopServer = false;
	// Check for prior copy of running task
	int oldId = taskNameToId((char*)m_serverTask.GetName());
	if(oldId != ERROR)
	{
		// TODO: Report error. You are in a bad state.
		taskDelete(oldId);
	}

	// spawn video server task
	// this is done to ensure that the task is spawned with the
	// floating point context save parameter.
	bool started = m_serverTask.Start((int)this);

	id = m_serverTask.GetID();

	if (!started)
	{
		wpi_setWPIError(TaskError);
		return id;
	}
	taskDelay(1);
	return id;
}
void baseRateTask(void *arg)
{
  runModel = (rtmGetErrorStatus(Model_M) == (NULL)) && !rtmGetStopRequested
    (Model_M);
  while (runModel) {
    mw_osSemaphoreWaitEver(&baserateTaskSem);

    /* External mode */
    {
      boolean_T rtmStopReq = false;
      rtExtModePauseIfNeeded(Model_M->extModeInfo, 1, &rtmStopReq);
      if (rtmStopReq) {
        rtmSetStopRequested(Model_M, true);
      }

      if (rtmGetStopRequested(Model_M) == true) {
        rtmSetErrorStatus(Model_M, "Simulation finished");
        break;
      }
    }

    Model_step();

    /* Get model outputs here */
    rtExtModeCheckEndTrigger();
    runModel = (rtmGetErrorStatus(Model_M) == (NULL)) && !rtmGetStopRequested
      (Model_M);
  }

  runModel = 0;
  terminateTask(arg);
  taskDelete((void *)0);
}
Example #4
0
/*
 * Disable disk cache
 */
STATUS
flashFsDisableDcache(void)
{
    if (flashFsVerbose)
        printf("flashFsDisableDcache\n");

    /* Disable disk cache - Hack */
    taskDelete(dcacheUpdTaskId);
    dcacheUpdTaskId = 0;

#if 0
    CBIO_DEV_ID dcacheHandle;
    void *devHandle;
    char fullname[20];

    /* Set the disk cache sync delay to 0 */
    devHandle = iosDevFind("flash:", &fullname);
    dcacheHandle = *(CBIO_DEV_ID*)((int)devHandle + 24);   /* FIXME */
    if (flashFsVerbose) {
        printf("dcacheDevTune - devHandle=0x%x, dcacheHandle=0x%x\n",
                (int)devHandle, (int)dcacheHandle);
    }
    if (dcacheDevTune(dcacheHandle, 0, 0, 0, 0) != OK) {
        printf("flashFsDisableDcache: dcacheDevTune failed\n");
        return ERROR;
    }

    dcacheDevDisable(dcacheHandle);   /* only for dosFS 2.2 */
#endif

    /* dcacheShow(dcacheHandle, 0); */

    return OK;
}
Example #5
0
u8 modemtask_reset( void )
{
    pinSet( MODEM_RESET, LOW );
    taskDelete( "modemreset"  );
    
    return( TRUE );
}
Example #6
0
u8 modemtask_onoff( void )
{
    pinSet( MODEM_ONOFF, LOW );
    taskDelete( "modemonoff" );

    return( TRUE );
}
Example #7
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;
}
Example #8
0
/**
 * @brief Détruire les ressources systèmes.
 * @return OK en cas de succès, ERROR sinon.
 */
int pe_cleanup_resources()
{
	int errtest = 0;
	
	// Destruction des ressources.
	if(semDelete(mut_table_capt))
	{
		printf("Erreur : Problème de destruction du sémaphore pour table_capt.\n");
		errtest = 1;
	}
	if(semDelete(mut_table_buffer))
	{
		printf("Erreur : Problème de destruction du sémaphore pour table_buffer.\n");
		errtest = 1;
	}
	if(msgQDelete(msgQ_dispatcher))
	{
		printf("Erreur : mauvais numéro de file de message.\n");
		errtest = 1;
	}	
	
	if(taskDelete(id_pe_task_dispatcher))
	{
		printf("Erreur : mauvais numéro de tache pour la tache dispatcher.\n");
		errtest = 1;
	}
	
	if (errtest)
	{
		return ERROR;
	}
	return OK;
}
Example #9
0
/* This is the task safe delete */
int task_delete(
					 OSI_LIB_HANDLE MgTaskHandle
					 )
{
#ifdef WINDOWS_OS
	DWORD ExitCode;
	WIN_HANDLE WinThreadHandle;

	WinThreadHandle=(WIN_HANDLE)MgTaskHandle;
	if (GetExitCodeThread(WinThreadHandle,&ExitCode)==0)
	{
		return AII_ERROR;
	}
	ExitThread(ExitCode);
	return AII_OK;
#endif

#ifdef VXWORKS_OS
	int status;

	status=taskDelete(MgTaskHandle);
	return status;
#endif

#ifdef LINUX_OS
	
#endif
	
}
Example #10
0
/*****************************************************************************
**  user system shutdown and resource cleanup
*****************************************************************************/
void
    user_syskill( void )
{
    STATUS err;

    while ( getchar() != (int)'q' )
        sleep( 1 );

    puts( "\r\nDeleting Task 1" );
    err = taskDelete( task1_id );

    puts( "\r\nDeleting Task 2" );
    err = taskDelete( task2_id );

    puts( "\r\nDeleting Task 3" );
    err = taskDelete( task3_id );

    printf( "\r\nDeleting Semaphore SEM3" );
    errno = 0;
    err = semDelete( sema43_id );
    if ( err == ERROR )
        printf( "... returned error %x\r\n", errno );

    printf( "\r\nDeleting Semaphore SEM2" );
    errno = 0;
    err = semDelete( sema42_id );
    if ( err == ERROR )
        printf( "... returned error %x\r\n", errno );

    printf( "\r\nDeleting Queue QUEUE3" );
    errno = 0;
    err = msgQDelete( queue3_id );
    if ( err == ERROR )
        printf( "... returned error %x\r\n", errno );
    else
        printf( "\r\n" );

    printf( "\r\nDeleting Queue QUEUE2" );
    errno = 0;
    err = msgQDelete( queue2_id );
    if ( err == ERROR )
        printf( "... returned error %x\r\n", errno );
    else
        printf( "\r\n" );

    printf( "\r\n" );
}
Example #11
0
void eventRFBack( void )
{
    //formRemove();
    //form
    //drawForms();
    taskDelete( "humidity", 0 );
    drawMainMenu();
}
Example #12
0
int arretConditionnement() {
	wdDelete(wdReparation);

	taskDelete(tidTraitementPalette);
	taskDelete(tidTraitementCarton);

	msgQDelete(fileConvoyage);

	semDelete(semClapet);
	semDelete(semCompteurPalette);
	semDelete(semEtatEmb);
	semDelete(semCapteurPalette);
	semDelete(semEtatImp);
	semDelete(semCapteurCarton);

	return OK;
}
Example #13
0
int
osip_thread_join (struct osip_thread * _thread)
{
  osip_thread_t *thread = (osip_thread_t *)_thread;
  if (thread == NULL)
    return -1;
  return taskDelete (thread->id);
}
Example #14
0
restartComLnk()
{
   int tid,stat,priority,stacksize,taskoptions;
   /* if tComLink still around then Connection was never made */
   DPRINT(1,"Time to Restart Exppproc Link.");
    if ((tid = taskNameToId("tMonitor")) != ERROR)
    {
       stat = taskDelete(tid);
    }
    if ((tid = taskNameToId("tStatAgent")) != ERROR)
    {
       stat = taskDelete(tid);
    }
    if ((tid = taskNameToId("tStatMon")) != ERROR)
    {
       stat = taskDelete(tid);
    }
   }
Example #15
0
/**
 * Kills the running task.
 * @returns true on success false if the task doesn't exist or we are unable to kill it.
 */
bool Task::Stop()
{
    bool ok = true;
    if (Verify())
    {
        ok = HandleError(taskDelete(m_taskID));
    }
    m_taskID = kInvalidTaskID;
    return ok;
}
Example #16
0
void stopSensor()
{
	if (tSensorID == 0)
	{
		printf("Sensors are not running.\n");
		return;
	}
	taskDelete(tSensorID);
	tSensorID=0;
}
Example #17
0
void
nfs_start(char *pathtab_name)
{
	FILE           *fp;
	char            path[PATH_MAX];
	int             id;

	if ((nfsd_task_id = taskSpawn("tNfsd", nfsd_task_priority,
				      nfsd_task_options, nfsd_task_stacksize,
				      nfsd, 0)) != ERROR &&
	    (mountd_task_id = taskSpawn("tMountd", mountd_task_priority,
				 mountd_task_options, mountd_task_stacksize,
					mountd, 0)) != ERROR) {
		nfsd_debug("nfs_start: nfsd and mountd started OK\n");

		if (!pathtab_name)
			return;

		nfsd_pathtab = symTblCreate(8, FALSE, memSysPartId);

		if (!nfsd_pathtab) {
			nfsd_debug("nfs_start: can't create nfsd_pathtab\n");
			return;
		}
		if ((fp = fopen(pathtab_name, "r")) == 0) {
			symTblDelete(nfsd_pathtab);
			nfsd_debug("nfs_start: can't open pathtab file <%s>\n",
				   pathtab_name);
			return;
		}
		while (fgets(nfsd_buffer, sizeof(nfsd_buffer), fp)) {
			sscanf(nfsd_buffer, "%s %d", path, &id);

			path_to_all_lower(path);

			if (symAdd(nfsd_pathtab, path, (char *) id,
				   (SYM_TYPE) NFSD_MSDOS_TYPE, 0) == ERROR) {
				symTblDelete(nfsd_pathtab);
				nfsd_debug("nfs_start: can't add path <%s>\n",
					   path);
				return;
			}
			nfsd_debug("nfs_start: added path <%s> id %x\n",
				   path, id);
		}

		nfsd_debug("nfs_start: %d paths added to pathtab\n",
			   nfsd_pathtab->nsymbols);
	} else {
		nfsd_debug("nfs_start: didn't work\n");

		if (nfsd_task_id != ERROR)
			taskDelete(nfsd_task_id);
	}
}
Example #18
0
STATUS ossThreadDestroy 
    (
    THREAD_HANDLE threadHandle	    /* handle of thread to be destroyed */
    )

    {
    if (taskDelete ((int) threadHandle) == ERROR)
	return ossStatus (S_ossLib_GENERAL_FAULT);

    return OK;
    }
Example #19
0
void init(void)
{
	
	int tacheSynchID;
	
	mailBox = msgQCreate( 2, 4, MSG_Q_FIFO);
	if (mailBox!=NULL)
		printf("Boite aux lettres créée\n");
	else
		printf("ERREUR\n");

	*GPT_IR = 0x1;
	*GPT_CR = 0x1c3;
	*GPT_PR = 0x0;
	*GPT_OCR1 = 24000000;



	// Initialisation des GPIO pour la broche GPIO9
	*IOMUXC1_GPIO9=0x05;
	*IOMUXC2_GPIO9=0x1B0B0;

	
	erreur = intConnect(87, (VOIDFUNCPTR)ITserver, 0);
	if (erreur !=OK)
	{
		printf("ERREUR intConnect\n");
		taskDelete(0);
	}
	erreur = intEnable(87);
	if (erreur != OK)
	{
		printf("Erreur intEnable\n");
		taskDelete(0);
	}
	
	
	tacheSynchID = taskSpawn(tacheSynch, 100, 0, 5000, (FUNCPTR)tacheSynch, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
	
	taskDelete(0);
}
Example #20
0
cleanAupdt()
{
  int tid;
  if (pMsgesToAupdt != NULL)
  {
    msgQDelete(pMsgesToAupdt);
    pMsgesToAupdt = NULL;
  }
  tid = taskNameToId("tAupdt");
  if (tid != ERROR)
    taskDelete(tid);
}
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");
    }
}
Example #22
0
//=========================================================================
// ddrTask: DDR task initialization function utility
//=========================================================================
int ddrTask(char *name, void* task, int priority)
{
    int tid=taskNameToId(name);
    
    if(tid != ERROR)
        taskDelete(tid);
    
    if(tid=taskSpawn(name,priority,0,10000,
        task,0,0,0,0,0,0,0,0,0,0)==ERROR)
            //perror("ddrTask:%s",name); 
            perror("ddrTask"); 
    return tid;
}
int vxhStop()
{
  if(!vxh_stop_flag)
    {
      vxh_stop_flag=1;
      taskDelay(10);
    }
  if(vxh_id)
    {
      taskDelete(vxh_id);
      vxh_id=0;
    }
}
Example #24
0
/*
 *  Stop the command
 */
void mprStopCmd(MprCmd *cmd)
{
    mprLog(cmd, 7, "cmd: stop");

    if (cmd->pid) {
#if BLD_WIN_LIKE
        TerminateProcess(cmd->process, 2);
#elif VXWORKS
        taskDelete(cmd->pid);
#else
        kill(cmd->pid, SIGTERM);
#endif
    }
}
Example #25
0
void bootGetUSART2( void )
{
    static u8 COM2Buffer[ 256 ], COM2Index = 0;
    u8 ucByte, CurrentStream;

    //pinSet( LED0, HIGH );
    CurrentStream = streamGetSTDIO();
    streamSetSTDIO( COM2 );
    if( USART2->SR & USART_RXNE ) { 
        USART2->SR &= ~USART_RXNE;
        ucByte = USART2->DR;
        
        if( xmodemProcess( &XModem, ucByte ) ){
            streamSetSTDIO( CurrentStream );
            return;
        } // if
        if( ucByte == '+' ){
            taskDelete( "boot" );
            globalBootStatus = BOOT_CANCEL;
            bootPrintPrompt();
            streamSetSTDIO( CurrentStream );
            return;
        } // if
        if( globalBootStatus & BOOT_CANCEL ){
            if( ucByte == '\r' ){
                COM2Buffer[ COM2Index ] = '\0'; // Add NULL to terminate string
                COM2Index = 0;
                if( executeCmd( COM2Buffer, (PYGMYCMD *)BOOTCOMMANDS ) ){
                    bootPrintPrompt();
                } else{
                    print( STDIO, "\rERROR" );
                    bootPrintPrompt();
                } // else
            } else{
                USART2->DR = ucByte;
                if( ucByte == '\b'  ){
                    if( COM2Index ){
                        --COM2Index;
                    } // if
                } else {
                    COM2Buffer[ COM2Index++ ] = ucByte;
                } // else
            } // else
        } // if
    } // if
    streamSetSTDIO( CurrentStream );
    //pinSet( LED0, LOW );
}
Example #26
0
static int __wind_task_delete(struct task_struct *curr, struct pt_regs *regs)
{
	xnhandle_t handle = __xn_reg_arg1(regs);
	WIND_TCB *pTcb;

	if (handle)
		pTcb = (WIND_TCB *)xnregistry_fetch(handle);
	else
		pTcb = __wind_task_current(curr);

	if (!pTcb)
		return S_objLib_OBJ_ID_ERROR;

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

	return 0;
}
Example #27
0
void testTaskNew(CuTest* test)
{
    const int n = 4;
    char* names[] = {
        "get up",
        "eat food",
        "study",
        "go to bed"
    };
    for (int i = 0; i < n; i++)
    {
        Task* task = taskNew(i, names[i]);
        CuAssertPtrNotNull(test, task);
        CuAssertStrEquals(test, names[i], task->name);
        CuAssertIntEquals(test, i, task->priority);
        taskDelete(task);
    }
}
Example #28
0
File: cmd.c Project: embedthis/mpr
/*
    Stop the command
    WARNING: Called from the finalizer. Must not block or lock.
 */
PUBLIC int mprStopCmd(MprCmd *cmd, int signal)
{
    mprDebug("mpr cmd", 6, "cmd: stop");
    if (signal < 0) {
        signal = SIGTERM;
    }
    cmd->stopped = 1;
    if (cmd->pid) {
#if ME_WIN_LIKE
        return TerminateProcess(cmd->process, 2) == 0;
#elif VXWORKS
        return taskDelete(cmd->pid);
#else
        return kill(cmd->pid, signal);
#endif
    }
    return 0;
}
Example #29
0
int main(int argc, char *const argv[])
{
	int ret;

	traceobj_init(&trobj, argv[0], sizeof(tseq) / sizeof(int));

	sem_id = semCCreate(SEM_Q_PRIORITY, 0);
	traceobj_assert(&trobj, sem_id != 0);

	traceobj_mark(&trobj, 8);

	btid = taskSpawn("backgroundTask", 11, 0, 0, backgroundTask,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
	traceobj_assert(&trobj, btid != ERROR);

	traceobj_mark(&trobj, 9);

	ftid = taskSpawn("foregroundTask", 10, 0, 0, foregroundTask,
			 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
	traceobj_assert(&trobj, ftid != ERROR);

	traceobj_mark(&trobj, 10);

	ret = semGive(sem_id);

	traceobj_assert(&trobj, ret == OK);

	traceobj_mark(&trobj, 11);

	ret = semGive(sem_id);

	traceobj_assert(&trobj, ret == OK);

	traceobj_mark(&trobj, 12);

	ret = taskDelete(btid);
	traceobj_assert(&trobj, ret == OK);

	traceobj_join(&trobj);

	traceobj_verify(&trobj, tseq, sizeof(tseq) / sizeof(int));

	exit(0);
}
Example #30
0
/*
 * Admin functions API: install of driver and then of devices.
 *						uninstall of devices and then of driver
 *						direct driver uninstall is also supported
 */
int drvInstall()
{
	if (semMAdmin==0)
	{//The semaphore hasn't been created yet : the driver has not been installed yet,
	 //let's do it
		semMAdmin = semMCreate(SEM_Q_FIFO);
		if(semMAdmin==0)
		{
			errnoSet(SEM_ERR);
			return -1;
		}
	} else {
		errnoSet(ALREADY_INSTALLED);
		return -1;
	}
	isrmq = msgQCreate(10,4,0); //Create a msg queue with 10 msg max,
								//4 byte per msg max, and msgs filled up in fifo order
	if (isrmq == NULL)
	{
		errnoSet(MSGQ_ERR);
		return -1;
	}
	tMsgDispatchID = taskSpawn("tMsgDispatch",0,0,1000,msgDispatch,(int)semMAdmin,0,0,0,0,0,0,0,0,0);
	//This task will dispatch a msg received by the isr and sleep the rest of the time.
	//It needs to be fast to prevent isr msg queue to fill up, hence the high priority
	//It's also nice for tests if his priority is superior than the shell's one, which
	//is set to 1
	if (tMsgDispatchID==-1)
	{
		msgQDelete(isrmq);
		errnoSet(TASK_ERR);
		return -1;
	}
	numPilote=iosDrvInstall(0,0,devOpen,devClose,devRead,0,0); //Register device in ios
	if (numPilote == -1)
	{
		msgQDelete(isrmq);
		taskDelete(tMsgDispatchID);
		errnoSet(INSTALL_ERR);
		return -1;
	}
	return 0;
}