Skip to content

Commit

Permalink
sched/lockcount: replace all lockcount check to nxsched_islocked_tcb()
Browse files Browse the repository at this point in the history
replace all lockcount check to nxsched_islocked_tcb()

Signed-off-by: chao an <[email protected]>
  • Loading branch information
anchao authored and xiaoxiang781216 committed Nov 26, 2024
1 parent 4dda980 commit 401e8eb
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
5 changes: 3 additions & 2 deletions sched/sched/sched_addreadytorun.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ bool nxsched_add_readytorun(FAR struct tcb_s *btcb)
* also disabled.
*/

if (rtcb->lockcount > 0 && rtcb->sched_priority < btcb->sched_priority)
if (nxsched_islocked_tcb(rtcb) &&
rtcb->sched_priority < btcb->sched_priority)
{
/* Yes. Preemption would occur! Add the new ready-to-run task to the
* g_pendingtasks task list for now.
Expand All @@ -96,7 +97,7 @@ bool nxsched_add_readytorun(FAR struct tcb_s *btcb)
* is now the new active task!
*/

DEBUGASSERT(rtcb->lockcount == 0 && !is_idle_task(btcb));
DEBUGASSERT(!nxsched_islocked_tcb(rtcb) && !is_idle_task(btcb));

btcb->task_state = TSTATE_TASK_RUNNING;
btcb->flink->task_state = TSTATE_TASK_READYTORUN;
Expand Down
4 changes: 2 additions & 2 deletions sched/sched/sched_critmonitor.c
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ void nxsched_resume_critmon(FAR struct tcb_s *tcb)
#if CONFIG_SCHED_CRITMONITOR_MAXTIME_PREEMPTION >= 0
/* Did this task disable pre-emption? */

if (tcb->lockcount > 0)
if (nxsched_islocked_tcb(tcb))
{
/* Yes.. Save the start time */

Expand Down Expand Up @@ -345,7 +345,7 @@ void nxsched_suspend_critmon(FAR struct tcb_s *tcb)
#if CONFIG_SCHED_CRITMONITOR_MAXTIME_PREEMPTION >= 0
/* Did this task disable preemption? */

if (tcb->lockcount > 0)
if (nxsched_islocked_tcb(tcb))
{
/* Possibly re-enabling.. Check for the max elapsed time */

Expand Down
2 changes: 1 addition & 1 deletion sched/sched/sched_mergepending.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ bool nxsched_merge_pending(void)
* Do nothing if pre-emption is still disabled
*/

if (rtcb->lockcount == 0)
if (!nxsched_islocked_tcb(rtcb))
{
for (ptcb = (FAR struct tcb_s *)list_pendingtasks()->head;
ptcb;
Expand Down
2 changes: 1 addition & 1 deletion sched/sched/sched_setpriority.c
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ static inline void nxsched_running_setpriority(FAR struct tcb_s *tcb,
{
FAR struct tcb_s *rtcb = this_task();

if (rtcb->lockcount > 0)
if (nxsched_islocked_tcb(rtcb))
{
/* Move all tasks with the higher priority from the ready-to-run
* list to the pending list.
Expand Down

0 comments on commit 401e8eb

Please sign in to comment.