def _get_allocated_size(cpu: Cpu, workload_map: dict, w_type: str) -> int: allocation_size = 0 for t in cpu.get_threads(): if _is_thread_occupied(t, workload_map, w_type): allocation_size += 1 return allocation_size
def get_oversubscribed_thread_count(cpu: Cpu, workload_map: dict) -> int: oversubscribed_thread_count = 0 for t in cpu.get_threads(): if _is_thread_occupied(t, workload_map, BURST) and _is_thread_occupied( t, workload_map, STATIC): oversubscribed_thread_count += 1 return oversubscribed_thread_count
def get_workloads(cpu: Cpu): workloads = {} for t in cpu.get_threads(): for w_id in t.get_workload_ids(): if w_id in workloads: workloads[w_id].append(t.get_id()) else: workloads[w_id] = [t.get_id()] return workloads
def _occupies_entire_cpu(workload: Workload, cpu: Cpu): return len(cpu.get_threads()) == workload.get_thread_count()
def get_free_threads(self, cpu: Cpu, workload_map: Dict[str, Workload], cpu_usage: Dict[str, float] = None) -> List[Thread]: return [t for t in cpu.get_threads() if len(t.get_workload_ids()) == 0]
def get_allocated_size(cpu: Cpu) -> int: return len([t for t in cpu.get_threads() if t.is_claimed()])