sched_critmon: add thread run time to critmonitor

Change-Id: Ib44e45f0f9a1b249b4067db324c9dbdf0cf3f288
Signed-off-by: ligd <liguiding1@xiaomi.com>
This commit is contained in:
ligd
2021-05-07 17:55:24 +08:00
committed by Xiang Xiao
parent dbdb24e2e0
commit 2d32a52353
3 changed files with 57 additions and 11 deletions
+20 -9
View File
@@ -208,10 +208,14 @@ void nxsched_critmon_csection(FAR struct tcb_s *tcb, bool state)
void nxsched_resume_critmon(FAR struct tcb_s *tcb)
{
uint32_t elapsed;
uint32_t current = up_critmon_gettime();
int cpu = this_cpu();
uint32_t elapsed;
DEBUGASSERT(tcb->premp_start == 0 && tcb->crit_start == 0);
DEBUGASSERT(tcb->premp_start == 0 && tcb->crit_start == 0 &&
tcb->run_start == 0);
tcb->run_start = current;
/* Did this task disable pre-emption? */
@@ -219,7 +223,7 @@ void nxsched_resume_critmon(FAR struct tcb_s *tcb)
{
/* Yes.. Save the start time */
tcb->premp_start = up_critmon_gettime();
tcb->premp_start = current;
DEBUGASSERT(tcb->premp_start != 0);
/* Zero means that the timer is not ready */
@@ -233,7 +237,7 @@ void nxsched_resume_critmon(FAR struct tcb_s *tcb)
{
/* Check for the global max elapsed time */
elapsed = up_critmon_gettime() - g_premp_start[cpu];
elapsed = current - g_premp_start[cpu];
g_premp_start[cpu] = 0;
if (elapsed > g_premp_max[cpu])
@@ -248,7 +252,7 @@ void nxsched_resume_critmon(FAR struct tcb_s *tcb)
{
/* Yes.. Save the start time */
tcb->crit_start = up_critmon_gettime();
tcb->crit_start = current;
DEBUGASSERT(tcb->crit_start != 0);
if (g_crit_start[cpu] == 0)
@@ -260,7 +264,7 @@ void nxsched_resume_critmon(FAR struct tcb_s *tcb)
{
/* Check for the global max elapsed time */
elapsed = up_critmon_gettime() - g_crit_start[cpu];
elapsed = current - g_crit_start[cpu];
g_crit_start[cpu] = 0;
if (elapsed > g_crit_max[cpu])
@@ -285,7 +289,14 @@ void nxsched_resume_critmon(FAR struct tcb_s *tcb)
void nxsched_suspend_critmon(FAR struct tcb_s *tcb)
{
uint32_t elapsed;
uint32_t current = up_critmon_gettime();
uint32_t elapsed = current - tcb->run_start;
tcb->run_start = 0;
if (elapsed > tcb->run_max)
{
tcb->run_max = elapsed;
}
/* Did this task disable preemption? */
@@ -293,7 +304,7 @@ void nxsched_suspend_critmon(FAR struct tcb_s *tcb)
{
/* Possibly re-enabling.. Check for the max elapsed time */
elapsed = up_critmon_gettime() - tcb->premp_start;
elapsed = current - tcb->premp_start;
tcb->premp_start = 0;
if (elapsed > tcb->premp_max)
@@ -308,7 +319,7 @@ void nxsched_suspend_critmon(FAR struct tcb_s *tcb)
{
/* Possibly leaving .. Check for the max elapsed time */
elapsed = up_critmon_gettime() - tcb->crit_start;
elapsed = current - tcb->crit_start;
tcb->crit_start = 0;
if (elapsed > tcb->crit_max)