Example #1
0
File: root.py Project: Engma90/labs
    def __init__(self):
        Process.__init__(self, {'parent' : None, 'name' : 'root', 'priority' : configs.ROOT_PRIORITY })

        # init kernel
        kernel_data.BLOCKED_PROCESSES = ProcessQueue()
        kernel_data.READY_PROCESSES = ProcessQueue()
        kernel_data.RESOURCES = ResourceList()
        kernel_data.ACTIVE_PROCESS = self

        # create static resources
        for resource in [InputDevice, OutputDevice, UserMemory, ExternalMemory,
            Terminate, EnoughSpace, Channel3, Channel1, Channel2, KernelMemory]:
            kernel.create_resource(resource, self)

        # create dynamic resources
        # for that many files in tasks folder create task_at_input resource
        counter = 0
        for file in os.listdir('tasks'):
            kernel.create_resource(TaskAtInput, self, {'file_path' : 'tasks/' + str(file) })
            counter += 1

        # create child processes
        for process in [Interrupt, Print]:
            kernel.create_process(process, self)

        #create resources if there are tasks to execute
        if kernel_data.RESOURCES.is_instance_created(TaskAtInput):
            for process in [Read, ParseTask, JobToDisk, JobToMem, Manager]:
                kernel.create_process(process, self)
        
        # create tasks_found resource
        if counter != 0:
            kernel.create_resource(TasksFound, self, {'count' : counter})
Example #2
0
    def __init__(self, opts = {}):
        opts['name'] = 'vm_' + str(kernel_data.PID)
        opts['priority'] = configs.LOADER_PRIORITY
        Process.__init__(self, opts)
        self.cs_length = opts['cs_length']
        self.ds_length = opts['ds_length']
        self.addresses = opts['addresses']
        
        # state 
        self.ic = None
        self.num = self.ds_length + 1 # skip DATA SEGMENT

        # prepare DS 
        for i in range(1, self.ds_length):
            data = user_memory.fetch(self.addresses[i])
            if data[0:2] != "DW":
                processor.pi = 2
                kernel.create_resource(InterruptEvent, self, {'process' : self })
            else:
                user_memory.write(to_hex(to_int(data[2:4])), self.addresses[i])
Example #3
0
    def __init__(self, opts={}):
        opts['name'] = 'vm_' + str(kernel_data.PID)
        opts['priority'] = configs.LOADER_PRIORITY
        Process.__init__(self, opts)
        self.cs_length = opts['cs_length']
        self.ds_length = opts['ds_length']
        self.addresses = opts['addresses']

        # state
        self.ic = None
        self.num = self.ds_length + 1  # skip DATA SEGMENT

        # prepare DS
        for i in range(1, self.ds_length):
            data = user_memory.fetch(self.addresses[i])
            if data[0:2] != "DW":
                processor.pi = 2
                kernel.create_resource(InterruptEvent, self, {'process': self})
            else:
                user_memory.write(to_hex(to_int(data[2:4])), self.addresses[i])
Example #4
0
 def __init__(self, opts={}):
     opts['name'] = 'job_to_disk_' + str(kernel_data.PID)
     opts['priority'] = configs.LOADER_PRIORITY
     Process.__init__(self, opts)
Example #5
0
File: read.py Project: Engma90/labs
 def __init__(self, opts = {}):
     opts['name'] = 'read_' + str(kernel_data.PID)
     opts['priority'] = configs.LOADER_PRIORITY
     Process.__init__(self, opts)
Example #6
0
 def __init__(self, opts={}):
     opts['name'] = 'print_' + str(kernel_data.PID)
     opts['priority'] = configs.PRINT_PRIORITY
     Process.__init__(self, opts)
Example #7
0
 def __init__(self, opts = {}):
     opts['name'] = 'interrupt_' + str(kernel_data.PID) 
     opts['priority'] = configs.INTERRUPT_PRIORITY
     Process.__init__(self, opts)
Example #8
0
 def __init__(self, opts={}):
     opts['name'] = 'interrupt_' + str(kernel_data.PID)
     opts['priority'] = configs.INTERRUPT_PRIORITY
     Process.__init__(self, opts)
Example #9
0
 def __init__(self, opts = {}):
     opts['name'] = 'print_' + str(kernel_data.PID)
     opts['priority'] = configs.PRINT_PRIORITY
     Process.__init__(self, opts)