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


Python Memory.printmem方法代码示例

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


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

示例1: CPU

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

#.........这里部分代码省略.........
            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)
            print "time %dms:"% simulator.time,"Process '%c'"% process.letter, "completed I/O [Q",
            sys.stdout.write('')
开发者ID:xil12008,项目名称:operatingsystemproject,代码行数:70,代码来源:CPU.py


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