Esempio n. 1
33
int main(int argc, char *argv[])
{
	TASK_ID rtid, ptid;

	copperplate_init(argc, argv);

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

	rtid = taskSpawn("rootTask", 50, 0, 0, rootTask,
			 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
	traceobj_assert(&trobj, rtid != ERROR);

	traceobj_mark(&trobj, 18);

	ptid = taskSpawn("peerTask", 10, 0, 0, peerTask,
			 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
	traceobj_assert(&trobj, ptid != ERROR);

	traceobj_mark(&trobj, 19);

	traceobj_join(&trobj);

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

	exit(0);
}
Esempio n. 2
5
int main(int argc, char *const argv[])
{
	TASK_ID rtid, ptid;

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

	traceobj_mark(&trobj, 11);

	rtid = taskSpawn("rootTask", 50, 0, 0, rootTask,
			 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
	traceobj_assert(&trobj, rtid != ERROR);

	traceobj_mark(&trobj, 12);

	ptid = taskSpawn("peerTask",
			 51,
			 0, 0, peerTask, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
	traceobj_assert(&trobj, ptid != ERROR);

	traceobj_mark(&trobj, 13);

	traceobj_join(&trobj);

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

	exit(0);
}
Esempio n. 3
0
void s4_msgq2(void)
{
	int taskIdOne;
	int taskIdTwo;

	if ((msgQueueId = msgQCreate(MAX_MESSAGES, MAX_MESSAGE_LENGTH,
		MSG_Q_FIFO)) == NULL)
	{
		printf("msgQCreate in failed.\n");
	}

	if ((msgQueueIdNew = msgQCreate(MAX_MESSAGES, MAX_MESSAGE_LENGTH,
		MSG_Q_FIFO)) == NULL)
	{
		printf("msgQCreate in failed.\n");
	}

	if ((taskIdOne = taskSpawn("task1", PRI, 0, 2000,
		(FUNCTION)taskOne, 1, 2, 3, 4, 5)) == ERROR)
	{
		printf("taskSpawn taskOne failed.\n");
	}

	if ((taskIdTwo = taskSpawn("task2", PRI, 0, 2000,
		(FUNCTION)taskTwo, 1, 2, 3, 4, 5)) == ERROR)
	{
		printf("taskSpawn taskTwo failed.\n");
	}
}
void simulator()
{ 
	initiateProcess();
	oldSensors = getSensorValues();

	/*create both message queues*/
	if ((gateInQueue = msgQCreate(MAX_MESSAGES, MAX_MESSAGE_LENGTH, MSG_Q_FIFO)) == NULL)
		printf("msgQCreate failed for read to gate in queue\n");

	if ((gateOutQueue = msgQCreate(MAX_MESSAGES, MAX_MESSAGE_LENGTH, MSG_Q_FIFO)) == NULL)
		printf("msgQCreate failed for update to gate out queue\n");

	if((taskSpawn("TASK 0",70,0x100,2000,(FUNCPTR)inputWatcher,0,0,0,0,0,0,0,0,0,0))== ERROR)
	{
		printf("Error spawning input watcher task.\n");
	}

	/*TASK 1 = gate in*/
	if((taskSpawn("GATE IN",70,0x100,2000,(FUNCPTR)gateIn,0,0,0,0,0,0,0,0,0,0))== ERROR)
	{
		printf("Error spawning gateIn task.\n");
	}

	/*TASK 2 = gate out*/
	if((taskSpawn("GATE OUT",70,0x100,2000,(FUNCPTR)gateOut,0,0,0,0,0,0,0,0,0,0))== ERROR)
	{
		printf("Error spawning gateOut task.\n");
	}

}
Esempio n. 5
0
void main (void)
{
	

	/* Add your code here: create tasks, semaphores, ... */
	initHardware(0);
	
	analogInputs = semBCreate (SEM_Q_PRIORITY, SEM_FULL);
	writeDisplay = semBCreate (SEM_Q_PRIORITY, SEM_FULL);

	int readInputsID;
	readInputsID = taskSpawn ("readInputs", 150, 0,0x1000,(FUNCPTR) readInputs,0,0,0,0,0,0,0,0,0,0);
	
	int showInputsID;
	showInputsID = taskSpawn ("showInputs", 160, 0,0x1000,(FUNCPTR) showInputs,0,0,0,0,0,0,0,0,0,0);
	
	int readKeyboardID;
	readKeyboardID = taskSpawn ("readKeyboard", 170, 0,0x1000,(FUNCPTR) readKeyboard,0,0,0,0,0,0,0,0,0,0);

	int timerID;
	timerID = taskSpawn ("timer", 140, 0,0x1000,(FUNCPTR) timer,0,0,0,0,0,0,0,0,0,0);
	
	int tcpServerID;
	tcpServerID = taskSpawn ("tcpServer", 200, 0,0x1000,(FUNCPTR) tcpServer,0,0,0,0,0,0,0,0,0,0);

	printf("Hello World");

	/* Suspend own task */
	taskSuspend (0);
} /* main */
Esempio n. 6
0
/**
*  Routine Name:	: RunProgram
*  Description 		: Start point of the program
*  Returns			: n/a
*  Parameters		: n/a
* 
*/
void RunProgram(void)
{
	int taskID;
	int portNumber;
	
	memset ((void *)&globalData, 0, sizeof(globalData));
	
	//telnetServer("50000");
	portNumber = 50000;
	taskID = taskSpawn("telnetServer",
					100,							// priority
					VX_FP_TASK,						// floating point C++ context save
					64000,							// stack size
					(FUNCPTR) telnetServer,			// function to be called
                    portNumber,						// port number
                    0,0,0,0,0,0,0,0,0);				// parameters (unused)
	
	portNumber = 50001;
	taskID = taskSpawn("telnetServer",
					100,							// priority
					VX_FP_TASK,						// floating point C++ context save
					64000,							// stack size
					(FUNCPTR) telnetServer,			// function to be called
                    portNumber,						// port number
                    0,0,0,0,0,0,0,0,0);				// parameters (unused)

}
Esempio n. 7
0
int
main()
{
    osInit(50);

    taskSpawn("t1", 100, 0, 1000, task, 200);
    taskSpawn("t2", 100, 0, 1000, task, 300);
    shellMainLoop(stdin, stdout, stderr, "task% ");
    return 0;
}
Esempio n. 8
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);
	}
}
Esempio n. 9
0
void s3_sem2(void)
{
	int taskIdOne;
	int taskIdTwo;
	semBinary = semBCreate(SEM_Q_FIFO, SEM_FULL);
	/*semTake(semBinary, WAIT_FOREVER);	/* NOTE 2 */
	taskIdOne = taskSpawn("task1", 90, 0, 2000,
		(FUNCTION)taskOne, 1, 2, 3, 4, 5);
	taskIdTwo = taskSpawn("task2", 90, 0, 2000,
		(FUNCTION)taskTwo, 1, 2, 3, 4, 5);
}
void main (void)
{
	unsigned char tempOut;
	/* Connect interrupt service routine to vector and all stuff */
	intConnect (INUM_TO_IVEC(aioIntNum), my_ISR, aioIntNum);
	sysIntEnablePIC (aioIRQNum);
	/* Enable interrupts on the aio:
	* All interrupts and interrupt from counter 1 too */
	tempOut = 0x24;
	sysOutByte (aioBase + intEnAddress, tempOut);
	
	/* Start counter 1 as timer with 50 ms period 
	* It has a clock input of 1 MHz = 1 µs 
	* Therefore the load value is 0xC350 = 50000 */
	tempOut = 0x74;
	sysOutByte (aioBase + cntCntrlReg, tempOut);
	tempOut = 0x50;
	sysOutByte (aioBase + cnt1Address, tempOut);
	tempOut = 0xC3;
	sysOutByte (aioBase + cnt1Address, tempOut);

	/* Add your code here: create tasks, semaphores, ... */
	//printf("Hello World!");
	
	/*The second task shall do the following:
	 *	- It starts counter a as an auto-reload timer with a period of 50 ms.
	 *	- The interrupt generated by this counter activates the task.
	 *		This shall be done with a semaphore.
	 *	- The task reads the analog inputs of both the potentiometer and the temperature.
	 *	- If the values have changed compared to the previous ones, these shall be written into global
	 *		variables (AIn).
	 *	- A hysteresis of e.g. 10 – 20 bit is necessary due to the noise of the analog inputs.
	 * 
	 * */
	initHardware(0);
	
	int readTask;
	readTask = taskSpawn("tRead", 101, 0, 0x1000, (FUNCPTR) tRead,0,0,0,0,0,0,0,0,0,0);
	
	timIntSem = semBCreate(SEM_Q_PRIORITY, SEM_EMPTY);
	
	/* The third task shall do the following:
	 *	- It writes the values of the global variables (AIn) onto the display.
	 *	- This shall happen approx. each 100 ms
	 */
	int writeTask;
	writeTask = taskSpawn("tWrite",102,0,0x1000, (FUNCPTR) tWrite,0,0,0,0,0,0,0,0,0,0);
	
	/* Suspend own task */
	taskSuspend (0);	//suspended sich selber
} /* main */
Esempio n. 11
0
int main(int argc, char *argv[])
{
	TASK_ID tid;
	int ret;

	copperplate_init(argc, argv);

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

	tid = taskSpawn("rootTask", 50, 0, 0, rootTask,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
	traceobj_assert(&trobj, tid != ERROR);

	traceobj_mark(&trobj, 5);

	ret = semDelete(sem_id);
	traceobj_assert(&trobj, ret == OK);

	traceobj_mark(&trobj, 6);

	traceobj_join(&trobj);

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

	exit(0);
}
CVMBool
CVMthreadCreate(CVMThreadID *tid, CVMSize stackSize, CVMInt32 priority,
    void (*func)(void *), void *arg)
{
    int task_options = VX_FP_TASK;
    int taskID;
    int vxPrio;

    vxPrio = JAVAPRIO2VXPRIO(priority);
    if (stackSize == 0) {
	stackSize = javaThreadStackSize;
    }
    taskID = taskSpawn(NULL, vxPrio, task_options, stackSize,
                            (FUNCPTR)start_func, (int)func,
                            (int)arg,0,0,0,0,0,0,0,0);

    if (taskID == ERROR) {
#ifdef CVM_DEBUG
	perror("taskSpawn");
#endif
	return CVM_FALSE;
    } else {
	tid->taskID = taskID;
	return CVM_TRUE;
    }
}
Esempio n. 13
0
/**
 * loads the dll libraries and spawns a task for the MAINCRIO
 */
void MyStart(void) {
    printf("Loading Dynamic Library...\n");
    /* load the library */
#if NiFpga_Windows || NiFpga_Ets
    MODULE_ID lib =  LoadLibraryA("MainCRIO.dll");
#elif NiFpga_VxWorks
    MODULE_ID lib =  VxLoadLibraryFromPath("MainCRIO.out", 0);
#else
    printf("Error dudes loading MainCRIO.out\n");
#endif
    const char* const name = "MainCRIO";
    void** const address;
    SYM_TYPE type;
    STATUS retVal = symFindByName(sysSymTbl,
                                  (char*)name,
                                  (char**)address,
                                  &type);
    if (retVal == OK)
    {
        taskSpawn("MainCRIO", 100, VX_FP_TASK, 0x8000, (FUNCPTR) *address, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
    }
    else {
        perror("Error loading MainCRIO function");
    }
    /* Freeing the library makes shit go all explody if the task hasn't
     * exited */

    /*printf("Freeing the library...\n");
    VxFreeLibrary(lib, 0);
    printf("Library freed...\n");*/
}
Esempio n. 14
0
void central (char *options)
{
  taskSpawn(CENTRAL_VXWORKS_NAME, centralPriority, 
	    CENTRAL_VXWORKS_OPTIONS, centralStacksize,
	    (FUNCPTR)centralMain,
	    (int)options, 0, 0, 0, 0, 0, 0, 0, 0, 0);
}
Esempio n. 15
0
STATUS UrgencyLibInit (void)
    {
    static BOOL done = FALSE;

    if (done)
	return (UrgencyTaskId == ERROR ? ERROR : OK);

    if (semBInit (&UrgencyJobInfo.sem, SEM_Q_FIFO, SEM_EMPTY) == ERROR)
	return (ERROR);

#ifdef BSP_VIRTUAL_STACK_DELETE
    semBInit (UrgencyTaskDelSemId, SEM_Q_PRIORITY, SEM_FULL);

    if (UrgencyTaskDelSemId == NULL)
	return (ERROR);
#endif

    done = TRUE;

    if (UrgencyJobAlloc (UrgencyJobNum) != OK)
      {
      panic ("UrgencyLibInit: couldn't allocate job nodes\n");
      return ERROR;
      }

    UrgencyTaskId = taskSpawn ("tUrgencyTask", UrgencyTaskPriority,
		           UrgencyTaskOptions, UrgencyTaskStackSize,
			   (FUNCPTR)UrgencyTask, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);

    
    return (UrgencyTaskId == ERROR ? ERROR : OK);
    }
VOS_UINT32 Monitor_Init(VOS_VOID)
{

    /*读取开关分集的USIM卡温度门限*/
    if(NV_OK != NV_Read(en_NV_Item_W_USIM_TEMP_ANT2_CTRL,
                            (VOS_VOID*)&g_stMonitorUsimAntCtrl,
                            sizeof(MONITOR_USIM_ANT2_CTRL)))
    {
        g_ulMonitorErrCode |= MONITOR_ERR_CODE_NV;

        return VOS_ERR;
    }

    if (VOS_OK != VOS_SmCCreate("MONS", 0, VOS_SEMA4_FIFO, &(g_ulMonitorCtrlSem)))
    {
        g_ulMonitorErrCode |= MONITOR_ERR_CODE_SEM;

        return VOS_ERR;
    }

#if (VOS_VXWORKS == VOS_OS_VER)
    taskSpawn("MONITOR_TASK", 159, 0, 10240,(FUNCPTR)Monitor_QueryTask, 0, 0, 0, 0, 0, 0, 0, 0,0,0);
#endif

    return VOS_OK;
}
Esempio n. 17
0
startNodeHBPub(int priority, int taskoptions, int stacksize)
{

    if (taskNameToId("tAppHBPub") == ERROR)
        taskSpawn("tAppHBPub",priority,0,stacksize,pubHB,1,
                  2,3,4,5,6,7,8,9,10);
}
int vxhGo()
{
  vxhStop();
  tid = taskNameToId("tShell");
  taskPrioritySet(tid,4);
  tid = taskNameToId("tLogTask");
  taskPrioritySet(tid,3);
  tid = taskNameToId("tExcTask");
  taskPrioritySet(tid,3);
  tid = taskNameToId("tTelnetd");
  taskPrioritySet(tid,5);
  tid = taskNameToId("tTelnetOutTask");
  taskPrioritySet(tid,6);
  tid = taskNameToId("tTelnetInTask");
  taskPrioritySet(tid,6);
  tid = taskNameToId("tWdbTask");
  taskPrioritySet(tid,7);

  vxh_stop_flag=0;
  vxh_count=0;
  vxh_id =  taskSpawn(0, //name
		1,		// priority
		VX_FP_TASK,	// options
		0x2000,		// stack size
		(FUNCPTR) vxh_task, // entry point
		      0,0,0,0,0,
		      0,0,0,0,0);
  return(0);
}
Esempio n. 19
0
File: netLib.c Progetto: phoboz/vmx
STATUS netLibInit(void)
{
  if (netLibInstalled == TRUE) {

    /* Return error if task not initialized */
    if (netTaskId == (int) NULL)
      return ERROR;

    return OK;
  }

  /* Mark as initialized */
  netLibInstalled = TRUE;

  /* Create network ring buffer */
  netWorkRing = rngCreate(NET_LIB_RING_SIZE);
  if (netWorkRing == NULL)
    return ERROR;

  /* Initialize network semaphore */
  semBInit(netTaskSemId, SEM_Q_PRIORITY, SEM_EMPTY);

  /* Start network task */
  netTaskId = taskSpawn("tNetTask", netTaskPriority,
                        netTaskOptions, netTaskStackSize,
                        (FUNCPTR) netTask,
                        0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
  if (netTaskId == (int) NULL)
    return ERROR;

  return OK;
}
Esempio n. 20
0
void ficl_taskSpawn(ficlVm *vm)
{
  int tNameLen;
  char *tName;
  int priority;
  int flags;
  int stackSize;
  unsigned command;

  char *taskName;

  FICL_STACK_CHECK(vm->dataStack,6,0);

  tNameLen = ficlStackPopInteger(vm->dataStack);
  tName =  ficlStackPopPointer(vm->dataStack);
  priority = ficlStackPopInteger(vm->dataStack);
  flags = ficlStackPopInteger(vm->dataStack);
  stackSize = ficlStackPopInteger(vm->dataStack);
  command = ficlStackPopUnsigned(vm->dataStack);

  if (simon_system == NULL)
    simon_boot(NULL);

  taskName = malloc(strlen(tName)+1);
  strcpy(taskName,tName);

  taskSpawn(taskName,priority,flags,stackSize,
	    spawn_helper,command,(int)taskName,0,0,0,0,0,0,0,0);
}
Esempio n. 21
0
void mxserver( int port_number,
		char *device_database_file,
		char *access_control_list_file,
		int detach )
{
	int task_id, priority, stack_size;

	if ( detach == 0 ) {
		mxserver_task( port_number,
			device_database_file,
			access_control_list_file );
	} else {

		priority = 0;
		stack_size = 65536;

		task_id = taskSpawn( "mxserver_task",
				priority,
				VX_FP_TASK,
				stack_size,
				(FUNCPTR) mxserver_task,
				port_number,
				(int) device_database_file,
				(int) access_control_list_file,
                                0, 0, 0, 0, 0, 0, 0 );

		fprintf( stderr, "mxserver_task() started.  task_id = %#lx\n",
			(unsigned long) task_id );
	}

	return;
}
Esempio n. 22
0
STATUS pcmciaInit (void)

    {
    PCMCIA_CTRL *pCtrl		= &pcmciaCtrl;
    PCMCIA_CHIP *pChip		= &pCtrl->chip;
    PCMCIA_CARD *pCard;
    PCMCIA_ADAPTER *pAdapter 	= NULL;
    int sock;
    int ix;


    pcmciaMsgQId = msgQCreate (PCMCIA_MAX_MSGS, sizeof(PCMCIA_MSG), MSG_Q_FIFO);

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

    pcmciadId = taskSpawn ("tPcmciad", pcmciadPriority,
			   pcmciadOptions, pcmciadStackSize,
			   (FUNCPTR) pcmciad, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);

    if (pcmciadId == ERROR)
	return (ERROR);

    for (ix = 0; ix < pcmciaAdapterNumEnt; ix++)
	{
        pAdapter = &pcmciaAdapter[ix];
        if ((* pAdapter->initRtn) (pAdapter->ioBase,
				   pAdapter->intVec,
				   pAdapter->intLevel,
				   pAdapter->showRtn) == OK)
	    break;
	}

    if (ix >= pcmciaAdapterNumEnt)
	return (ERROR);

    semMInit (&cisMuteSem, SEM_Q_PRIORITY | SEM_DELETE_SAFE |
	      SEM_INVERSION_SAFE);

    (void) intConnect ((VOIDFUNCPTR *)INUM_TO_IVEC(pAdapter->intVec),
		       (VOIDFUNCPTR)pcmciaCscIntr, 0);

    if (pCtrl->socks != 0)		/* if explicitely defined, use it */
        pChip->socks = pCtrl->socks;

    for (sock = 0; sock < pChip->socks; sock++)
	{
	pCard = &pCtrl->card[sock];

	if ((pCard->cardStatus = (* pChip->status) (sock)) & PC_IS_CARD)
	    (void) cisGet (sock);

        (void) (* pChip->cscPoll) (sock);
        (void) (* pChip->cscOn) (sock, pChip->intLevel);
	}

    sysIntEnablePIC (pAdapter->intLevel);

    return (OK);
    }
/*lint -save -e64*/
MAILBOX_EXTERN int mailbox_init_platform(void)
{
    struct mb_vx_proc   *process    = &g_mailbox_vx_proc_tbl[0];
    unsigned int        count      =  sizeof(g_mailbox_vx_proc_tbl) /
                                       sizeof(struct mb_vx_proc);
    unsigned int        proc_id;

    /*创建平台任务中断信号量部分*/
    while (count) {
        /*为任务处理方式的邮箱通道创建任务*/
        proc_id = process->id;
        if ((proc_id > MAILBOX_VXWORKS_PROC_STYLE_TASK_RESERVED) && (proc_id < MAILBOX_VXWORKS_PROC_STYLE_TASK_BUTT)) {
            /* 创建邮箱接收任务等待信号量*/
            osl_sem_init(0, &process->sema);

            /* 创建邮箱收数据处理任务*/
            if (ERROR == (int)taskSpawn((char *)process->name, (int)process->priority, (int)0,
                            (int)process->stack,
                            (void*)mailbox_receive_task,
                            (int)(&process->sema),
                            (int)(&process->vxqueue),
                            (int)0, (int)0, (int)0, (int)0, (int)0, (int)0, (int)0, (int)0)) /*lint !e119 !e64*/
            {
                return mailbox_logerro_p1(MAILBOX_ERR_VXWORKS_TASK_CREATE, proc_id);
            }
        }
        count--;
        process++;
    }

    mailbox_usr_init();

    return MAILBOX_OK;
}
Esempio n. 24
0
STATUS ossThreadCreate 
    (
    THREAD_PROTOTYPE func,	    /* function to spawn as new thread */
    pVOID param,		    /* Parameter to be passed to new thread */
    UINT16 priority,		    /* OSS_PRIORITY_xxxx */
    pCHAR name, 		    /* thread name or NULL */
    pTHREAD_HANDLE pThreadHandle    /* Handle of newly spawned thread */
    )

    {
    /* validate params */

    if (pThreadHandle == NULL)
	return ossStatus (S_ossLib_BAD_PARAMETER);


    /* Use vxWorks to spawn a new thread (task in vxWorks parlance). */

    if ((*pThreadHandle = (THREAD_HANDLE) taskSpawn (name, 
	translatePriority (priority), DEFAULT_OPTIONS, DEFAULT_STACK, 
	threadHead, (int) func, (int) param, 0, 0, 0, 0, 0, 0, 0, 0)) == 
	(THREAD_HANDLE) ERROR)
	return ossStatus (S_ossLib_GENERAL_FAULT);

    return OK;
    }
Esempio n. 25
0
/******************************************************************************
*
* usrTimeInit - init system time and Real-Time Clock
*
*/
void usrTimeInit(void)
    {

    usrTimeSync();

    taskSpawn("tTimeSync", 255, 0, 4096, usrTimeAdj, 60,
		0,0,0,0,0,0,0,0,0);
    }
Esempio n. 26
0
void sched(void) /* function to create the two tasks */
{
int taskIdOne, taskIdTwo, taskIdThree;

printf("\n\n\n\n\n");
/* spawn the three tasks */
if((taskIdOne = taskSpawn("task2",LOW,0x100,20000,(FUNCPTR)taskOne,0,0,0,0,0,0,0,
	0,0,0)) == ERROR)
	printf("taskSpawn taskOne failed\n");
if((taskIdTwo = taskSpawn("task2",MID,0x100,20000,(FUNCPTR)taskTwo,0,0,0,0,0,0,0,
	0,0,0)) == ERROR)
	printf("taskSpawn taskTwo failed\n");
if((taskIdThree = taskSpawn("task3",HIGH,0x100,20000,(FUNCPTR)taskThree,0,0,0,0,0,0,0,
	0,0,0)) == ERROR)
	printf("taskSpawn taskThree failed\n");

}
Esempio n. 27
0
void task_leds_start(void)
{
    taskSpawn("LEDS",
            OS_TASK_LEDS_PRIO,
            the_leds_stack,
            TASK_LEDS_STK_SIZE,
            (OSFUNCPTR)leds_loop, 0);
}
Esempio n. 28
0
File: cmd.c Progetto: embedthis/mpr
/*
    Start the command to run (stdIn and stdOut are named from the client's perspective)
 */
PUBLIC int startProcess(MprCmd *cmd)
{
    MprCmdTaskFn    entryFn;
    MprModule       *mp;
    char            *entryPoint, *program, *pair;
    int             pri, next;

    mprLog("info mpr cmd", 4, "Program %s", cmd->program);
    entryPoint = 0;
    if (cmd->env) {
        for (ITERATE_ITEMS(cmd->env, pair, next)) {
            if (sncmp(pair, "entryPoint=", 11) == 0) {
                entryPoint = sclone(&pair[11]);
            }
        }
    }
    program = mprGetPathBase(cmd->program);
    if (entryPoint == 0) {
        program = mprTrimPathExt(program);
        entryPoint = program;
    }
#if ME_CPU_ARCH == MPR_CPU_IX86 || ME_CPU_ARCH == MPR_CPU_IX64 || ME_CPU_ARCH == MPR_CPU_SH
    /*
        A leading underscore is required on some architectures
     */
    entryPoint = sjoin("_", entryPoint, NULL);
#endif
    if (mprFindVxSym(sysSymTbl, entryPoint, (char**) (void*) &entryFn) < 0) {
        if ((mp = mprCreateModule(cmd->program, cmd->program, NULL, NULL)) == 0) {
            mprLog("error mpr cmd", 0, "Cannot create module");
            return MPR_ERR_CANT_CREATE;
        }
        if (mprLoadModule(mp) < 0) {
            mprLog("error mpr cmd", 0, "Cannot load DLL %s, errno %d", program, mprGetOsError());
            return MPR_ERR_CANT_READ;
        }
        if (mprFindVxSym(sysSymTbl, entryPoint, (char**) (void*) &entryFn) < 0) {
            mprLog("error mpr cmd", 0, "Cannot find symbol %s, errno %d", entryPoint, mprGetOsError());
            return MPR_ERR_CANT_ACCESS;
        }
    }
    taskPriorityGet(taskIdSelf(), &pri);

    cmd->pid = taskSpawn(entryPoint, pri, VX_FP_TASK | VX_PRIVATE_ENV, ME_STACK_SIZE, (FUNCPTR) cmdTaskEntry,
        (int) cmd->program, (int) entryFn, (int) cmd, 0, 0, 0, 0, 0, 0, 0);

    if (cmd->pid < 0) {
        mprLog("error mpr cmd", 0, "Cannot create task %s, errno %d", entryPoint, mprGetOsError());
        return MPR_ERR_CANT_CREATE;
    }
    if (semTake(cmd->startCond, MPR_TIMEOUT_START_TASK) != OK) {
        mprLog("error mpr cmd", 0, "Child %s did not initialize, errno %d", cmd->program, mprGetOsError());
        return MPR_ERR_CANT_CREATE;
    }
    semDelete(cmd->startCond);
    cmd->startCond = 0;
    return 0;
}
//------------------------------------------------------------------------------
// Function:    ShbIpcStartSignalingNewData
//
// Description: Start signaling of new data (called from reading process)
//
// Parameters:  pShbInstance_p                  pointer to shared buffer instance
//              pfnSignalHandlerNewData_p       pointer to master buffer instance
//
// Return:      tShbError      = error code
//------------------------------------------------------------------------------
tShbError  ShbIpcStartSignalingNewData(tShbInstance pShbInstance_p,
                                       tSigHndlrNewData pfnSignalHandlerNewData_p,
                                       tShbPriority ShbPriority_p)
{
    tShbMemInst*        pShbMemInst;
    tShbMemHeader*      pShbMemHeader;
    tShbError           ShbError;
    INT                 iSchedPriority;

    if ((pShbInstance_p == NULL) || (pfnSignalHandlerNewData_p == NULL))
    {
        return (kShbInvalidArg);
    }

    pShbMemInst   = ShbIpcGetShbMemInst   (pShbInstance_p);
    pShbMemHeader = ShbIpcGetShbMemHeader (pShbInstance_p);
    ShbError = kShbOk;

    if ((pShbMemInst->m_fNewDataThreadStarted) ||
        (pShbMemInst->m_pfnSigHndlrNewData != NULL))
    {
        ShbError = kShbAlreadySignaling;
        EPL_DBGLVL_ERROR_TRACE("%s() Thread already started!\n", __func__);
        goto Exit;
    }

    pShbMemInst->m_pfnSigHndlrNewData = pfnSignalHandlerNewData_p;

    iSchedPriority = EPL_TASK_PRIORITY_SHB;
    switch (ShbPriority_p)
    {
        case kShbPriorityLow:
            iSchedPriority += 5;
            break;

        case kShbPriorityNormal:
            iSchedPriority += 0;
            break;

        case kShbPriorityHigh:
            iSchedPriority -= 5;
            break;
    }

    if ((pShbMemInst->m_tThreadNewDataId =
    		taskSpawn ("tShbIpc", iSchedPriority,
                       0, EPL_TASK_STACK_SIZE, &ShbIpcThreadSignalNewData,
                       (int)pShbInstance_p, 0, 0, 0, 0, 0, 0, 0, 0, 0)) == ERROR)
    {
        pShbMemInst->m_pfnSigHndlrNewData = NULL;
        ShbError = kShbInvalidSigHndlr;
        goto Exit;
    }

Exit:
    return (ShbError);
}
Esempio n. 30
0
void main(){
	
	int taskId,i=1;
	
	for(;i<ITER;i++)
		taskId = taskSpawn("tprint_task",i*50,0x100,200,
				(FUNCPTR)print_task,i,0,0,0,0,0,0,0,0,0);
	
}