Beispiel #1
0
 def __init__(self, disco):
     self._disco = disco
     self._memory = Memory(32)
     self._pcbTable = PCBTable()
     self._intManager = IntManager()
     self._memoryManager = MemoryManagerContinuousAssignmentBestFit(self._memory, self._pcbTable, self._intManager, 1)
     self._mmu = Mmu(self._memory)
     self._loader = LoaderBlocks(self._memory, self._mmu, disco, self._memoryManager)
     self._scheduler = SchedulerSJFPreemptive()
     self._timer = None
     self._cpu = Cpu(self._mmu, self._intManager)
     self._dispatcher = Dispatcher(self._mmu, self._cpu)
     self._deviceManager = DeviceManager(self._intManager)
     self._intManager.setInterruptions(self._loader, self._dispatcher, self._scheduler, self._pcbTable, self._deviceManager, self._memoryManager, self._timer)
     self._newPrograms = NewPrograms(self._intManager)
     self._clock = Clock(self._cpu, self._deviceManager, self._timer, self._newPrograms)
Beispiel #2
0
 def __init__(self, disco):
     self._disco            = disco
     self._pcbTable         = PCBTable()
     self._schedulerFactory = SchedulersFactory(self._pcbTable)
     self._scheduler        = self._schedulerFactory.getScheduler()
     self._intManager       = IntManager()
     self._memoryFactory    = MemoryFactory(self._pcbTable, self._intManager, disco)
     self._memory           = self._memoryFactory.getMemory()
     self._memoryManager    = self._memoryFactory.getMemoryManager()
     self._mmu              = self._memoryFactory.getMmu()
     self._loader           = self._memoryFactory.getLoader()
     self._timer            = self._schedulerFactory.getTimer(self._intManager)
     self._cpu              = Cpu(self._mmu, self._intManager)
     self._dispatcher       = Dispatcher(self._mmu, self._cpu)
     self._deviceManager    = DeviceManager(self._intManager)
     self._intManager.setInterruptions(self._loader, self._dispatcher, self._scheduler, self._pcbTable, self._deviceManager, self._memoryManager, self._timer)
     self._newPrograms      = NewPrograms(self._intManager)
     self._clock            = Clock(self._cpu, self._deviceManager, self._timer, self._newPrograms)
Beispiel #3
0
 def __init__(self, disco):
     self._disco = disco
     self._memory = Memory(8)
     self._pcbTable = PCBTable()
     self._intManager = IntManager()
     sizeFrame = 4
     pageReplacementAlgorithm = SecondChancePageReplacementAlgorithm()
     self._swap = Swap(sizeFrame)
     self._memoryManager = MemoryManagerPaging(self._memory, sizeFrame, self._pcbTable, self._swap, pageReplacementAlgorithm)
     self._mmu = MmuPages(self._memory, sizeFrame, self._intManager)
     self._loader = LoaderPages(self._memory, self._mmu, self._disco, self._memoryManager, self._swap)
     self._memoryManager.setLoader(self._loader)  # Es para no hacer la interrupcion swapIN (el memoryManager y el loader se conocen mutuamente)
     self._scheduler = SchedulerPriorityPreemptive(self._pcbTable, 80)
     self._timer = None
     self._cpu = Cpu(self._mmu, self._intManager)
     self._dispatcher = Dispatcher(self._mmu, self._cpu)
     self._deviceManager = DeviceManager(self._intManager)
     self._intManager.setInterruptions(self._loader, self._dispatcher, self._scheduler, self._pcbTable, self._deviceManager, self._memoryManager, self._timer)
     self._newPrograms = NewPrograms(self._intManager)
     self._clock = Clock(self._cpu, self._deviceManager, self._timer, self._newPrograms)
 def setUp(self):
     self._io1 = IO_1(1)
     self._io2 = IO_2(1)
     self._io3 = IO_3(1)
     self._deviceManager = DeviceManager(mock.Mock())
class tester(unittest.TestCase):
    def setUp(self):
        self._io1 = IO_1(1)
        self._io2 = IO_2(1)
        self._io3 = IO_3(1)
        self._deviceManager = DeviceManager(mock.Mock())

    def sizeWaiting(self):
        totalSizeWaiting = 0
        for ioId, queue in self._deviceManager.getWaiting().items():
            totalSizeWaiting += queue.lenItems()
        return totalSizeWaiting

    #en ves de pedir sizewaitin pedir el waintin y aca utilizar el
    def test000ElDeviceManagerHandleaUnIO_1EnUnTick(self):

        self._deviceManager.add(0, self._io1.getId())  # pid = 0
        self._deviceManager.tick(
        )  # este tick no cuenta porque pertenece al tick que fue agregado el pid al deviceManager
        self.assertEqual(1, self.sizeWaiting())
        self._deviceManager.tick()
        self.assertEqual(0, self.sizeWaiting())

    def test001ElDeviceManagerHandleaUnIO_2EnDosTicks(self):

        self._deviceManager.tick()
        self._deviceManager.add(0, self._io2.getId())  # pid = 0
        self._deviceManager.tick(
        )  # este tick no cuenta porque pertenece al tick que fue agregado el pid al deviceManager
        self._deviceManager.tick()
        self.assertEqual(1, self.sizeWaiting())
        self._deviceManager.tick()
        self.assertEqual(0, self.sizeWaiting())

    def test002ElDeviceManagerHandleaUnIO_3EnTresTicks(self):

        self._deviceManager.tick()
        self._deviceManager.tick()
        self._deviceManager.add(0, self._io3.getId())  # pid = 0
        self._deviceManager.tick(
        )  # este tick no cuenta porque pertenece al tick que fue agregado el pid al deviceManager
        self._deviceManager.tick()
        self._deviceManager.tick()
        self.assertEqual(1, self.sizeWaiting())
        self._deviceManager.tick()
        self.assertEqual(0, self.sizeWaiting())

    def test003ElDeviceManagerHandleaUnIo_1IO_2yIO_3EnElMismoTick(self):

        self._deviceManager.tick()
        self._deviceManager.tick()
        self._deviceManager.add(0, self._io3.getId())  # pid = 0
        self._deviceManager.tick(
        )  # este tick no cuenta para el pid 0 porque pertenece al tick que fue agregado al deviceManager
        self._deviceManager.add(1, self._io2.getId())  # pid = 1
        self._deviceManager.tick(
        )  # este tick no cuenta para el pid 1 porque pertenece al tick que fue agregado al deviceManager
        self._deviceManager.add(2, self._io1.getId())  # pid = 2
        self._deviceManager.tick(
        )  # este tick no cuenta para el pid 2 porque pertenece al tick que fue agregado al deviceManager
        self.assertEqual(3, self.sizeWaiting())
        self._deviceManager.tick()
        self.assertEqual(0, self.sizeWaiting())