Writing Driver (and usleep)
Paul Barton-Davis
pauld at stowe.cs.washington.edu
Tue Apr 16 04:46:18 AEST 1991
First the good news:
You can get the driver docs from AT&T, 2 manuals, one
containing the man pages, the other a general guide to
device drivers for V/386.
Now the bad news:
1) Price - each manual is about $150 !!!
2) Content - the manuals were obviously produced by
editing those for a 3B2 and still abound with
irrelevant and sometimes incorrect material
referring to those systems. Much of what's
needed for a 386 system is missing or insufficiently
detailed.
3) Content(II) - the functions you mention are NOT
documented.
Finally, if you want one last way to get the kernel docs, try SCO.
They do still distribute the driver man pages, both printed and
otherwise. If you know someone with SCO, they might be able to let you
get (printed or online) copies of the stuff in /usr/man/catK, and SCO
*might* sell you a driver manual on its own.
RAMBLING ---
Its important to realize that there are several thousand functions
in the kernel, any one of which you could call from a driver. That
doesn't mean they are part of the "kernel/driver interface", and
there are no guarantees that they will correctly in the context
of a driver (particularly during interrupt handling).
Furthermore, as for the tenmicrosecond() function - I have to say that
I know of only one way of coding this. You can't use the clock, since
must V/386 systems set HZ to be 50 or 60, which means 16 milliseconds
between ticks right there. All you can do is to block all interrupts,
and then go into a loop that should last for about 10msecs. Move your
code to a 486 or some other compatible system and it may break.
System V timing, like most of the system, sucks. If anyone knows of
any other way to do this, let me know.
Which brings up another kernel bug. There were some postings last week
about a usleep function. SCO apparently don't know how to calculate
msecs, because poll (fds, 0, 1000) only sleeps for .6 second. After
some experimentation, it appears that someone has not corrected some
code that assumes HZ = 100, and to get the correct figure, you have
to do this:
actual_msecs_required = requested_msecs * 100 / HZ;
This is a serious bug that has implications for areas other than
those of importance to kernel hackers and deep system programmers.
--
Paul Barton-Davis <pauld at cs.washington.edu>
UW Computer Science Lab ``to shatter tradition makes us feel free''
More information about the Comp.unix.sysv386
mailing list