def load_a_io_instruction_in_a_program(self):
     program = Program("IO")
     manager = Manager(self.scheduler, self.pcb_table, self.memory_manager)
     interruption_handler = InterruptionHandler(manager)
     self.a_kernel.set_interruption_handler(interruption_handler)
     self.cpu.kernel = self.a_kernel
     program.addInstruction(self.instruction_io)
     program.addInstruction(self.instruction_io)
     self.write_program(program,self.memory)
     self.setup_load_of_a_program_in_memory(2, program, 2)
Esempio n. 2
0
 def load_a_io_instruction_in_a_program(self):
     program = Program("IO")
     self.a_kernel.set_scheduler(self.scheduler)
     interruption_manager = InterruptionHandler(self.cpu)
     load_in_interruption_manager = Handle_Loaders()
     load_in_interruption_manager.load_handlers(interruption_manager)
     self.a_kernel.set_interruption_handler(interruption_manager)
     instruction = InstructionIO()
     program.addInstruction(instruction)
     program.addInstruction(instruction)
     self.write_program(program,self.memory)
     self.setup_load_of_a_program_in_memory(2, program, 2)
Esempio n. 3
0
 def load_a_instruction_in_a_program(self):
     program = Program("SIN-IO")
     self.a_kernel.set_scheduler(self.scheduler)
     self.a_kernel.set_pcb_table(self.pcb_table)
     interruption_manager = InterruptionHandler(self.cpu)
     self.a_kernel.set_interruption_handler(interruption_manager)
     load_in_interruption_manager = Handle_Loaders()
     load_in_interruption_manager.load_handlers(interruption_manager)
     instruction = Instruction("Texto")
     program.addInstruction(instruction)
     program.addInstruction(instruction)
     self.write_program(program,self.memory)
     self.setup_load_of_a_program_in_memory(2, program, 1)
class TestPCBInfoHolder(unittest.TestCase):

    def setUp(self):
        self.program = Program("AProgram")
        self.program.addInstruction(Instruction("Hola"))
        self.program.addInstruction(Instruction("Chau"))
        self.page_holder = PageHolder(self.program)
        self.pcb = PCB(0, 2, self.page_holder)
        self.page_creator = PageCreator(1)
        self.page_creator.create(self.pcb,1)

    def test_pcb_ni_idea(self):
        self.assertEqual(2, len(self.pcb.get_pages()))

    def test_i_increment_my_pc_and_ask_if_has_finished(self):
        self.page_holder.increment()
        self.assertTrue(self.page_holder.has_finished())
 def setUp(self):
     self.program = Program("AProgram")
     self.program.addInstruction(Instruction("Hola"))
     self.program.addInstruction(Instruction("Chau"))
     self.page_holder = PageHolder(self.program)
     self.pcb = PCB(0, 2, self.page_holder)
     self.page_creator = PageCreator(1)
     self.page_creator.create(self.pcb,1)
class TestInterruption(unittest.TestCase):
    def setUp(self):
        self.cpu = Cpu(None)
        self.kernel = Kernel(None, self.cpu)
        self.cpu.kernel = self.kernel
        self.pcb_table = self.kernel.pcb_table
        self.memory_manager = self.kernel.memory_manager
        self.fifo = FifoPolicy(self.kernel.scheduler)
        self.program = Program("Pepe")
        self.instruction = Instruction("first instruction")
        self.program.addInstruction(self.instruction)
        self.info_unit = [1, 2, 3, 4]
        self.block_holder = BlockHolder(self.program)
        self.block_holder.set_representation(self.info_unit)
        self.pcb = PCB(1, 4, self.block_holder)
        self.pcb_table.add(self.pcb)
        self.cpu.set_actual_pcb(self.pcb)
        self.manager = Manager(self.kernel.scheduler, self.pcb_table, self.memory_manager)
        self.interruption_handler = InterruptionHandler(self.manager)
        self.kernel.set_interruption_handler(self.interruption_handler)

    def test_when_a_process_is_killed_then_it_is_removed_from_the_pcb_table(self):
        self.cpu.execute_single_instruction(self.program.get_instructions().pop())
        self.assertEquals(self.pcb_table.size(), 0)
 def setUp(self):
     self.cpu = Cpu(None)
     self.kernel = Kernel(None, self.cpu)
     self.cpu.kernel = self.kernel
     self.pcb_table = self.kernel.pcb_table
     self.memory_manager = self.kernel.memory_manager
     self.fifo = FifoPolicy(self.kernel.scheduler)
     self.program = Program("Pepe")
     self.instruction = Instruction("first instruction")
     self.program.addInstruction(self.instruction)
     self.info_unit = [1, 2, 3, 4]
     self.block_holder = BlockHolder(self.program)
     self.block_holder.set_representation(self.info_unit)
     self.pcb = PCB(1, 4, self.block_holder)
     self.pcb_table.add(self.pcb)
     self.cpu.set_actual_pcb(self.pcb)
     self.manager = Manager(self.kernel.scheduler, self.pcb_table, self.memory_manager)
     self.interruption_handler = InterruptionHandler(self.manager)
     self.kernel.set_interruption_handler(self.interruption_handler)