Changed the way how CPU activity is monitored: instead of taking the active
time of the idle thread as a measure, we now compute the CPU activity on each thread switch - the time the CPU worked is the total of user and kernel time a thread spent during its quantum. Unlike before, this mechanism works correctly on SMP machines. I hope this works as expected :) git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16193 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -23,6 +23,12 @@ typedef union cpu_ent {
|
||||
// thread.c: used to force a reschedule at quantum expiration time
|
||||
int preempted;
|
||||
timer quantum_timer;
|
||||
|
||||
// keeping track of CPU activity
|
||||
bigtime_t active_time;
|
||||
bigtime_t last_kernel_time;
|
||||
bigtime_t last_user_time;
|
||||
|
||||
bool disabled;
|
||||
} info;
|
||||
} cpu_ent __attribute__((aligned(64)));
|
||||
@@ -39,6 +45,7 @@ status_t cpu_preboot_init(struct kernel_args *args);
|
||||
status_t cpu_init(struct kernel_args *args);
|
||||
status_t cpu_init_post_vm(struct kernel_args *args);
|
||||
status_t cpu_init_post_modules(struct kernel_args *args);
|
||||
bigtime_t cpu_get_active_time(int32 cpu);
|
||||
|
||||
cpu_ent *get_cpu_struct(void);
|
||||
extern inline cpu_ent *get_cpu_struct(void) { return &gCPU[smp_get_current_cpu()]; }
|
||||
|
||||
@@ -34,7 +34,6 @@ status_t thread_per_cpu_init(int32 cpuNum);
|
||||
void thread_yield(void);
|
||||
void thread_exit(void);
|
||||
|
||||
bigtime_t thread_get_active_cpu_time(int32 cpuNum);
|
||||
int32 thread_max_threads(void);
|
||||
int32 thread_used_threads(void);
|
||||
|
||||
@@ -47,8 +46,14 @@ static thread_id thread_get_current_thread_id(void);
|
||||
static inline thread_id
|
||||
thread_get_current_thread_id(void)
|
||||
{
|
||||
struct thread *t = thread_get_current_thread();
|
||||
return t ? t->id : 0;
|
||||
struct thread *thread = thread_get_current_thread();
|
||||
return thread ? thread->id : 0;
|
||||
}
|
||||
|
||||
static inline bool
|
||||
thread_is_idle_thread(struct thread *thread)
|
||||
{
|
||||
return thread->entry == NULL;
|
||||
}
|
||||
|
||||
thread_id allocate_thread_id(void);
|
||||
|
||||
Reference in New Issue
Block a user