Exemplo n.º 1
0
 def initialize_tasks(self, tasks):
     i = 0
     for task in tasks:
         current_task = Task()
         current_task.initialize(i, task, Memory(50), Internal_State(),
                                 IO())
         self.tasks.append(current_task)
         i += 1
Exemplo n.º 2
0
 def initialize(self, base_instructions):
     self.memory = Memory(20)
     self.error = Error()
     self.internal_state = Internal_State()
     self.io = IO()
     self.base_instructions = base_instructions
     self.max_mem_pages = 2
     self.remaining_mem_pages = 2
     self.new_memory = [0] * self.max_mem_pages
     print(self.new_memory)
Exemplo n.º 3
0
    def handle_create(self, cpu, clock):
        base_task_id = cpu.memory.info[cpu.internal_state.PC + 1]
        print(f"\n--- CREATING TASK FOR BASE PROGR {base_task_id} ---")

        try:
            new_task = Task()
            new_task.initialize(len(self.tasks), self.base_tasks[base_task_id],
                                Memory(50), Internal_State(), IO())
            new_task.task_state = "READY"

            for i in range(len(new_task.progr)):
                new_task.memory.write(i, new_task.progr[i], cpu.error)

            self.tasks.append(new_task)
            cpu.internal_state.PC = cpu.internal_state.PC + 1 + 1
        except:
            cpu.error.update(5)
            cpu.internal_state.mode = "PARADA"
            cpu.internal_state.mode_info = "RECEIVED PROGRAM " + \
                    str(base_task_id)
Exemplo n.º 4
0
 def initialize(self, progr):
     self.cpu = CPU()
     self.clock = Clock()
     self.progr = progr
     self.cpu.initialize(Memory(20), Error(), Internal_State(), IO())
Exemplo n.º 5
0
 def initialize(self, base_instructions):
     self.memory = Memory(20)
     self.error = Error()
     self.internal_state = Internal_State()
     self.io = IO()
     self.base_instructions = base_instructions
Exemplo n.º 6
0
 def initialize_tasks(self, progr):
     current_task = Task()
     current_task.initialize(0, progr, Memory(50), Internal_State(), IO())
     self.tasks.append(current_task)
     self.tasks[self.current_task_id].task_state = "RUNNING"