/* Populates the per-CPU COLLECTD_CPU_STATE_ACTIVE rate and the global rate_by_state * array. */ static void aggregate (gauge_t *sum_by_state) /* {{{ */ { size_t cpu_num; size_t state; for (state = 0; state < COLLECTD_CPU_STATE_MAX; state++) sum_by_state[state] = NAN; for (cpu_num = 0; cpu_num < global_cpu_num; cpu_num++) { cpu_state_t *this_cpu_states = get_cpu_state (cpu_num, 0); this_cpu_states[COLLECTD_CPU_STATE_ACTIVE].rate = NAN; for (state = 0; state < COLLECTD_CPU_STATE_ACTIVE; state++) { if (!this_cpu_states[state].has_value) continue; RATE_ADD (sum_by_state[state], this_cpu_states[state].rate); if (state != COLLECTD_CPU_STATE_IDLE) RATE_ADD (this_cpu_states[COLLECTD_CPU_STATE_ACTIVE].rate, this_cpu_states[state].rate); } if (!isnan (this_cpu_states[COLLECTD_CPU_STATE_ACTIVE].rate)) this_cpu_states[COLLECTD_CPU_STATE_ACTIVE].has_value = 1; RATE_ADD (sum_by_state[COLLECTD_CPU_STATE_ACTIVE], this_cpu_states[COLLECTD_CPU_STATE_ACTIVE].rate); } } /* }}} void aggregate */
/* Check the task list for the cpu and check for schedule feasibility */ struct rt_info* create_feasible_schedule(int cpu_id) { struct rt_info *it, *best_dead, *head, *best_ivd, *last_ivd; struct cpu_info *cur_cpu = NULL; struct timespec exec_ts; int removed; cur_cpu = get_cpu_state(cpu_id); head = cur_cpu->head; best_dead = head; if(!head) goto out; best_ivd = head; it = task_list_entry(head->task_list[LIST_CPUTSK].next, LIST_CPUTSK); do { if(insert_on_list(it, best_ivd, LIST_CPUIVD, SORT_KEY_GVD, 0)) best_ivd = it; it = task_list_entry(it->task_list[LIST_CPUTSK].next, LIST_CPUTSK); } while(it != head); last_ivd = task_list_entry(best_ivd->task_list[LIST_CPUIVD].prev, LIST_CPUIVD); do { removed = 0; it = best_dead; exec_ts = current_kernel_time(); do { add_ts(&exec_ts, &(it->left), &exec_ts); if(earlier_deadline(&(it->deadline), &exec_ts)) { list_remove(last_ivd, LIST_CPUTSK); if(last_ivd == best_dead) { best_dead = task_list_entry(last_ivd->task_list[LIST_CPUTSK].next, LIST_CPUTSK); } last_ivd = task_list_entry(last_ivd->task_list[LIST_CPUIVD].prev, LIST_CPUIVD); removed = 1; } it = task_list_entry(it->task_list[LIST_CPUTSK].next, LIST_CPUTSK); } while(removed == 0 && it != best_dead); } while(last_ivd != best_ivd && removed == 1); out: cur_cpu->best_dead = best_dead; return best_dead; }