|
|
1.1 ! root 1: .TH REQUEST 3 ! 2: .CT 2 comm_term time_man proc_man ! 3: .SH NAME ! 4: request, own, wait, alarm, sleep, nap, kbdchar, rcvchar, realtime, sendchar, sendnchars, \- 5620 I/O requests ! 5: .SH SYNOPSIS ! 6: .B #include <jerq.h> ! 7: .PP ! 8: .B void request(r) int r; ! 9: .PP ! 10: .B int own(r) int r; ! 11: .PP ! 12: .B int wait(r) int r; ! 13: .PP ! 14: .B void alarm(t) unsigned t; ! 15: .PP ! 16: .B void sleep(t) unsigned t; ! 17: .PP ! 18: .B void nap(t) unsigned t; ! 19: .PP ! 20: .B long realtime(); ! 21: .PP ! 22: .B int kbdchar(); ! 23: .PP ! 24: .B int rcvchar(); ! 25: .PP ! 26: .B void sendchar(c) int c; ! 27: .PP ! 28: .B "void sendnchars(n, cp) int n; char *cp;" ! 29: .SH DESCRIPTION ! 30: .I Request ! 31: announces a program's intent to use I/O devices and resources, ! 32: and must be called once early in a program, before ! 33: .IR initdisplay . ! 34: The bit vector ! 35: .I r ! 36: indicates which resources are to be used by ! 37: OR'ing together one or more of the elements ! 38: .B KBD ! 39: (keyboard), ! 40: .BR MOUSE , ! 41: .B RCV ! 42: (characters received by terminal from Unix), ! 43: .B SEND ! 44: (characters sent from terminal to Unix) ! 45: and ! 46: .BR ALARM . ! 47: For example, ! 48: .B request(MOUSE|KBD) ! 49: indicates that the process ! 50: wants to use the mouse and keyboard. ! 51: All resource except ! 52: .B RCV ! 53: are always implicitly requested. ! 54: .PP ! 55: .I Own ! 56: returns a bit vector ! 57: of which I/O resources have data available. ! 58: For example, ! 59: .BR own()&KBD ! 60: indicates ! 61: whether a character is available to be read by ! 62: .I kbdchar ! 63: (see below), ! 64: .BR own()&RCV ! 65: indicates ! 66: whether a character is available to be read by ! 67: .I rcvchar ! 68: (see below) and, ! 69: .B own()&ALARM ! 70: indicates whether the alarm timer has fired. ! 71: .PP ! 72: .IR Wait 's ! 73: argument ! 74: .I r ! 75: is a bit vector composed as for ! 76: .IR request . ! 77: .I Wait ! 78: suspends the process, ! 79: enabling others, ! 80: until at least one of the requested resources is available. ! 81: The return value is a bit vector indicating which of the requested resources ! 82: are available \(em the same as ! 83: .BR own()&r . ! 84: .PP ! 85: Processes wishing to poll for input may call ! 86: .BR wait(CPU) ; ! 87: it will return as soon as all available input has been queued. ! 88: .B CPU ! 89: is a fake resource which is always ! 90: requested. ! 91: The ! 92: .B SEND ! 93: pseudo-resource is unused; ! 94: .B wait(SEND) ! 95: always succeeds. ! 96: .PP ! 97: .I Alarm ! 98: starts a timer which will fire ! 99: .I t ! 100: ticks (60ths of a second) into the future. ! 101: A pseudo-resource ! 102: .B ALARM ! 103: can be used to check the status of the timer with ! 104: .I own ! 105: or ! 106: .IR wait . ! 107: .PP ! 108: .I Nap ! 109: is equivalent to ! 110: .B wait(MOUSE) ! 111: in the emulator library. ! 112: It blocks the process until a new window event is received. ! 113: .PP ! 114: .I Sleep ! 115: delays the process for ! 116: .I t ! 117: ticks of a 60Hz clock. ! 118: .I Sleep ! 119: does not interfere with ! 120: .IR alarm , ! 121: and vice versa. ! 122: .PP ! 123: .I Realtime ! 124: returns the number of 60Hz clock ticks since 1970 mod 32. ! 125: .PP ! 126: .I Kbdchar ! 127: returns the next keyboard character typed to the process. ! 128: If no characters have been typed, or ! 129: .B KBD ! 130: has not been ! 131: .IR request ed, ! 132: .I kbdchar ! 133: returns ! 134: \-1. ! 135: .PP ! 136: .I Rcvchar ! 137: returns the next character received from the host, ! 138: typically written on the standard output of the ! 139: companion ! 140: .I host ! 141: process. ! 142: If there are no characters available, or ! 143: .B RCV ! 144: has not been ! 145: .IR request ed, ! 146: .I rcvchar ! 147: returns ! 148: \-1. ! 149: .PP ! 150: .I Sendchar ! 151: sends a single byte to the ! 152: .I host ! 153: process. ! 154: .I Sendnchars ! 155: sends to the ! 156: .I host ! 157: process ! 158: .I n ! 159: characters pointed to by ! 160: .IR p . ! 161: .SH EXAMPLES ! 162: .EX ! 163: request(KBD|RCV); ! 164: for(;;){ ! 165: r=wait(KBD|RCV); ! 166: if(r&KBD) ! 167: keyboard(kbdchar()); ! 168: if(r&RCV) ! 169: receive(rcvchar()); ! 170: } ! 171: .EE ! 172: .PD0 ! 173: .IP ! 174: Take input from either the keyboard or the host. ! 175: .PD ! 176: .SH SEE ALSO ! 177: .IR button (3)
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.