Annotation of xinu/sys/TEST/test.c.ports, revision 1.1

1.1     ! root        1: /* test.c - main */
        !             2: 
        !             3: #include <conf.h>
        !             4: #include <kernel.h>
        !             5: #include <mark.h>
        !             6: #include <ports.h>
        !             7: 
        !             8: /*----------------------------------------------------------------------
        !             9:  *  main  --  simple ports test
        !            10:  *----------------------------------------------------------------------
        !            11:  */
        !            12: main()
        !            13: {
        !            14:        int     port1, port2, p();
        !            15: 
        !            16:        kprintf("Testing ports\n");
        !            17:        kprintf("Pcreate(2) returns %d\n", port1=pcreate(2) );
        !            18:        kprintf("Pcreate(3) returns %d\n", port2=pcreate(3) );
        !            19:        kprintf("Psend(%d,100) = %d\n", port1, psend(port1,100) );
        !            20:        kprintf("Preceive(%d) = %d\n", port1, preceive(port1) );
        !            21:        kprintf("Psend(%d, 200) = %d\n", port1, psend(port1,200) );
        !            22:        kprintf("Psend(%d, 300) = %d\n", port1, psend(port1,300) );
        !            23:        kprintf("Psend(%d, 400) = %d\n", port2, psend(port2,400) );
        !            24:        kprintf("Preceive(%d) = %d\n", port2, preceive(port2) );
        !            25:        kprintf("Preceive(%d) = %d\n", port1, preceive(port1) );
        !            26:        kprintf("Preceive(%d) = %d\n", port1, preceive(port1) );
        !            27:        kprintf("Psend(%d, 500) = %d\n", port2, psend(port2,500) );
        !            28:        kprintf("Psend(%d, 600) = %d\n", port2, psend(port2,600) );
        !            29:        kprintf("Psend(%d, 700) = %d\n", port2, psend(port2,700) );
        !            30:        kprintf("Creating process to read port %d\n", port2);
        !            31:        resume(create(p,300,25,"ptest",1, port2));
        !            32:        kprintf("Attempt to overflow port and cause wait\n");
        !            33:        kprintf("Psend(%d, 800) = %d\n", port2, psend(port2,800) );
        !            34:        kprintf("Psend(%d, 810) = %d\n", port2, psend(port2,810) );
        !            35:        kprintf("Psend(%d, 820) = %d\n", port2, psend(port2,820) );
        !            36:        kprintf("Psend(%d, 830) = %d\n", port2, psend(port2,830) );
        !            37: 
        !            38: }
        !            39: p(port)
        !            40: {
        !            41:        int     msg;
        !            42: 
        !            43:        kprintf(" P:reading port %d every five seconds\n",port);
        !            44:        for (msg=0 ; msg != 830 ; sleep10(50) )
        !            45:            kprintf(" P: preceive(%d) = %d\n",port,msg=preceive(port));
        !            46:        kprintf("End of port test\n");
        !            47: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.