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


Python Clock.addSuscribed方法代码示例

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


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

示例1: ClockTest

# 需要导入模块: from clock import Clock [as 别名]
# 或者: from clock.Clock import addSuscribed [as 别名]
class ClockTest(unittest.TestCase):

	def setUp(self):
		self.clock = Clock()

	def test_startUp(self):
		assert (self.clock.isRunning == False)
		self.clock.startUp()
		assert (self.clock.isRunning == True)
		self.clock.shutDown()

	def test_shutdown(self):
		self.clock.startUp()
		assert (self.clock.isRunning == True)
		self.clock.shutDown()
		assert (self.clock.isRunning == False)

	def test_addSuscribed(self):
		aCpu = Mock()
		self.clock.addSuscribed(aCpu)
		assert (self.clock.suscribed == [aCpu])

	def test_notify(self):
		aCpu = Mock()
		other = Mock()
		another = Mock()
		self.clock.suscribed = [aCpu,other,another]
		self.clock.notify()
		verify(aCpu,times(1)).run();
		verify(other,times(1)).run();
		verify(another,times(1)).run();
开发者ID:fernandodm,项目名称:sistemasoperativos,代码行数:33,代码来源:tclock.py

示例2: __init__

# 需要导入模块: from clock import Clock [as 别名]
# 或者: from clock.Clock import addSuscribed [as 别名]
class Kernel:
    def __init__(self, aSize):
        self.disc = Disc()
        self.memory = MainMemory(aSize)
        self.memoryManager = ContinuousAssignment(LogicalMemory(self.memory),self)
        self.handler = InterruptionHandler(self)
        self.cpu = Cpu(self.memoryManager,self.handler)
        self.scheduler = Scheduler(self.cpu)        
        self.clock = Clock()
        self.IO = io.IO(self)
        self.clock.addSuscribed(self.cpu)
        self.clock.addSuscribed(self.IO)
        self.clock.addSuscribed(self.handler)
        #tabla que contiene todos los pcb (k,v) => (pid,pcb)
        self.table = {}

    def getLogicalMemory(self):
        return self.logicalMemory

    def getMemoryManager(self):
        return self.memoryManager

    def getDisc(self):
        return self.disc

    def getCpu(self):
        return self.cpu

    def getMemory(self):
        return self.memory

    def getMemoryManager(self):
        return self.memoryManager

    def getHandler(self):
        return self.handler

    def getIO(self):
        return self.IO

    def getClock(self):
        return self.clock

    def getScheduler(self):
        return self.scheduler

    def getTable(self):
        return self.table

    #Comienza con la ejecucion del clock
    def startUp(self):
        self.getClock().startUp()

    #Corta la ejecucion del clock
    def shutDown(self):
        self.getClock().shutDown()

    def run(self, name):
        print "[Kernel] Ejecutar programa: " + str(name)
        self.handler.newIrq(name)

    #Obtiene todos los programas del disco
    def getProgramasDelDisco(self, name):
        return self.getDisc().getProgram(name)

    #Agrega el pcb en la table
    def addPcb(self,aPcb):
        self.table[aPcb.getPid()] = aPcb
        print "LALALALAAAAA " + str(len(self.table))

    #Borra el pcb en la table
    def removePcb(self,aPcb):
        #guardo las keys para tener una lista
        #y ver si la tabla de pcb esta vacia o no
        keys = self.table.keys()
        if(len(keys) != 0):
            del self.table[aPcb.getPid()]

        print "RERERERERER " + str(len(self.table))
开发者ID:fernandodm,项目名称:sistemasoperativos,代码行数:81,代码来源:kernel.py


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