kernel: Update cpu_ent::active_time atomically

This commit is contained in:
Pawel Dziepak 2013-10-23 21:56:14 +02:00
parent 453bf75027
commit d6efe8ee75
3 changed files with 4 additions and 9 deletions

View File

@ -74,12 +74,7 @@ cpu_get_active_time(int32 cpu)
if (cpu < 0 || cpu > smp_get_num_cpus())
return 0;
// We need to grab the scheduler lock here, because the thread activity
// time is not maintained atomically (because there is no need to).
InterruptsSpinLocker schedulerLocker(gSchedulerLock);
return gCPU[cpu].active_time;
return atomic_get64(&gCPU[cpu].active_time);
}

View File

@ -1213,7 +1213,7 @@ affine_track_cpu_activity(Thread* oldThread, Thread* nextThread, int32 thisCore)
= (oldThread->kernel_time - oldThread->cpu->last_kernel_time)
+ (oldThread->user_time - oldThread->cpu->last_user_time);
oldThread->cpu->active_time += active;
atomic_add64(&oldThread->cpu->active_time, active);
sCoreEntries[thisCore].fActiveTime += active;
}

View File

@ -634,9 +634,9 @@ simple_reschedule(void)
// track CPU activity
if (!thread_is_idle_thread(oldThread)) {
oldThread->cpu->active_time +=
atomic_add64(&oldThread->cpu->active_time,
(oldThread->kernel_time - oldThread->cpu->last_kernel_time)
+ (oldThread->user_time - oldThread->cpu->last_user_time);
+ (oldThread->user_time - oldThread->cpu->last_user_time));
}
if (!thread_is_idle_thread(nextThread)) {