vfs:add nxsched_foreach to sched_lock avoid crash

If scheduling occurs in file_fsync,
fl_lock may be released, and an error may
occur when calling nxmutex_unlock

Signed-off-by: anjiahao <anjiahao@xiaomi.com>
This commit is contained in:
anjiahao 2023-08-15 15:00:15 +08:00 committed by Xiang Xiao
parent fa63ef69c9
commit 48c153db25

View File

@ -63,6 +63,7 @@ void nxsched_foreach(nxsched_foreach_t handler, FAR void *arg)
/* Visit each active task */
flags = enter_critical_section();
sched_lock();
for (ndx = 0; ndx < g_npidhash; ndx++)
{
/* This test and the function call must be atomic */
@ -73,5 +74,6 @@ void nxsched_foreach(nxsched_foreach_t handler, FAR void *arg)
}
}
sched_unlock();
leave_critical_section(flags);
}