pkarashchenko commented on code in PR #6318: URL: https://github.com/apache/incubator-nuttx/pull/6318#discussion_r911326478
########## sched/wqueue/kwork_inherit.c: ########## @@ -66,91 +66,40 @@ static void lpwork_boostworker(pid_t wpid, uint8_t reqprio) wtcb = nxsched_get_tcb(wpid); DEBUGASSERT(wtcb); -#if CONFIG_SEM_NNESTPRIO > 0 + /* REVISIT: Priority multi-boost is not supported */ + + DEBUGASSERT(wtcb->boost_priority == 0); + /* If the priority of the client thread that is greater than the base * priority of the worker thread, then we may need to adjust the worker * thread's priority now or later to that priority. */ if (reqprio > wtcb->base_priority) { - /* If the new priority is greater than the current, possibly already - * boosted priority of the worker thread, then we will have to raise - * the worker thread's priority now. + /* Save boost priority value as it might be needed in case of multiple + * re-prioritisations happen, then the priority of the thread can't go + * below the boost priority value until priority boost is canceled */ - if (reqprio > wtcb->sched_priority) - { - /* If the current priority of worker thread has already been - * boosted, then add the boost priority to the list of restoration - * priorities. When the higher priority waiter thread gets its - * count, then we need to revert the worker thread to this saved - * priority (not to its base priority). - */ - - if (wtcb->sched_priority > wtcb->base_priority) - { - /* Save the current, boosted priority of the worker thread. */ - - if (wtcb->npend_reprio < CONFIG_SEM_NNESTPRIO) - { - wtcb->pend_reprios[wtcb->npend_reprio] = - wtcb->sched_priority; - wtcb->npend_reprio++; - } - else - { - serr("ERROR: CONFIG_SEM_NNESTPRIO exceeded\n"); - DEBUGASSERT(wtcb->npend_reprio < CONFIG_SEM_NNESTPRIO); - } - } + wtcb->boost_priority = reqprio; - /* Raise the priority of the worker. This cannot cause a context - * switch because we have preemption disabled. The worker thread - * may be marked "pending" and the switch may occur during - * sched_unblock() processing. - */ + /* If the priority of the client thread that is less than of equal to + * the priority of the worker thread, then do nothing because the + * thread is already running at a sufficient priority. + */ - nxsched_set_priority(wtcb, reqprio); - } - else + if (reqprio > wtcb->sched_priority) { - /* The new priority is above the base priority of the worker, - * but not as high as its current working priority. Just put it - * in the list of pending restoration priorities so that when the - * higher priority thread gets its count, we can revert to this - * saved priority and not to the base priority. + /* Raise the priority of the worker thread. This cannot cause Review Comment: reminder to self: need to fix the comment -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org