curci@stat.uucp (Ray Curci (scri)) (02/27/89)
I am working with v1.3d minix on an IBM AT, trying to write some communications software that accesses port COM1. (/dev/tty01) By using ioctl() I set up the port to 9600 baud, 8 data bits, RAW. Using read() and write() I am able to send and receive single characters. To complete the software I have run into two problems: 1) I need to be able to do a non-blocking read, or be able to check to see if read data is available before executing read(). Under most unixes during an OPEN() call, you can use the flag O_NDELAY to make the i/o non-blocking but this is not present in minix. When looking in the minix source code where it reads from a character oriented device, it appears to me that it will always suspend when data is unavailable during read. Of course it is possible to set up a 1 second alarm under minix just before the read call to work around this problem, but for this particular application 1 second is too long. 2) I need to be able to read a timer whose units are smaller than 1 second in order to implement the protocol. Most unixes have the system call long times( &tms ) which both fills in the structure tms with user and system time for the process and children and returns the number of ticks that the system has been up as a long. (typically 1 tick = 1/60 second). Minix fills in the structure but does not return the #ticks. Unless someone can give me a better alternative I will reluctantly modify my kernel to understand the O_NDELAY and have times() return ticks. raymond curci inet: curci@stat.fsu.edu, curci@nu.cs.fsu.edu uucp: uunet!nu.cs.fsu.edu!curci