#!/bin/rc # makes hypercubes and launches applications and simulations # usuall used after rfork V and starting ramfs and possibly importing /srv from other cubehosts if(! test -d /tmp/cube){ echo 'mkdir /tmp/cube and touch 0 1 2 3 corresponding to desired cube dimensions' exit no.cube } rfork en # lists of node names of hypercubes and hypercube slices dtwo=(00 01 10 11) dthree=(000 001 010 011 100 101 110 111) dfour=(0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111) dfive=(00000 00001 00010 00011 00100 00101 00110 00111 01000 01001 01010 01011 01100 01101 01110 01111 10000 10001 10010 10011 10100 10101 10110 10111 11000 11001 11010 11011 11100 11101 11110 11111) dsix=(000000 000001 000010 000011 000100 000101 000110 000111 001000 001001 001010 001011 001100 001101 001110 001111 010000 010001 010010 010011 010100 010101 010110 010111 011000 011001 011010 011011 011100 011101 011110 011111 100000 100001 100010 100011 100100 100101 100110 100111 101000 101001 101010 101011 101100 101101 101110 101111 110000 110001 110010 110011 110100 110101 110110 110111 111000 111001 111010 111011 111100 111101 111110 111111) hasix=(000000 000001 000010 000011 000100 000101 000110 000111 001000 001001 001010 001011 001100 001101 001110 001111 010000 010001 010010 010011 010100 010101 010110 010111 011000 011001 011010 011011 011100 011101 011110 011111) hbsix=(100000 100001 100010 100011 100100 100101 100110 100111 101000 101001 101010 101011 101100 101101 101110 101111 110000 110001 110010 110011 110100 110101 110110 110111 111000 111001 111010 111011 111100 111101 111110 111111) dsix=(000000 000001 000010 000011 000100 000101 000110 000111 001000 001001 001010 001011 001100 001101 001110 001111 010000 010001 010010 010011 010100 010101 010110 010111 011000 011001 011010 011011 011100 011101 011110 011111 100000 100001 100010 100011 100100 100101 100110 100111 101000 101001 101010 101011 101100 101101 101110 101111 110000 110001 110010 110011 110100 110101 110110 110111 111000 111001 111010 111011 111100 111101 111110 111111) hasev=(0000000 0000001 0000010 0000011 0000100 0000101 0000110 0000111 0001000 0001001 0001010 0001011 0001100 0001101 0001110 0001111 0010000 0010001 0010010 0010011 0010100 0010101 0010110 0010111 0011000 0011001 0011010 0011011 0011100 0011101 0011110 0011111 0100000 0100001 0100010 0100011 0100100 0100101 0100110 0100111 0101000 0101001 0101010 0101011 0101100 0101101 0101110 0101111 0110000 0110001 0110010 0110011 0110100 0110101 0110110 0110111 0111000 0111001 0111010 0111011 0111100 0111101 0111110 0111111) hbsev=(1000000 1000001 1000010 1000011 1000100 1000101 1000110 1000111 1001000 1001001 1001010 1001011 1001100 1001101 1001110 1001111 1010000 1010001 1010010 1010011 1010100 1010101 1010110 1010111 1011000 1011001 1011010 1011011 1011100 1011101 1011110 1011111 1100000 1100001 1100010 1100011 1100100 1100101 1100110 1100111 1101000 1101001 1101010 1101011 1101100 1101101 1101110 1101111 1110000 1110001 1110010 1110011 1110100 1110101 1110110 1110111 1111000 1111001 1111010 1111011 1111100 1111101 1111110 1111111) dsev=(0000000 0000001 0000010 0000011 0000100 0000101 0000110 0000111 0001000 0001001 0001010 0001011 0001100 0001101 0001110 0001111 0010000 0010001 0010010 0010011 0010100 0010101 0010110 0010111 0011000 0011001 0011010 0011011 0011100 0011101 0011110 0011111 0100000 0100001 0100010 0100011 0100100 0100101 0100110 0100111 0101000 0101001 0101010 0101011 0101100 0101101 0101110 0101111 0110000 0110001 0110010 0110011 0110100 0110101 0110110 0110111 0111000 0111001 0111010 0111011 0111100 0111101 0111110 0111111 1000000 1000001 1000010 1000011 1000100 1000101 1000110 1000111 1001000 1001001 1001010 1001011 1001100 1001101 1001110 1001111 1010000 1010001 1010010 1010011 1010100 1010101 1010110 1010111 1011000 1011001 1011010 1011011 1011100 1011101 1011110 1011111 1100000 1100001 1100010 1100011 1100100 1100101 1100110 1100111 1101000 1101001 1101010 1101011 1101100 1101101 1101110 1101111 1110000 1110001 1110010 1110011 1110100 1110101 1110110 1110111 1111000 1111001 1111010 1111011 1111100 1111101 1111110 1111111) qaeight=(00000000 00000001 00000010 00000011 00000100 00000101 00000110 00000111 00001000 00001001 00001010 00001011 00001100 00001101 00001110 00001111 00010000 00010001 00010010 00010011 00010100 00010101 00010110 00010111 00011000 00011001 00011010 00011011 00011100 00011101 00011110 00011111 00100000 00100001 00100010 00100011 00100100 00100101 00100110 00100111 00101000 00101001 00101010 00101011 00101100 00101101 00101110 00101111 00110000 00110001 00110010 00110011 00110100 00110101 00110110 00110111 00111000 00111001 00111010 00111011 00111100 00111101 00111110 00111111) qbeight=(01000000 01000001 01000010 01000011 01000100 01000101 01000110 01000111 01001000 01001001 01001010 01001011 01001100 01001101 01001110 01001111 01010000 01010001 01010010 01010011 01010100 01010101 01010110 01010111 01011000 01011001 01011010 01011011 01011100 01011101 01011110 01011111 01100000 01100001 01100010 01100011 01100100 01100101 01100110 01100111 01101000 01101001 01101010 01101011 01101100 01101101 01101110 01101111 01110000 01110001 01110010 01110011 01110100 01110101 01110110 01110111 01111000 01111001 01111010 01111011 01111100 01111101 01111110 01111111) qceight=(10000000 10000001 10000010 10000011 10000100 10000101 10000110 10000111 10001000 10001001 10001010 10001011 10001100 10001101 10001110 10001111 10010000 10010001 10010010 10010011 10010100 10010101 10010110 10010111 10011000 10011001 10011010 10011011 10011100 10011101 10011110 10011111 10100000 10100001 10100010 10100011 10100100 10100101 10100110 10100111 10101000 10101001 10101010 10101011 10101100 10101101 10101110 10101111 10110000 10110001 10110010 10110011 10110100 10110101 10110110 10110111 10111000 10111001 10111010 10111011 10111100 10111101 10111110 10111111) qdeight=(11000000 11000001 11000010 11000011 11000100 11000101 11000110 11000111 11001000 11001001 11001010 11001011 11001100 11001101 11001110 11001111 11010000 11010001 11010010 11010011 11010100 11010101 11010110 11010111 11011000 11011001 11011010 11011011 11011100 11011101 11011110 11011111 11100000 11100001 11100010 11100011 11100100 11100101 11100110 11100111 11101000 11101001 11101010 11101011 11101100 11101101 11101110 11101111 11110000 11110001 11110010 11110011 11110100 11110101 11110110 11110111 11111000 11111001 11111010 11111011 11111100 11111101 11111110 11111111) while (~ $1 -*){ switch($1){ case -d debug=yes shift case -h routehub=yes shift case -s routestart=yes shift case * echo bad flag $1 shift } } # whatsit.rc dfour mrsulu.rc kill # kills named process and closes hubs if(~ $3 kill){ kill $2 |rc for(i in $$1){ echo step >>/n/$i/in sleep 1 echo quit >>/n/$i.ctl/ctl sleep 1 echo quit >>/n/$i/ctl } exit } # whatsit.rc dfour rocks.sim # used after initial hypercube setup to launch a sim with mrsulu.rc if(~ $2 *.sim){ suluargs=$2 if(~ $debug yes) suluargs=(-d $suluargs) for(i in $$1) echo mrsulu.rc $suluargs '< /n/'^$i^'/in' >>/n/$i.ctl/io0 . $2.fns rc exit } # whatsit.rc dfour cube.rc # starts an arbitrary program connected to the given cube if(~ $#2 1){ for(i in $$1) echo $2 '< /n/'^$i^'/in' >>/n/$i.ctl/io0 exit } # whatsit.rc -s hasev # used as the second stage in setting up a multisystem partitioned cube if(~ $routestart yes){ for(i in $$1){ mount /srv/$i.ctl /n/$i.ctl echo routestart.rc >>/n/$i.ctl/io0 } sleep 5 for(i in $$1) mount /srv/$i /n/$i rc exit } # setup sizing for window spawning switch($1){ case dtwo dim=2 hinc=949 vinc=499 case dthree dim=3 hinc=474 vinc=499 case dfour dim=4 hinc=474 vinc=249 case dfive dim=5 hinc=237 vinc=249 case hasix dim=5 hinc=237 vinc=249 case hbsix dim=5 hinc=237 vinc=249 case dsix dim=6 hinc=237 vinc=124 case hasev dim=6 hinc=237 vinc=124 case hbsev dim=6 hinc=237 vinc=124 case dsev dim=7 hinc=119 vinc=124 case qaeight dim=6 hinc=237 vinc=124 case qbeight dim=6 hinc=237 vinc=124 case qceight dim=6 hinc=237 vinc=124 case qdeight dim=6 hinc=237 vinc=124 } hstart=0 vstart=0 hcor=`{echo $hstart + $hinc |hoc} vcor=`{echo $vstart + $vinc |hoc} # whatsit.rc dfour # spawns windows for a hypercube, puts control hubfs in each, puts cube hubfs in each for(i in $$1){ rfork efns mynum=$i # echo window -m -r $hstart $vstart $hcor $vcor hub $i.ctl window -m -r $hstart $vstart $hcor $vcor hub $i.ctl hstart=$hcor hcor=`{echo $hcor + $hinc |hoc} if(test $hstart -gt 1700){ hstart=0 hcor=`{echo $hstart + $hinc |hoc} vstart=$vcor vcor=`{echo $vcor + $vinc |hoc} } } # give all those windows time to spawn and then tell the ctl shell to start the cube hub sleep 5 for(i in $$1){ mount /srv/$i.ctl /n/$i.ctl echo routehub.rc >>/n/$i.ctl/io0 } # whatsit.rc -h hasev # if we are doing a multipart multisystem cube we exit here if(~ $routehub yes) exit # wait for setup and start the actual cubic connection routing sleep 6 for(i in $$1){ # mount /srv/$i.ctl /n/$i.ctl echo routestart.rc >>/n/$i.ctl/io0 } # wait again and mount everything because we are going to be sending commands sleep 5 for(i in $$1) mount /srv/$i /n/$i rc