Re: clock.h

From: Peter Pentchev (roam_at_ringlet.net)
Date: 02/28/05

  • Next message: Dan Nelson: "Re: clock.h"
    Date: Mon, 28 Feb 2005 18:06:49 +0200
    To: Kathy Quinlan <kat-free@kaqelectronics.dyndns.org>
    
    
    

    On Mon, Feb 28, 2005 at 11:39:52PM +0800, Kathy Quinlan wrote:
    > I have this:
    >
    > #include <machine/clock.h>
    >
    > In program I use this:
    >
    > DELAY(1000);
    >
    > I get this:
    >
    > undefined referance to 'DELAY'
    >
    > when I compile the program with GCC with flags -Wall -g -o com main.c
    >
    > ANY ideas ??
    >
    > I have looked in the relevent header and it seems to be there

    Yes, it is in clock.h, but...

    /*-
     * Kernel interface to machine-dependent clock driver.

    That's the way that clock.h starts. The 'kernel interface' part means
    that this is a header file that declares functions that are used *only*
    within the FreeBSD kernel - since they are only implemented in another
    part of the kernel code. You cannot use these definitions and functions
    from a userland program, as you are trying to do.

    The reason that the DELAY() declaration seems to be in the header file,
    yet the compiler does not see it, is the #ifdef _KERNEL at the top of
    clock.h :) This is just a level of protection that accomplishes exactly
    that - no userland program should *ever* define the _KERNEL symbol, so
    no userland program will be fooled into believing that there is a
    DELAY() function that it could possibly use. It simply cannot, since
    the DELAY() function is declared within kernel code for use by the
    kernel only.

    If you want a high-precision delay/sleep interface in a userland
    program, take a look at the usleep(2) and nanosleep(2) syscalls.

    G'luck,
    Peter

    -- 
    Peter Pentchev	roam@ringlet.net    roam@cnsys.bg    roam@FreeBSD.org
    PGP key:	http://people.FreeBSD.org/~roam/roam.key.asc
    Key fingerprint	FDBA FD79 C26F 3C51 C95E  DF9E ED18 B68D 1619 4553
    I am the meaning of this sentence.
    
    



  • Next message: Dan Nelson: "Re: clock.h"

    Relevant Pages

    • Re: need help while implementing a timer.
      ... Linux on my system doesnot have a timer granularity of 10 ms. ... A few tests on an i386 box with a 2.6.0-test7 kernel verified ... relatively constant if there is light loading on the cpu. ... Calling selectresulted in a 10ms delay Calling nanosleep() ...
      (comp.os.linux.development.apps)
    • Re: need help while implementing a timer.
      ... SO there timers of nano granularity is availbale but as of now i ... grepping the include files for a 2.6.0 kernel shows a ... > relatively constant if there is light loading on the cpu. ... > microseconds, both systems, when no delay was added. ...
      (comp.os.linux.development.apps)
    • Re: [PATCH 1/5] Skip timer works.patch
      ... calibrates the delay wrong because of timing glitches caused by CPU ... transparent to the kernel. ... polling a timer that is supposed to tick properly even in virtualization. ...
      (Linux-Kernel)
    • Re: [PATCH] printk: add halt_delay parameter for printk delay in halt phase
      ... other way to dump kernel messages that time. ... Furthermore the delay is ...     default n ... What do you think removing the Kconfig option, ...
      (Linux-Kernel)
    • Re: PROBLEM: E6850 has an 8+ minute delay during boot
      ... minute delay during boot. ... The problem occurs on the Ubuntu gutsy 2.6.22-14 kernel, ... I am running an SMP kernel currently, ... Calibrating delay using timer specific routine.. ...
      (Linux-Kernel)