mirror of
https://github.com/apache/nuttx.git
synced 2026-06-06 08:36:24 +08:00
Performance improvement: Idle loop should not take MM semaphore if there is not garbage to be collected. This can cause loss of performance and thrashing in tasking
This commit is contained in:
@@ -97,6 +97,7 @@ int os_idletask(int argc, FAR char *argv[])
|
||||
/* Enter the IDLE loop */
|
||||
|
||||
sdbg("CPU%d: Beginning Idle Loop\n", this_cpu());
|
||||
|
||||
for (; ; )
|
||||
{
|
||||
/* Perform garbage collection (if it is not being done by the worker
|
||||
@@ -118,9 +119,9 @@ int os_idletask(int argc, FAR char *argv[])
|
||||
* queue so that is done in a safer context.
|
||||
*/
|
||||
|
||||
if (kmm_trysemaphore() == 0)
|
||||
if (sched_have_garbage() && kmm_trysemaphore() == 0)
|
||||
{
|
||||
sched_garbagecollection();
|
||||
sched_garbage_collection();
|
||||
kmm_givesemaphore();
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -415,11 +415,13 @@ void os_start(void)
|
||||
#endif
|
||||
{
|
||||
FAR dq_queue_t *tasklist;
|
||||
int hashndx;
|
||||
|
||||
/* Assign the process ID(s) of ZERO to the idle task(s) */
|
||||
|
||||
g_pidhash[PIDHASH(g_lastpid)].tcb = &g_idletcb[cpu].cmn;
|
||||
g_pidhash[PIDHASH(g_lastpid)].pid = g_lastpid;
|
||||
hashndx = PIDHASH(g_lastpid);
|
||||
g_pidhash[hashndx].tcb = &g_idletcb[cpu].cmn;
|
||||
g_pidhash[hashndx].pid = g_lastpid;
|
||||
|
||||
/* Initialize a TCB for this thread of execution. NOTE: The default
|
||||
* value for most components of the g_idletcb are zero. The entire
|
||||
@@ -783,9 +785,9 @@ void os_start(void)
|
||||
* queue so that is done in a safer context.
|
||||
*/
|
||||
|
||||
if (kmm_trysemaphore() == 0)
|
||||
if (sched_have_garbage() && kmm_trysemaphore() == 0)
|
||||
{
|
||||
sched_garbagecollection();
|
||||
sched_garbage_collection();
|
||||
kmm_givesemaphore();
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user