This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new 401e8eb062 sched/lockcount: replace all lockcount check to
nxsched_islocked_tcb()
401e8eb062 is described below
commit 401e8eb0625e5e87881707f3e43afa812c63f384
Author: chao an <[email protected]>
AuthorDate: Tue Nov 26 08:58:02 2024 +0800
sched/lockcount: replace all lockcount check to nxsched_islocked_tcb()
replace all lockcount check to nxsched_islocked_tcb()
Signed-off-by: chao an <[email protected]>
---
sched/sched/sched_addreadytorun.c | 5 +++--
sched/sched/sched_critmonitor.c | 4 ++--
sched/sched/sched_mergepending.c | 2 +-
sched/sched/sched_setpriority.c | 2 +-
4 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/sched/sched/sched_addreadytorun.c
b/sched/sched/sched_addreadytorun.c
index da01dec08d..3e9fe5676e 100644
--- a/sched/sched/sched_addreadytorun.c
+++ b/sched/sched/sched_addreadytorun.c
@@ -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.
@@ -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;
diff --git a/sched/sched/sched_critmonitor.c b/sched/sched/sched_critmonitor.c
index bf547b52cf..9d8dc7d037 100644
--- a/sched/sched/sched_critmonitor.c
+++ b/sched/sched/sched_critmonitor.c
@@ -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 */
@@ -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 */
diff --git a/sched/sched/sched_mergepending.c b/sched/sched/sched_mergepending.c
index a577932957..a3064400e3 100644
--- a/sched/sched/sched_mergepending.c
+++ b/sched/sched/sched_mergepending.c
@@ -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;
diff --git a/sched/sched/sched_setpriority.c b/sched/sched/sched_setpriority.c
index 7dc2b166e2..112e1dbb59 100644
--- a/sched/sched/sched_setpriority.c
+++ b/sched/sched/sched_setpriority.c
@@ -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.