def __init__(self, programs, **kwargs):
        """
        Builds a Decree OS
        :param cpus: CPU for this platform
        :param mem: memory for this platform
        :todo: generalize for more CPUs
        :todo: fix deps?
        """
        programs = programs.split(",")
        super().__init__(path=programs[0], **kwargs)

        self.program = programs[0]
        self.clocks = 0
        self.files = []
        self.syscall_trace = []

        self.files = []
        # open standard files stdin, stdout, stderr
        logger.info("Opening file descriptors (0,1,2)")
        self.input = Socket()
        self.output = Socket()

        stdin = Socket()
        stdout = Socket()
        stderr = Socket()
        # A transmit to stdin,stdout or stderr will be directed to out
        stdin.peer = self.output
        stdout.peer = self.output
        stderr.peer = self.output
        # A receive from stdin will get data from inp
        self.input.peer = stdin
        # A receive on stdout or stderr will return no data (rx_bytes: 0)

        assert self._open(stdin) == 0
        assert self._open(stdout) == 1
        assert self._open(stderr) == 2

        # Load process and setup socketpairs
        self.procs = []
        for program in programs:
            self.procs += self.load(program)
            socka, sockb = Socket.pair()
            self._open(socka)
            self._open(sockb)

        nprocs = len(self.procs)
        nfiles = len(self.files)
        assert nprocs > 0
        self.running = list(range(nprocs))
        self._current = 0

        # Each process can wait for one timeout
        self.timers = [None] * nprocs
        # each fd has a waitlist
        self.rwait = [set() for _ in range(nfiles)]
        self.twait = [set() for _ in range(nfiles)]

        # Install event forwarders
        for proc in self.procs:
            self.forward_events_from(proc)
def __init__ ( self , programs , ** kwargs ) : programs = programs . split ( "," ) super ( ) . __init__ ( path = programs [ 0 ] , ** kwargs ) self . program = programs [ 0 ] self . clocks = 0 self . files = [ ] self . syscall_trace = [ ] self . files = [ ] logger . info ( "Opening file descriptors (0,1,2)" ) self . input = Socket ( ) self . output = Socket ( ) stdin = Socket ( ) stdout = Socket ( ) stderr = Socket ( ) stdin . peer = self . output stdout . peer = self . output stderr . peer = self . output self . input . peer = stdin assert self . _open ( stdin ) == 0 assert self . _open ( stdout ) == 1 assert self . _open ( stderr ) == 2 self . procs = [ ] for program in programs : self . procs += self . load ( program ) socka , sockb = Socket . pair ( ) self . _open ( socka ) self . _open ( sockb ) nprocs = len ( self . procs ) nfiles = len ( self . files ) assert nprocs > 0 self . running = list ( range ( nprocs ) ) self . _current = 0 self . timers = [ None ] * nprocs self . rwait = [ set ( ) for _ in range ( nfiles ) ] self . twait = [ set ( ) for _ in range ( nfiles ) ] for proc in self . procs : self . forward_events_from ( proc )
Builds a Decree OS
        :param cpus: CPU for this platform
        :param mem: memory for this platform
        :todo: generalize for more CPUs
        :todo: fix deps?