本文整理汇总了Python中Memory.defrag方法的典型用法代码示例。如果您正苦于以下问题:Python Memory.defrag方法的具体用法?Python Memory.defrag怎么用?Python Memory.defrag使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Memory
的用法示例。
在下文中一共展示了Memory.defrag方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: input
# 需要导入模块: import Memory [as 别名]
# 或者: from Memory import defrag [as 别名]
promptTime = input("Enter a time for the simulation to pause: ")
if promptTime < currentTime:
print("Cannot enter a time that has already passed. Try again.")
else:
break
nextEvents = mainSched.getNextEvents(currentTime)
while (currentTime <= promptTime) | (currentTime <= nextEvents[0][0]):
nextEvents = mainSched.getNextEvents(currentTime)
if (currentTime == nextEvents[0][0]):
for event in nextEvents:
if event[2] == 'e':
er = mem.addProc(event)
if er == -1:
mem.defrag(currentTime, procCount)
er2 = mem.addProc(event)
if er2 == -1:
print("Out-Of-Memory Error: Exiting Simulation")
print("Tried to add process: " + event[1])
print("Memory Dump: Time: %i" % (currentTime))
print(mem)
sys.exit(1)
procCount += 1
if event[2] == 'l':
mem.removeProc(event)
procCount -= 1
if (currentTime == nextEvents[0][0]) | (currentTime == promptTime):
print('Memory at time: ' + str(currentTime))
print(mem)