Skip to content

Commit

Permalink
sched_unlock: remove redundant/stale logic and comment
Browse files Browse the repository at this point in the history
  • Loading branch information
yamt authored and xiaoxiang781216 committed Nov 20, 2024
1 parent fb92b60 commit b4d8ac8
Showing 1 changed file with 1 addition and 29 deletions.
30 changes: 1 addition & 29 deletions sched/sched/sched_unlock.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,38 +98,14 @@ int sched_unlock(void)
sched_note_premption(rtcb, false);
#endif

/* Set the lock count to zero */

rtcb->lockcount = 0;

/* Release any ready-to-run tasks that have collected in
* g_pendingtasks.
*
* NOTE: This operation has a very high likelihood of causing
* this task to be switched out!
*/

/* In the SMP case, the tasks remains pend(1) if we are
* in a critical section, i.e., g_cpu_irqlock is locked by other
* CPUs, or (2) other CPUs still have pre-emption disabled, i.e.,
* g_cpu_lockset is locked. In those cases, the release of the
* pending tasks must be deferred until those conditions are met.
*
* There are certain conditions that we must avoid by preventing
* releasing the pending tasks while within the critical section
* of other CPUs. This logic does that and there is matching
* logic in nxsched_add_readytorun to avoid starting new tasks
* within the critical section (unless the CPU is the holder of
* the lock).
*
* REVISIT: If this CPU is only one that holds the IRQ lock, then
* we should go ahead and release the pending tasks. See the logic
* leave_critical_section(): It will call nxsched_merge_pending()
* BEFORE it clears IRQ lock.
*/

if (!nxsched_islocked_tcb(rtcb) &&
list_pendingtasks()->head != NULL)
if (list_pendingtasks()->head != NULL)
{
if (nxsched_merge_pending())
{
Expand Down Expand Up @@ -247,10 +223,6 @@ int sched_unlock(void)
sched_note_premption(rtcb, false);
#endif

/* Set the lock count to zero */

rtcb->lockcount = 0;

/* Release any ready-to-run tasks that have collected in
* g_pendingtasks.
*
Expand Down

0 comments on commit b4d8ac8

Please sign in to comment.