コード例 #1
0
ファイル: Kernel.py プロジェクト: MatLock/OSProject
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()
コード例 #2
0
ファイル: Kernel.py プロジェクト: MatLock/OSProject
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')   
コード例 #3
0
ファイル: Kernel.py プロジェクト: MatLock/OSProject
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()
コード例 #4
0
ファイル: main.py プロジェクト: HarishRohini/eecs645
def start_execution(options):
    f = open(options.file, 'r')
    content = f.read()
    read_content = ReadContents()
    instructions = Instructions()
    #print "Id 2 :", id(instructions)
    registers = Registers()
    memory = Memory()
    read_content.read_iregisters(content)
    read_content.read_fpregisters(content)
    read_content.read_memory(content)
    read_content.get_instructions(content)
    #instructions, registers, memory = read_content.return_attrs()
    instructions = read_content.return_attrs()
    #print "registers: ", id(registers), " Inst : ", id(instructions.registers), id(memory), id(instructions.memory)
    #print instructions.get_instructions(), '\n', registers.r['R2'], '\n', memory.location, '\n', registers.f
    instructions.build_instruction_objects()
    #print instructions.instructions_object_list
    #print "In main file : ", id(memory), id(registers), id(instructions)
    clock = Clock(instructions)
    #clock.print_object_ids()
    #print clock.start_clock()
    #print clock.clock
    clock.next_instruction()
    #print "log : ", Registers.f['F4']['contents']
    writer = Writer(clock.clock_execution_dict, Registers.f,
                    len(instructions.instructions_object_list))
    writer.write_to_file()
    writer.write_to_file_registers()
コード例 #5
0
    def __init__(self, pc=1):
        self.registers = [Register(i) for i in range(32)]
        self.params = None
        self.op = None
        self.pc = pc

        self.saved_flags = Flags()
        self.memory = Memory()
コード例 #6
0
 def __init__(self, memorySize):
     self._memory = Memory(memorySize)
     self._mmu = MMU(self._memory)
     self._irqVector = IRQVector()
     self._cpu = CPU(self._mmu, self._irqVector)
     self._IOdevice = IOdevice(self._irqVector)
     self._clock = Clock(self._cpu, self._IOdevice)
     self._timer = DummyTimer()
コード例 #7
0
ファイル: Kernel.py プロジェクト: MatLock/OSProject
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))
コード例 #8
0
ファイル: Kernel.py プロジェクト: MatLock/OSProject
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')
コード例 #9
0
ファイル: app.py プロジェクト: mklindtner/backend
        traceback.print_exc()
        return json_error("Illegal filter parameters", 422, e)


@app.route('/property-types', methods=['GET'])
def get_property_types():
    types = [{'name': t.name, 'value': t.value} for t in PropertyType]
    return jsonify(types)


def prepare(df):
    return df.fillna('NaN')


@app.route('/predict', methods=['POST'])
def cost_prediction():
    sent = dict(request.json)
    return jsonify(cost_predictor(sent))


if __name__ == '__main__':
    print('Loading memory ...')
    memory = Memory('new_data.csv')
    graph_cache = create_graph_cache(memory.data)
    print(f'Loaded {len(memory.data)} records.')
    cost_predictor = create_cost_predictor(memory.data)
    prop_type_predictor, ptc_acc = create_pt_classifier(memory.data)
    print(f'Trained property type classifier, accuracy={ptc_acc}')

    app.run()