1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147
| #include <lib.h> const int PP1 = 0x800, PP2 = 0x1001; int finished = 0; void handler(int num){ debugf("into sighandler to %d.\n",num); int envid=syscall_getenvid(); debugf("%x received sig%d.\n",envid,num); if(num == 5){ finished++; debugf("adding finished!\n"); } } int main() { u_int me, who, i=0; me = syscall_getenvid(); struct sigaction sig; struct sigset_t set; struct sigset_t shed; sigemptyset(&set); sigemptyset(&shed); sigaddset(&shed, 2); sigaddset(&shed, 3); sig.sa_handler=handler; sig.sa_mask=set; sigaction(2,&sig,NULL); sigaction(3,&sig,NULL); sigaction(5,&sig,NULL); debugf("i am %x\n", me); sigprocmask(2, &shed, NULL); if (me == PP1) { kill(PP2, 5); debugf("@@@@PP1 sent 5 to %x@@@@\n", PP2); debugf("PP1 start wait finished sig\n"); while(finished <1){ i++; if((i%10000000) == 0){ debugf("%x now finished is %d\n", me,finished); } } debugf("pp1received start sig and send!\n"); who = PP2; kill(who, 5); kill(who, 3); kill(who, 2); kill(who, 5); kill(who, 5); debugf("@@@@PP1 sent 5,3,2 to PP2@@@@\n"); }if(me == PP2){ debugf("wait PP1 start!\n"); while(finished < 1){ i++; if((i%10000000) == 0){ debugf("%x now finished is %d\n", me,finished); } } kill(PP1, 5); debugf("@@@@@send 5 from %x to %x\n", me, PP1); debugf("PP2 for start\n"); while(finished <4){ i++; if((i%10000000) == 0){ debugf("%x now finished is %d\n", me,finished); } } } return 0; }
-------------------------------------------------------------------------------
init.c: mips_init() is called Memory size: 65536 KiB, number of pages: 16384 to memory 80430000 for struct Pages. pmap.c: mips vm init success i am 1001 wait PP1 start! i am 800 @@@@PP1 sent 5 to 1001@@@@ PP1 start wait finished sig into sighandler to 5. 1001 received sig5. adding finished! @@@@@send 5 from 1001 to 800 PP2 for start into sighandler to 5. 800 received sig5. adding finished! pp1received start sig and send! @@@@PP1 sent 5,3,2 to PP2@@@@ [00000800] destroying 00000800 [00000800] free env 00000800 i am killed ... into sighandler to 5. 1001 received sig5. adding finished! into sighandler to 5. 1001 received sig5. adding finished! into sighandler to 5. 1001 received sig5. adding finished! [00001001] destroying 00001001 [00001001] free env 00001001 i am killed ...
-------------------------------------------------------------------------------
init.c: mips_init() is called Memory size: 65536 KiB, number of pages: 16384 to memory 80430000 for struct Pages. pmap.c: mips vm init success i am 1001 wait PP1 start! i am 800 @@@@PP1 sent 5 to 1001@@@@ PP1 start wait finished sig into sighandler to 5. 1001 received sig5. adding finished! @@@@@send 5 from 800 to 800 into sighandler to 5. 800 received sig5. adding finished! pp1received start sig and send! into sighandler to 5. 1001 received sig5. adding finished! into sighandler to 5. 1001 received sig5. adding finished! @@@@@send 5 from 800 to 800 PP2 for start into sighandler to 5. 800 received sig5. adding finished! 800 now finished is 3 1001 now finished is 2 800 now finished is 3 1001 now finished is 2 800 now finished is 3 1001 now finished is 2 800 now finished is 3 ...
|