Exemplo n.º 1
0
/*..........................................................................*/
void QActive_start(QActive *me, uint8_t prio,
                   QEvent const *qSto[], uint32_t qLen,
                   void *stkSto, uint32_t stkSize,
                   QEvent const *ie)
{
   
	int err;

	me->eQueue = xQueueCreate( qLen , sizeof(QEvent*) );

    Q_ASSERT(me->eQueue != (void *)0);        /*  queue created */
    me->prio = prio;                                /* save the QF priority */
    QF_add_(me);                     /* make QF aware of this active object */
    QF_ACTIVE_INIT_(&me->super, ie);          /* execute initial transition */

    QS_FLUSH();                       /* flush the trace buffer to the host */
 //  	vTaskDelay( 0x32 );
                        /* task is represented by its unique priority */
//    me->thread = (uint8_t)(QF_MAX_ACTIVE - me->prio); /* map to OSprio. */	   

    err= xTaskCreate( task_function, task_name[task_idx] , 0x100 * 3, me,tskIDLE_PRIORITY+me->prio, &me->thread);

    Q_ASSERT(me->thread !=  (xTaskHandle) NULL );
	 task_idx++;
}
Exemplo n.º 2
0
/*..........................................................................*/
void QActive_start(QActive *me, uint8_t prio,
                   QEvent const *qSto[], uint32_t qLen,
                   void *stkSto, uint32_t stkSize,
                   QEvent const *ie)
{
    INT8U err;
    me->eQueue = OSQCreate((void **)qSto, qLen);
    Q_ASSERT(me->eQueue != (OS_EVENT *)0);        /* uC/OS-II queue created */
    me->prio = prio;                                /* save the QF priority */
    QF_add_(me);                     /* make QF aware of this active object */
    QF_ACTIVE_INIT_(&me->super, ie);          /* execute initial transition */

    QS_FLUSH();                       /* flush the trace buffer to the host */

                        /* uC/OS task is represented by its unique priority */
    me->thread = (uint8_t)(QF_MAX_ACTIVE - me->prio); /* map to uC/OS prio. */
    err = OSTaskCreateExt(&task_function,              /* the task function */
             me,                                   /* the 'pdata' parameter */
             &(((OS_STK *)stkSto)[(stkSize / sizeof(OS_STK)) - 1]), /* ptos */
             me->thread,                          /* uC/OS-II task priority */
             me->thread,                                         /* task id */
             (OS_STK *)stkSto,                                      /* pbos */
             stkSize/sizeof(OS_STK),   /* size of the stack in OS_STK units */
             (void *)0,                                             /* pext */
             (INT16U)OS_TASK_OPT_STK_CLR);                           /* opt */
    Q_ASSERT(err == OS_NO_ERR);                    /* uC/OS-II task created */
}
Exemplo n.º 3
0
/*..........................................................................*/
void QF_run(void) {
    uint8_t p;
    QActive *a;
    QEvent const *e;
    QF_INT_LOCK_KEY_

    QF_onStartup();                                     /* startup callback */

    for (;;) {                                       /* the background loop */
        QF_INT_LOCK_();

#if (QF_MAX_ACTIVE <= 8)
        if (QPSet8_notEmpty(&QF_readySet_)) {
            QPSet8_findMax(&QF_readySet_, p);
#else
        if (QPSet64_notEmpty(&QF_readySet_)) {
            QPSet64_findMax(&QF_readySet_, p);
#endif
            a = QF_active_[p];
            QF_INT_UNLOCK_();

            e = QActive_get_(a);          /* get the next event for this AO */
            QF_ACTIVE_DISPATCH_(&a->super, e);        /* dispatch to the AO */
            QF_gc(e); /* determine if event is garbage and collect it if so */
        }
        else {
#ifndef QF_INT_KEY_TYPE
            QF_onIdle();                                      /* see NOTE01 */
#else
            QF_onIdle(intLockKey_);                           /* see NOTE01 */
#endif                                                   /* QF_INT_KEY_TYPE */
        }
    }
}
/*..........................................................................*/
void QActive_start(QActive *me, uint8_t prio,
                   QEvent const *qSto[], uint32_t qLen,
                   void *stkSto, uint32_t stkSize,
                   QEvent const *ie)
{
    Q_REQUIRE(((uint8_t)0 < prio) && (prio <= (uint8_t)QF_MAX_ACTIVE)
              && (stkSto == (void *)0));   /* does not need per-actor stack */

    (void)stkSize;         /* avoid the "unused parameter" compiler warning */
    QEQueue_init(&me->eQueue, qSto, (QEQueueCtr)qLen);/* initialize QEQueue */
    me->prio = prio;           /* set the QF priority of this active object */
    QF_add_(me);                     /* make QF aware of this active object */
    QF_ACTIVE_INIT_(&me->super, ie);          /* execute initial transition */

    QS_FLUSH();                       /* flush the trace buffer to the host */
}
Exemplo n.º 4
0
/*..........................................................................*/
void QActive_start(QActive *me, uint8_t prio,
                  QEvent const *qSto[], uint32_t qLen,
                  void *stkSto, uint32_t stkSize,
                  QEvent const *ie)
{
    pthread_attr_t attr;
    struct sched_param param;

    Q_REQUIRE(stkSto == (void *)0);  /* p-threads allocate stack internally */

    QEQueue_init(&me->eQueue, qSto, (QEQueueCtr)qLen);
    pthread_cond_init(&me->osObject, 0);

    me->prio = prio;
    QF_add_(me);                     /* make QF aware of this active object */
    QF_ACTIVE_INIT_(&me->super, ie);      /* execute the initial transition */

    QS_FLUSH();                       /* flush the trace buffer to the host */

    pthread_attr_init(&attr);

    /* SCHED_FIFO corresponds to real-time preemptive priority-based scheduler
    * NOTE: This scheduling policy requires the superuser privileges
    */
    pthread_attr_setschedpolicy(&attr, SCHED_FIFO);
                                                              /* see NOTE04 */
    param.sched_priority = prio
                           + (sched_get_priority_max(SCHED_FIFO)
                              - QF_MAX_ACTIVE - 3);

    pthread_attr_setschedparam(&attr, &param);
    pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);

    if (pthread_create(&me->thread, &attr, &thread_routine, me) != 0) {
               /* Creating the p-thread with the SCHED_FIFO policy failed.
               * Most probably this application has no superuser privileges,
               * so we just fall back to the default SCHED_OTHER policy
               * and priority 0.
               */
        pthread_attr_setschedpolicy(&attr, SCHED_OTHER);
        param.sched_priority = 0;
        pthread_attr_setschedparam(&attr, &param);
        Q_ALLEGE(pthread_create(&me->thread, &attr, &thread_routine, me)== 0);
    }
    pthread_attr_destroy(&attr);
}
Exemplo n.º 5
0
/*..........................................................................*/
void QActive_start(QActive *me, uint8_t prio,
                  QEvent const *qSto[], uint32_t qLen,
                  void *stkSto, uint32_t stkSize,
                  QEvent const *ie)
{
    int p;
    DWORD threadId;

    Q_REQUIRE((stkSto == (void *)0)   /* Windows allocates stack internally */
              && (stkSize != 0));

    QEQueue_init(&me->eQueue, qSto, (QEQueueCtr)qLen);
    me->osObject = CreateEvent(NULL, FALSE, FALSE, NULL);
    me->prio = prio;
    QF_add_(me);                     /* make QF aware of this active object */
    QF_ACTIVE_INIT_(&me->super, ie);          /* execute initial transition */

    me->thread = CreateThread(NULL, stkSize,
                              &thread_function, me, 0, &threadId);
    Q_ASSERT(me->thread != (HANDLE)0);            /* thread must be created */

    switch (me->prio) {              /* remap QF priority to Win32 priority */
        case 1:
            p = THREAD_PRIORITY_IDLE;
            break;
        case 2:
            p = THREAD_PRIORITY_LOWEST;
            break;
        case 3:
            p = THREAD_PRIORITY_BELOW_NORMAL;
            break;
        case (QF_MAX_ACTIVE - 1):
            p = THREAD_PRIORITY_ABOVE_NORMAL;
            break;
        case QF_MAX_ACTIVE:
            p = THREAD_PRIORITY_HIGHEST;
            break;
        default:
            p = THREAD_PRIORITY_NORMAL;
            break;
    }
    SetThreadPriority(me->thread, p);
}
/*..........................................................................*/
void QActive_start(QActive *me, uint8_t prio,
                   QEvt const *qSto[], uint32_t qLen,
                   void *stkSto, uint32_t stkSize,
                   QEvt const *ie)
{
    Q_REQUIRE(((uint8_t)0 < prio) && (prio <= (uint8_t)QF_MAX_ACTIVE));

    QEQueue_init(&me->eQueue, qSto, (QEQueueCtr)qLen);
    me->prio = prio;
    QF_add_(me);                     /* make QF aware of this active object */

#if defined(QK_TLS) || defined(QK_EXT_SAVE)
    me->osObject = (uint8_t)stkSize;  /* osObject contains the thread flags */
    me->thread = stkSto;/* contains the pointer to the thread-local storage */
#else
    Q_ASSERT((stkSto == (void *)0) && (stkSize == (uint32_t)0));
#endif

    QF_ACTIVE_INIT_(&me->super, ie);          /* execute initial transition */

    QS_FLUSH();                       /* flush the trace buffer to the host */
}