grt@hocda.UUCP (G.TOMASEVICH) (05/01/84)
It is not easy to get real-time behavior out of UNIX. I have managed to get a PDP-11/45 with RP04 and two TU10 tape drives, plus two DR11-W's, to process data at 8 KHz. The operation is to copy a source file to one DR11 and read the second DR11 to a destination file. I had to hack some drivers into UNIX to get real-time restart of DMA at the end of each block transfer, and that only works with all interrupts disabled for a time. The clock loses ticks during DMA as a result. The UNIX scheduler is slow, and the clock interrupt routine is a pig. There is no way I could get the DR11W ready state detected and DMA restarted in 125 microsec without disabling all interrupts. The hacks are in the utssys.c file, which already looks like a hack. One is to read the DR11 registers, the second is to write them, and the third is to disable interrupts, wait for DR11 ready, then write the registers, enable interrupts, and return the status register value. In addition, I changed 'plock' to allow any user to lock a process, I let anyone read '/dev/mem' (an alternative is to let the user change to group 'sys'). The program reads the segmentation registers and calculates the addresses of the buffers and then the bits for the DR11W registers. The main program has a multitasking scheduler to do everything during a DMA run, which includes operating the DR11-W's, detecting errors, and reading keys and interpreting commands. I do not know RT11 at all, but in any case we are replacing our PDP with a VAX later this year, so I will have to redo the program for the VAX. I do not know how slow a data rate one needs in order to run with clock interrupts enabled. In addition, I avoided writing a real driver with interrupts. That would almost certainly fail in my case, because there is so much stuff done before the operating system even gets to the device interrupt routine. The program cannot reliably read from one file and write to another except right after doing 'fsck -S'; apparently the freelist entropy goes up too much after a few files have been made and erased. It is possible to get real-time copy for a disk file source to a raw disk filesystem (/dev/rrp4) or to a magnetic tape in raw mode, but the mag tape cannot be at the load point. For some reason, tape motion away from the load point is very slow, then succeeding writes occur fast enough. The program uses ping-pong buffers which hold .75 second of data; one pair each for the transmitting and receiving DR11W's. George Tomasevich, AT&T Bell Laboratories