|
|
1.1 ! root 1: /* test.c - main */ ! 2: ! 3: #include <conf.h> ! 4: #include <kernel.h> ! 5: #include <frame.h> ! 6: ! 7: /*------------------------------------------------------------------------ ! 8: * main -- test frame I/O ! 9: *------------------------------------------------------------------------ ! 10: */ ! 11: main() ! 12: { ! 13: struct frame *fptr; ! 14: int i, len, pr(); ! 15: char ch; ! 16: ! 17: kprintf("\nTesting frames - PLEASE USE 1 FOR MACHINE ID\n"); ! 18: fptr = getbuf(frbpool); ! 19: kprintf("Creating a process to print incoming messages\n"); ! 20: resume( create(pr,200,19,"print",1,0) ); ! 21: kprintf("\nType a message at each prompt.\n"); ! 22: while(TRUE) { ! 23: kprintf("Message to send: "); ! 24: gets(fptr->frdata); ! 25: if ( (i = strlen(fptr->frdata)+3) > 120 ) ! 26: i = 120; ! 27: fptr->frlen = i; ! 28: fsend(0,1,fptr); ! 29: fptr = getbuf(frbpool); ! 30: } ! 31: } ! 32: pr(netid) ! 33: int netid; ! 34: { ! 35: struct frame *fptr; ! 36: int i; ! 37: ! 38: kprintf("\n P: Starting with netid=%d\n",netid); ! 39: while (TRUE) { ! 40: fptr = freceive(netid); ! 41: i = getflen(fptr); ! 42: fptr->frdata[i-3] = '\0'; ! 43: kprintf(" P: received %s\n", fptr->frdata); ! 44: freebuf(fptr); ! 45: } ! 46: } ! 47: ! 48: P() ! 49: { ! 50: prdumph(); ! 51: qdumph(); ! 52: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.