// ----------------------------------------------------------------------------- //! \brief Initialize an RTOS queue to hold messages to be processed. //! //! \param pQueue - pointer to queue instance structure. //! //! \return A queue handle. // ----------------------------------------------------------------------------- Queue_Handle NPIUtil_constructQueue(Queue_Struct *pQueue) { // Construct a Queue instance. Queue_construct(pQueue, NULL); return Queue_handle(pQueue); }
/* * ======== pthread_setschedparam ======== */ int pthread_setschedparam(pthread_t pthread, int policy, const struct sched_param *param) { pthread_Obj *thread = (pthread_Obj *)pthread; Task_Handle task = thread->task; UInt oldPri; int priority = param->sched_priority; UInt key; #if ti_sysbios_posix_Settings_supportsMutexPriority__D int maxPri; #endif if ((priority >= Task_numPriorities) || ((priority == 0)) || (priority < -1)) { /* Bad priority value */ return (EINVAL); } key = Task_disable(); oldPri = Task_getPri(task); thread->priority = priority; #if ti_sysbios_posix_Settings_supportsMutexPriority__D /* * If the thread is holding a PTHREAD_PRIO_PROTECT or * PTHREAD_PRIO_INHERIT mutex and running at its ceiling, we don't * want to set its priority to a lower value. Instead, we save the * new priority to set it to, once the mutexes of higher priority * ceilings are released. */ if (!Queue_empty(Queue_handle(&(thread->mutexList)))) { maxPri = _pthread_getMaxPrioCeiling(thread); if (priority > maxPri) { Task_setPri(task, priority); } } else { /* The thread owns no mutexes */ oldPri = Task_setPri(task, priority); } #else oldPri = Task_setPri(task, priority); #endif Task_restore(key); /* Suppress warning about oldPri not being used. */ (void)oldPri; return (0); }