Annotation of xinu/sys/test1.c, revision 1.1.1.1

1.1       root        1: #include <stdio.h>
                      2: int workcount = 0;
                      3: 
                      4: main()
                      5: {
                      6:   int nwork, ch, work();
                      7: 
                      8:   printf("Enter cycles of work to do: ");
                      9: /*  scanf("%d",&nwork); */
                     10:   nwork = 1000;
                     11:   ch = getc(CONSOLE);
                     12:   printf("Got %c %d\n",ch,nwork);
                     13:   resume(create(work,500,20,"worker",1,nwork));
                     14:   printf("Parent back from resume of child\n");
                     15:   while (1)
                     16:     {
                     17:       getc(CONSOLE);           /* wait for <CR> from keyboard */
                     18:       printf("worker at # %d\n",workcount);
                     19:     }
                     20: }
                     21: 
                     22: work(ncycles)
                     23: {
                     24:   int i;
                     25:   printf("child starting, ncycles=%d...\n",ncycles);
                     26:   for (i=1;i<=ncycles;i++)
                     27:     {
                     28:       docycle(i);              /* do ith work cycle */
                     29:       workcount++;             /* count it where parent can see it */
                     30:     }
                     31: }
                     32: 
                     33: docycle(n)
                     34: int n;
                     35: {
                     36:   int i;
                     37:   for (i=0;i<n;i++);
                     38: }

unix.superglobalmegacorp.com

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