def main2(): instruction1 = BasicInstruction() instruction2 = BasicInstruction() memory = Memory() memory.buildMemory(5) frame1 = Frame(memory,0,1) frame2 = Frame(memory,1,2) frame3 = Frame(memory,3,1) frame4 = Frame(memory,4,1) mmu = MMU() mmu.fullFrames.append(frame1) mmu.fullFrames.append(frame3) mmu.emptyFrames.append(frame2) mmu.emptyFrames.append(frame4) program = Program('a') program.addInstruction(instruction1) pcbA = PCB('a',0,0,1) programb = Program('b') pcbB = PCB('b',0,3,1) programb.addInstruction(instruction1) frame1.load(pcbA,program) frame3.load(pcbB,programb) memory.printMemory() print(memory.getEmptyCells()) mmu.compact() memory.printMemory()
def main0(): instruction1 = BasicInstruction() instruction2 = IO_Instruction() instruction3 = Priority_Instruction() program = Program('a') program.addInstruction(instruction1) program.addInstruction(instruction1) program.addInstruction(instruction1) programb = Program('b') programb.addInstruction(instruction3) programc = Program('c') programc.addInstruction(instruction1) programc.addInstruction(instruction1) programc.addInstruction(instruction1) timer = Timer(2) memory = Memory() memory.buildMemory(9) frame1 = Frame(memory,0,9) mmu = MMU() mmu.addEmptyFrame(frame1) cpu = CPU(None,mmu,None,timer) scheduler = Scheduler(PFIFO()) ioqueue = IOQueue(scheduler) disk = Disk(None) kernel = Kernel(cpu,ioqueue,scheduler,mmu,disk) disk.setKernel(kernel) cpu.setKernel(kernel) kernel.saveProgram(program) kernel.saveProgram(programb) kernel.saveProgram(programc) kernel.start() cpu.start() ioqueue.start()
def main1(): instruction1 = BasicInstruction() instruction3 = Priority_Instruction() logger = Logger("../resource/log.txt") program = Program('a') program.addInstruction(instruction1) program.addInstruction(instruction1) program.addInstruction(instruction1) program.addInstruction(instruction1) program.addInstruction(instruction1) program.addInstruction(instruction1) programb = Program('b') programb.addInstruction(instruction3) programc = Program('c') programc.addInstruction(instruction1) programc.addInstruction(instruction1) programc.addInstruction(instruction1) timer = Timer(2) memory = Memory() memory.buildMemory(9) frame1 = Frame(memory,0,9) mmu = MMU() mmu.addEmptyFrame(frame1) cpu = CPU(None,mmu,None,timer,logger) scheduler = Scheduler(PFIFO()) ioqueue = IOQueue(scheduler,logger) disk = Disk(None) kernel = Kernel(cpu,ioqueue,scheduler,mmu,disk,logger) disk.setKernel(kernel) disk.save(program) disk.save(programb) disk.save(programc) cpu.setKernel(kernel) kernel.executeProgram('a')
def main3(): if(1==1): instruction1 = BasicInstruction() instruction2 = BasicInstruction() memory = Memory() memory.buildMemory(5) frame1 = Frame(memory,0,1) frame2 = Frame(memory,1,2) frame3 = Frame(memory,3,1) frame4 = Frame(memory,4,1) mmu = MMU() mmu.fullFrames.append(frame1) mmu.fullFrames.append(frame3) mmu.emptyFrames.append(frame2) mmu.emptyFrames.append(frame4) program = Program('a') program.addInstruction(instruction1) pcbA = PCB('a',0,0,1) programb = Program('b') pcbB = PCB('b',0,3,1) programb.addInstruction(instruction1) frame1.load(pcbA,program) frame3.load(pcbB,programb) programc = Program('c') programc.addInstruction(instruction1) programc.addInstruction(instruction1) programc.addInstruction(instruction1) programd = Program('d') programd.addInstruction(instruction2) programd.addInstruction(instruction2) programd.addInstruction(instruction2) scheduler = Scheduler(PFIFO()) disk = Disk(None) kernel = Kernel (None,None,scheduler,mmu,disk) disk.setKernel(kernel) memory.printMemory() kernel.saveProgram(programc) print( " ") memory.printMemory() kernel.saveProgram(programd) print( " ") memory.printMemory() print(len(disk.programList))
def main(): instruction1 = BasicInstruction() instruction2 = IO_Instruction() instruction3 = Priority_Instruction() program = Program('a') program.addInstruction(instruction1) program.addInstruction(instruction1) program.addInstruction(instruction1) program.addInstruction(instruction1) program.addInstruction(instruction1) programd = Program('d') programd.addInstruction(instruction1) programd.addInstruction(instruction1) programd.addInstruction(instruction1) programd.addInstruction(instruction1) programd.addInstruction(instruction1) programb = Program('b') programb.addInstruction(instruction3) programc = Program('c') programc.addInstruction(instruction1) programc.addInstruction(instruction1) programc.addInstruction(instruction1) timer = Timer(2) memory = Memory() memory.buildMemory(9) frame1 = Frame(memory,0,9) logger = Logger("/home/matlock/Escritorio/Sistemas Operativos/OSProyect/resource/log.txt") mmu = MMU(logger) mmu.addEmptyFrame(frame1) cpu = CPU(None,mmu,None,timer,logger) scheduler = Scheduler(PFIFO()) ioqueue = IOQueue(scheduler,logger) disk = Disk(None) kernel = Kernel(cpu,ioqueue,scheduler,mmu,disk,logger) disk.setKernel(kernel) cpu.setKernel(kernel) x = [] x.append(program) x.append(programb) x.append(programc) x.append(programd) kernel.saveOnDisk(x) kernel.executeProgram('a')