Example #1
0
    def start(taskletCls, newname='Tasklet', newgroup=None, newuser=None, result1=None, *args, **kwargs):
        
        # Temporarily disable TCB, so that calling tasklet's context
        # is not used for misled API calls
        # essentially bug-prevention
        prev_tcb = S.loc.tcb
        S.loc.tcb = None
        
        task = taskletCls(*args, **kwargs)
        
        S.loc.tcb = prev_tcb
        
        current_tcb = prev_tcb
        
        if (newuser != None) and (current_tcb.user != 'SYSTEMYA'):
            raise Tasklet.AccessDenied('Cannot set user, not SYSTEMYA')
        newuser = newuser or current_tcb.user
        if (newgroup != None) and (current_tcb.group != 'admin'):
            raise Tasklet.AccessDenied('Cannot set group, not admin')
        newgroup = newgroup or current_tcb.group
        
        tid = S.getNextTID()
        tcb = TaskletControlBlock(tid, newuser, newgroup, newname)
        
        if isinstance(task, GCTasklet):
            tcb.is_gc_on = True
        
        S.registerNewTasklet(tcb, task)
        S.schedule(tcb, task.on_startup)

        if result1 != None:
            S.schedule(current_tcb, result1, Tasklet(tid, newuser, newgroup, newname))
Example #2
0
    def start(taskletCls,
              newname='Tasklet',
              newgroup=None,
              newuser=None,
              result1=None,
              *args,
              **kwargs):

        # Temporarily disable TCB, so that calling tasklet's context
        # is not used for misled API calls
        # essentially bug-prevention
        prev_tcb = S.loc.tcb
        S.loc.tcb = None

        task = taskletCls(*args, **kwargs)

        S.loc.tcb = prev_tcb

        current_tcb = prev_tcb

        if (newuser != None) and (current_tcb.user != 'SYSTEMYA'):
            raise Tasklet.AccessDenied('Cannot set user, not SYSTEMYA')
        newuser = newuser or current_tcb.user
        if (newgroup != None) and (current_tcb.group != 'admin'):
            raise Tasklet.AccessDenied('Cannot set group, not admin')
        newgroup = newgroup or current_tcb.group

        tid = S.getNextTID()
        tcb = TaskletControlBlock(tid, newuser, newgroup, newname)

        if isinstance(task, GCTasklet):
            tcb.is_gc_on = True

        S.registerNewTasklet(tcb, task)
        S.schedule(tcb, task.on_startup)

        if result1 != None:
            S.schedule(current_tcb, result1,
                       Tasklet(tid, newuser, newgroup, newname))
Example #3
0
        print ("INIT: Init v1.0 (part of System y) started")
        for elem in self.initlist:
            if len(elem) == 4: user, group, name, cls = elem; args = (); kwargs = {}
            if len(elem) == 5: user, group, name, cls, args = elem; kwargs = {}
            if len(elem) == 6: user, group, name, cls, args, kwargs = elem
            
            if isinstance(cls, str):    
                # attempt an import
                try:
                    mod = importlib.import_module('.'.join(cls.split('.')[:-1]))
                    cls = getattr(mod, cls.split('.')[-1])
                except (ImportError, AttributeError):
                    print("INIT: Failed to import", cls)
                    continue
                
            Tasklet.start(cls, name, group, user, None, *args, **kwargs) 

            print("INIT:", len(self.initlist), "tasklets spawned, exiting")

if __name__ == '__main__':
    S.startup()
    S.tidIssuer.adjustID(0)  # 0th Page on 0th Frame

    
    # manual bootstrap here
    init = InitTasklet(initrd)
    tcb = TaskletControlBlock(0, 'SYSTEMYA', 'admin', 'init')
    S.registerNewTasklet(tcb, init)
    S.schedule(tcb, init.on_startup)    

Example #4
0
                kwargs = {}
            if len(elem) == 5:
                user, group, name, cls, args = elem
                kwargs = {}
            if len(elem) == 6: user, group, name, cls, args, kwargs = elem

            if isinstance(cls, str):
                # attempt an import
                try:
                    mod = importlib.import_module('.'.join(
                        cls.split('.')[:-1]))
                    cls = getattr(mod, cls.split('.')[-1])
                except (ImportError, AttributeError):
                    print("INIT: Failed to import", cls)
                    continue

            Tasklet.start(cls, name, group, user, None, *args, **kwargs)

            print("INIT:", len(self.initlist), "tasklets spawned, exiting")


if __name__ == '__main__':
    S.startup()
    S.tidIssuer.adjustID(0)  # 0th Page on 0th Frame

    # manual bootstrap here
    init = InitTasklet(initrd)
    tcb = TaskletControlBlock(0, 'SYSTEMYA', 'admin', 'init')
    S.registerNewTasklet(tcb, init)
    S.schedule(tcb, init.on_startup)