def timeOut(command_line: [str]) -> None: if len(command_line) != 1: output_string = "Incorrect number of arguments with to command" else: PCB.processTimeOut()
def test(): PCB.createInitProcess() print(PCB.current_process.ID) PCB.createNewProcess("x", 2) print(PCB.current_process.ID) PCB.createNewProcess("y", 1) print(PCB.current_process.ID) PCB.processTimeOut() print(PCB.current_process.ID) PCB.createNewProcess("z", 2) print(PCB.current_process.ID) PCB.processTimeOut() print(PCB.current_process.ID) PCB.requestResource("R1", 1) print(PCB.current_process.ID) PCB.processTimeOut() print(PCB.current_process.ID) PCB.requestResource("R1", 1) print(PCB.current_process.ID) PCB.deleteProcess("z") print(PCB.current_process.ID) PCB.releaseResource("R1", 1) print(PCB.current_process.ID) PCB.deleteProcess("x") print(PCB.current_process.ID)
def deleteProcess(command_line: [str]) -> None: if len(command_line) != 2: output_string = "Incorrect number of arguments with de command" else: output_string = PCB.deleteProcess(command_line[1])
def resourceRelease(command_line: [str]) -> None: if len(command_line) != 3: output_string = "Incorrect number of arguments with rel command" else: output_string = PCB.releaseResource(command_line[1], int(command_line[2]))
def processCreation(command_line: [str]) -> None: if len(command_line) != 3: output_string = "Incorrect number of arguments with cr command" else: #Handle check of inputs to ensure they can be typecasted to proper type output_string = PCB.createNewProcess(command_line[1], int(command_line[2]))
def handleInit(command_line: [str]) -> None: if len(command_line) > 1: output_string = "To many arguments with init command" else: output_string = PCB.createNewProcess("Init", 0)
PCB.createNewProcess("z", 2) print(PCB.current_process.ID) PCB.processTimeOut() print(PCB.current_process.ID) PCB.requestResource("R1", 1) print(PCB.current_process.ID) PCB.processTimeOut() print(PCB.current_process.ID) PCB.requestResource("R1", 1) print(PCB.current_process.ID) PCB.deleteProcess("z") print(PCB.current_process.ID) PCB.releaseResource("R1", 1) print(PCB.current_process.ID) PCB.deleteProcess("x") print(PCB.current_process.ID) if __name__ == '__main__': #test() PCB.createInitProcess() readFile()