当前位置: 首页>>代码示例>>Python>>正文


Python Memory.deallocate方法代码示例

本文整理汇总了Python中memory.Memory.deallocate方法的典型用法代码示例。如果您正苦于以下问题:Python Memory.deallocate方法的具体用法?Python Memory.deallocate怎么用?Python Memory.deallocate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在memory.Memory的用法示例。


在下文中一共展示了Memory.deallocate方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: CPU

# 需要导入模块: from memory import Memory [as 别名]
# 或者: from memory.Memory import deallocate [as 别名]

#.........这里部分代码省略.........
        process.setInCPUTime(simulator.time)
        if self.queueType == "RR" :
            simulator.schedule(simulator.time + burst_time, self.eCPUBurst, process, simulator) 
            if burst_time > self.t_slice:
                simulator.schedule(simulator.time + self.t_slice, self.eRRPreempt, process, simulator) 
        else:
            simulator.schedule(simulator.time + burst_time, self.eCPUBurst, process, simulator) 

        self.contentSwitchSum += 1

    def eCPUBurst(self, process, simulator):
        self.burstTimeSum += process.setOutCPUTime(simulator.time)
	process.currentAgingSeq = random.getrandbits(128)

        process.num_burst -= 1 
        if process.num_burst > 0:
            #time 181ms: P1 completed its CPU burst
            print "time %dms:" % simulator.time,"Process '%c'"%process.letter, "completed its CPU burst [Q",
            sys.stdout.write('')
            self.printQueue()
            print "]"
            #time 181ms: P1 performing I/O
            print "time %dms:"% simulator.time,"Process '%c'"%process.letter, "performing I/O [Q",
            sys.stdout.write('')
            self.printQueue()
            print "]"
            simulator.schedule(simulator.time + process.io_time, self.eIOBurst, process, simulator) 
        else:
            print "time %dms:"% simulator.time,"Process '%c'"%process.letter, "terminated [Q",
            sys.stdout.write('')
            self.printQueue()
            print "]"

            self.mem.deallocate( process.letter )
            print "time %dms:"% simulator.time, "Simulated Memory:"
            self.mem.printmem()

            self.turnaroundTimeSum += simulator.time
            self.active_n -= 1
            if(self.active_n == 0):
                print "time %dms: Simulator for %s ended [Q]" %( simulator.time, self.queueType)
        self.processInCPU = None #Note: process in cpu is in use of CPU, NOT in content switch
        if(not self.process_queue.isEmpty()):
            next_burst_time, next_process = self.process_queue.nextProcess() 
            tmp =next_process.setOutQueueTime(simulator.time)
	    self.waitTimeSum += tmp 
	    self.waitTimeNum += 1 

            simulator.schedule(simulator.time + self.t_cs, self.eContentSwitch, next_process, next_burst_time, simulator) 
            self.CPUIdle = False
        else: #empty process queue
            self.CPUIdle = True
 
    def eIOBurst(self, process, simulator):
        if process.num_burst == 0:
            return

        process.resetRemainBurstTime()

        if self.processInCPU and self.queueType=="SRT" and self.processInCPU.remain_burst_time - (simulator.time - self.processInCPU.lastTimeInCPU) > process.burst_time : 
	# Preempted by SRT
            self.SRTPreempt(process, simulator)
	elif self.processInCPU and self.queueType=="PWA" and self.processInCPU.priority > process.priority:
	# Preempted by PWA
	    process.currentAgingSeq = random.getrandbits(128)
	    self.processInCPU.currentAgingSeq = random.getrandbits(128)
开发者ID:xil12008,项目名称:operatingsystemproject,代码行数:70,代码来源:CPU.py

示例2: printStatusMessage

# 需要导入模块: from memory import Memory [as 别名]
# 或者: from memory.Memory import deallocate [as 别名]
                        #The process is done, kick it over to the IO queue.
                        if (cpu.currentProcess.timeremaining <= 0):
                        
                            cpu.currentProcess.bursts -= 1
                            cpu.currentProcess.executedBursts += 1

                            #Only report burst completions if the process isn't about to terminate.
                            if (cpu.currentProcess.bursts):
                                printStatusMessage("Process '"+str(cpu.currentProcess.id)+"' completed its CPU burst", cpu.processQueue)
                                iosys.startedIO(process)

                            #Process is done.
                            else:
                                cpu.currentProcess.status = "terminated"
                                mem.deallocate(cpu.currentProcess.id)
                                printStatusMessage("Process '"+str(cpu.currentProcess.id)+"' terminated", cpu.processQueue)
                                printStatusMessage("Process '{0}' exits the system (deallocated {1} memory units)".format(cpu.currentProcess.id, cpu.currentProcess.memsize))
                                printStatusMessage("Simulated Memory:\n{0}".format(mem))
                                terminatedProcesses += 1

                            cpu.currentProcess = None
                            cpu.contextTime = 0


                        #For round robin detect when time slice expires.
                        elif (cpu.algorithm == "rr" and cpu.processTime >= cpu.sliceTime):
                            #PREMPTION TIME SLICE EXPIRED!
                            assert(cpu.processTime)

                            #Outputting for the srt preemption is different from the round robin queue output. (First process is included.
开发者ID:not-inept,项目名称:opsys-p3-cpu-sim,代码行数:32,代码来源:BananaComquatPeachApplePinenut.py


注:本文中的memory.Memory.deallocate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。