Exemple #1
0
/*..........................................................................*/
void QActive_start_(QActive * const me, uint_fast8_t prio,
                    QEvt const *qSto[], uint_fast16_t qLen,
                    void *stkSto, uint_fast16_t stkSize,
                    QEvt const *ie)
{
    /* create the embOS message box for the AO */
    OS_CreateMB(&me->eQueue,
                (OS_U16)sizeof(QEvt *),
                (OS_UINT)qLen,
                (void *)&qSto[0]);

    me->prio = prio;  /* save the QF priority */
    QF_add_(me);      /* make QF aware of this active object */
    QMSM_INIT(&me->super, ie);  /* thake the top-most initial tran. */
    QS_FLUSH(); /* flush the trace buffer to the host */

    /* create an embOS task for the AO */
    OS_CreateTaskEx(&me->thread,
                    "AO",
                    (OS_PRIO)prio, /* embOS uses the same numbering as QP */
                    &thread_function,
                    (void OS_STACKPTR *)stkSto,
                    (OS_UINT)stkSize,
                    (OS_UINT)0,    /* no AOs at the same prio */
                    (void *)me);
}
Exemple #2
0
//............................................................................
void QMActive::start(uint_fast8_t prio,
                     QEvt const *qSto[], uint_fast16_t qLen,
                     void *stkSto, uint_fast16_t stkSize,
                     QEvt const *ie)
{
    // create the embOS message box for the AO
    OS_CreateMB(&m_eQueue,
                static_cast<OS_U16>(sizeof(QEvt *)),
                static_cast<OS_UINT>(qLen),
                static_cast<void *>(&qSto[0]));

    m_prio = prio;  // save the QF priority
    QF::add_(this); // make QF aware of this active object
    init(ie);       // thake the top-most initial tran.
    QS_FLUSH();     // flush the trace buffer to the host

    // create an embOS task for the AO
    OS_CreateTaskEx(&m_thread,
        "AO",
        static_cast<OS_PRIO>(prio), // embOS uses same numbering as QP
        &thread_function,
        static_cast<void OS_STACKPTR *>(stkSto),
        static_cast<OS_UINT>(stkSize),
        static_cast<OS_UINT>(0),    // no AOs at the same prio
        this);
}
bool_t osCreateStaticTask(OsTask *task, const char_t *name, OsTaskCode taskCode,
   void *params, void *stack, size_t stackSize, int_t priority)
{
   //Create a new task
   OS_CreateTaskEx(task, name, priority, taskCode,
      stack, stackSize * sizeof(uint_t), 1, params);

   //The task was successfully created
   return TRUE;
}
Exemple #4
0
/*-----------------------------------------------------------------------------------
 * Starts a new thread with priority "prio" that will begin its execution in the
 * function "thread()". The "arg" argument will be passed as an argument to the
 * thread() function. The id of the new thread is returned. Both the id and
 * the priority are system dependent.
 */
/*@null@*/ int  sys_thread_new( const char *name, lwip_thread_fn thread, void *arg, int stacksize, int prio, sys_thread_t* thread_out )
{
    emos_task_t* task = malloc_named("sys_thread_new", sizeof(emos_task_t));
    task->stack = malloc_named("sys_thread_new", stacksize*sizeof(int));


    /* The first time this is called we are creating the lwIP handler. */
    OS_CreateTaskEx(&task->task, name, prio, thread, task->stack, stacksize*sizeof(int), 0, arg);

#if LWIP_SYS_ARCH_TIMEOUTS
    /* For each task created, store the task handle (pid) in the timers array.
     * This scheme doesn't allow for threads to be deleted
     */
    timeout_list[next_thread++].pid = created_task;
#endif /* if LWIP_SYS_ARCH_TIMEOUTS */

    *thread_out = task;
    return 0;//( result == pdPASS )? 0 : -1;
    //return((sys_thread_t)task);
}
OsTask *osCreateTask(const char_t *name, OsTaskCode taskCode,
   void *params, size_t stackSize, int_t priority)
{
   uint_t i;
   OS_TASK *task;
   void *stack;

   //Enter critical section
   osSuspendAllTasks();

   //Loop through TCB table
   for(i = 0; i < OS_PORT_MAX_TASKS; i++)
   {
      //Check whether the current entry is free
      if(tcbTable[i] == NULL)
         break;
   }

   //Any entry available in the table?
   if(i < OS_PORT_MAX_TASKS)
   {
      //Allocate a memory block to hold the task's control block
      task = osAllocMem(sizeof(OS_TASK));

      //Successful memory allocation?
      if(task != NULL)
      {
         //Allocate a memory block to hold the task's stack
         stack = osAllocMem(stackSize * sizeof(uint_t));

         //Successful memory allocation?
         if(stack != NULL)
         {
            //Create a new task
            OS_CreateTaskEx(task, name, priority, taskCode,
               stack, stackSize * sizeof(uint_t), 1, params);

            //Save TCB base address
            tcbTable[i] = task;
            //Save stack base address
            stkTable[i] = stack;
         }
         else
         {
            osFreeMem(task);
            //Memory allocation failed
            task = NULL;
         }
      }
   }
   else
   {
      //Memory allocation failed
      task = NULL;
   }

   //Leave critical section
   osResumeAllTasks();

   //Return task pointer
   return task;
}