Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 3 Feb 2008 13:42:01 -0800
From:      "Len Gross" <sandiegobiker@gmail.com>
To:        "freebsd-hackers@freebsd.org" <freebsd-hackers@freebsd.org>
Subject:   Netgraph, usleep, and moving to Kernel
Message-ID:  <27cb3ada0802031342w62c96ba8i933f712c74de4988@mail.gmail.com>

next in thread | raw e-mail | index | archive | help
I've had some good success with implementing a custom MAC protocol using
Netgraph.   The current implementation runs in userland, connects to the
Kernel iface and kernel ethernet nodes.  It uses a polling loop with
usleep,  All very cool.  This is just background as the question really has
to do with usleeop in userland or kernel mode.

In testing with nothing else running on the box. it  seems to reveal that if
I ask for 100 usec of "sleep time," I get about 1000 usec (1 msec).  I have
set hz to 10,000 in kern.clockrate and Ticks is at 100.

If I set hz to 20,000 there is no improvement and Ticks seems to "reset
itsefl" to 50.  Box is an old Pentium with about 500 Mhz clock.  I also get
this behaviour on "test programs" that just call usleep.

1) Is there a way to get finer timing with usleep or an equivalent call?

2) When I move the userland into a "true" Netgraph Kernel node will I see
different behaviour?

Thanks in advance.

-- Len



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?27cb3ada0802031342w62c96ba8i933f712c74de4988>