simulate.py (4945:6f40bdb0ba9f) | simulate.py (4946:fa62733fca2d) |
---|---|
1# Copyright (c) 2005 The Regents of The University of Michigan 2# All rights reserved. 3# 4# Redistribution and use in source and binary forms, with or without 5# modification, are permitted provided that the following conditions are 6# met: redistributions of source code must retain the above copyright 7# notice, this list of conditions and the following disclaimer; 8# redistributions in binary form must reproduce the above copyright --- 153 unchanged lines hidden (view full) --- 162 doDrain(system) 163 print "Changing memory mode to timing" 164 system.changeTiming(objects.params.timing) 165 166def switchCpus(cpuList): 167 print "switching cpus" 168 if not isinstance(cpuList, list): 169 raise RuntimeError, "Must pass a list to this function" | 1# Copyright (c) 2005 The Regents of The University of Michigan 2# All rights reserved. 3# 4# Redistribution and use in source and binary forms, with or without 5# modification, are permitted provided that the following conditions are 6# met: redistributions of source code must retain the above copyright 7# notice, this list of conditions and the following disclaimer; 8# redistributions in binary form must reproduce the above copyright --- 153 unchanged lines hidden (view full) --- 162 doDrain(system) 163 print "Changing memory mode to timing" 164 system.changeTiming(objects.params.timing) 165 166def switchCpus(cpuList): 167 print "switching cpus" 168 if not isinstance(cpuList, list): 169 raise RuntimeError, "Must pass a list to this function" |
170 for i in cpuList: 171 if not isinstance(i, tuple): | 170 for item in cpuList: 171 if not isinstance(item, tuple) or len(item) != 2: |
172 raise RuntimeError, "List must have tuples of (oldCPU,newCPU)" 173 | 172 raise RuntimeError, "List must have tuples of (oldCPU,newCPU)" 173 |
174 [old_cpus, new_cpus] = zip(*cpuList) | 174 for old_cpu, new_cpu in cpuList: 175 if not isinstance(old_cpu, objects.BaseCPU): 176 raise TypeError, "%s is not of type BaseCPU" % old_cpu 177 if not isinstance(new_cpu, objects.BaseCPU): 178 raise TypeError, "%s is not of type BaseCPU" % new_cpu |
175 | 179 |
176 for cpu in old_cpus: 177 if not isinstance(cpu, objects.BaseCPU): 178 raise TypeError, "%s is not of type BaseCPU" % cpu 179 for cpu in new_cpus: 180 if not isinstance(cpu, objects.BaseCPU): 181 raise TypeError, "%s is not of type BaseCPU" % cpu 182 183 # Drain all of the individual CPUs 184 drain_event = internal.event.createCountedDrain() 185 unready_cpus = 0 186 for old_cpu in old_cpus: 187 unready_cpus += old_cpu.startDrain(drain_event, False) 188 # If we've got some objects that can't drain immediately, then simulate 189 if unready_cpus > 0: 190 drain_event.setCount(unready_cpus) 191 simulate() 192 internal.event.cleanupCountedDrain(drain_event) | |
193 # Now all of the CPUs are ready to be switched out | 180 # Now all of the CPUs are ready to be switched out |
194 for old_cpu in old_cpus: | 181 for old_cpu, new_cpu in cpuList: |
195 old_cpu._ccObject.switchOut() | 182 old_cpu._ccObject.switchOut() |
196 index = 0 197 for new_cpu in new_cpus: 198 new_cpu.takeOverFrom(old_cpus[index]) 199 new_cpu._ccObject.resume() 200 index += 1 | 183 184 for old_cpu, new_cpu in cpuList: 185 new_cpu.takeOverFrom(old_cpu) |