Exemplo n.º 1
0
    def run(self):
        ''' move data from kernel memory to HD '''

        # get task data
        if self.used_resources.get_by_class(TaskDataAtSM) is None:
            kernel.ask_for_resource(
                kernel_data.RESOURCES.get_by_class(TaskDataAtSM), self,
                TaskDataAtSM)
            return

        # get external memory
        if self.used_resources.get_by_class(ExternalMemory) is None:
            kernel.ask_for_resource(
                kernel_data.RESOURCES.get_by_class(ExternalMemory), self,
                ExternalMemory)
            return

        # get channel3
        if self.used_resources.get_by_class(Channel3) is None:
            kernel.ask_for_resource(
                kernel_data.RESOURCES.get_by_class(Channel3), self, Channel3)
            return

        # move data
        write_data = real.channel_device.sm_hd(True)

        kernel.create_resource(TaskAtHD, self, {'write_info': write_data})
        kernel.delete_resource(self.used_resources.get_by_class(TaskDataAtSM))
        kernel.free_resource(self.used_resources.get_by_class(Channel3), self,
                             True)
        return
Exemplo n.º 2
0
    def run(self):
        ''' move task from HD to User memory '''

        # get task loaded
        if self.used_resources.get_by_class(TaskAtHD) is None:
            kernel.ask_for_resource(
                kernel_data.RESOURCES.get_by_class(TaskAtHD), self, TaskAtHD)
            return

        # TODO - interaction with TaskAtHD for asking space
        # Enough-space is single resource that when asked checks if there is enough space on user memory
        # and reserves it
        # get enough space
        #if self.used_resources.get_by_class(EnoughSpace) is None:
        #    kernel.ask_for_resource(kernel_data.RESOURCES.get_by_class(EnoughSpace), self, EnoughSpace)
        #    return

        # get channel3
        if self.used_resources.get_by_class(Channel3) is None:
            kernel.ask_for_resource(
                kernel_data.RESOURCES.get_by_class(Channel3), self, Channel3)
            return

        addresses = channel_device.hd_to_um(
            self.used_resources.get_by_class(TaskAtHD).write_info)

        if addresses is not None:
            kernel.create_resource(TaskLoaded, self, {'addresses': addresses})
            kernel.delete_resource(self.used_resources.get_by_class(TaskAtHD))

        #kernel.free_resource(self.used_resources.get_by_class(EnoughSpace), self)
        #return
        kernel.free_resource(self.used_resources.get_by_class(Channel3), self,
                             True)
        return
Exemplo n.º 3
0
    def run(self):
        ''' move data from kernel memory to HD '''

        # get task data
        if self.used_resources.get_by_class(TaskDataAtSM) is None:
            kernel.ask_for_resource(kernel_data.RESOURCES.get_by_class(TaskDataAtSM), self, TaskDataAtSM)
            return

        # get external memory
        if self.used_resources.get_by_class(ExternalMemory) is None:
            kernel.ask_for_resource(kernel_data.RESOURCES.get_by_class(ExternalMemory), self, ExternalMemory)
            return

        # get channel3 
        if self.used_resources.get_by_class(Channel3) is None:
            kernel.ask_for_resource(kernel_data.RESOURCES.get_by_class(Channel3), self, Channel3)
            return

        # move data
        write_data = real.channel_device.sm_hd(True)

        kernel.create_resource(TaskAtHD, self, {'write_info' : write_data})
        kernel.delete_resource(self.used_resources.get_by_class(TaskDataAtSM))
        kernel.free_resource(self.used_resources.get_by_class(Channel3), self, True)
        return
Exemplo n.º 4
0
    def run(self):
        ''' move task from HD to User memory '''

        # get task loaded
        if self.used_resources.get_by_class(TaskAtHD) is None:
            kernel.ask_for_resource(kernel_data.RESOURCES.get_by_class(TaskAtHD), self, TaskAtHD)
            return

        # TODO - interaction with TaskAtHD for asking space
        # Enough-space is single resource that when asked checks if there is enough space on user memory
        # and reserves it
        # get enough space
        #if self.used_resources.get_by_class(EnoughSpace) is None:
        #    kernel.ask_for_resource(kernel_data.RESOURCES.get_by_class(EnoughSpace), self, EnoughSpace)
        #    return

        # get channel3 
        if self.used_resources.get_by_class(Channel3) is None:
            kernel.ask_for_resource(kernel_data.RESOURCES.get_by_class(Channel3), self, Channel3)
            return

        addresses =  channel_device.hd_to_um(self.used_resources.get_by_class(TaskAtHD).write_info)

        if addresses is not None:
            kernel.create_resource(TaskLoaded, self, {'addresses' : addresses })
            kernel.delete_resource(self.used_resources.get_by_class(TaskAtHD))

        #kernel.free_resource(self.used_resources.get_by_class(EnoughSpace), self)
        #return 
        kernel.free_resource(self.used_resources.get_by_class(Channel3), self, True)
        return
Exemplo n.º 5
0
Arquivo: read.py Projeto: jmf-mas/labs
    def run(self):
        ''' 
          Reads task from input device to kernel memory and creates
            resource task_at_sm
        '''
        while True:
            # get task
            if self.used_resources.get_by_class(TaskAtInput) is None:
                kernel.ask_for_resource(kernel_data.RESOURCES.get_by_class(TaskAtInput), self, TaskAtInput)
                return

            # get input device
            if self.used_resources.get_by_class(InputDevice) is None:
                kernel.ask_for_resource(kernel_data.RESOURCES.get_by_class(InputDevice), self, InputDevice)
                return

            # get kernel memory
            if self.used_resources.get_by_class(KernelMemory) is None:
                kernel.ask_for_resource(kernel_data.RESOURCES.get_by_class(KernelMemory), self, KernelMemory)
                return

            # get channel device
            if self.used_resources.get_by_class(Channel1) is None:
                kernel.ask_for_resource(kernel_data.RESOURCES.get_by_class(Channel1), self, Channel1)
                return
            
            # read data
            data.input_file = self.used_resources.get_by_class(TaskAtInput).file_path
            channel_device.read_from_in(True) 

            # create resource at_sm
            kernel.create_resource(TaskAtSM, self)

            # reverse order because after freeing resource it would be caught again
            # delete resource
            kernel.delete_resource(self.used_resources.get_by_class(TaskAtInput))
            #free resource
            kernel.free_resource(self.used_resources.get_by_class(KernelMemory), self, True)
            return

            kernel.free_resource(self.used_resources.get_by_class(Channel1), self, True)
            return