<time .h> in the standard,Why?

Discussion in 'C Programming' started by sathyashrayan, Feb 4, 2004.

  1. Friends,
    As I was going through the standard draft of C (C99) I come across
    the header file <time.h>. I wonder why the standard has included the
    header file since it depends on the hardware that we work with. If
    somebody wants to access the time of the system then he has to use the
    interrupt 1A in the real mode or access the timer chip (port id
    70-70h) pmode but that is off-topic in this group.
    I concluded that it is because of the running-time analysis that is
    needed for a program.
    (Correct me if I am wrong)
    If the standard can include a *portable* way of accessing a hardware
    why not the standard include for other routines also such as keyboard,
    graphic device drivers, hard disk etc.
    sathyashrayan, Feb 4, 2004
    #1
    1. Advertising

  2. sathyashrayan

    Zhi Liu Guest

    hi,
    The design of C is not to hide the hardware but to provide a general way
    of programming on different platforms.
    C runs on real system not the virtual machine.So almost every action has
    something to do with the hardware. Standard I/O, setjmp, math lib....
    In your question, the time library may be support by the hardware or the
    OS or anything else, depending on the compiler and system architecture.
    There is no *protable* way to access hardware, but *portable* software
    interface implemented by compiler and libc.


    "sathyashrayan" <> ????
    news:...
    > Friends,
    > As I was going through the standard draft of C (C99) I come across
    > the header file <time.h>. I wonder why the standard has included the
    > header file since it depends on the hardware that we work with. If
    > somebody wants to access the time of the system then he has to use the
    > interrupt 1A in the real mode or access the timer chip (port id
    > 70-70h) pmode but that is off-topic in this group.
    > I concluded that it is because of the running-time analysis that is
    > needed for a program.
    > (Correct me if I am wrong)
    > If the standard can include a *portable* way of accessing a hardware
    > why not the standard include for other routines also such as keyboard,
    > graphic device drivers, hard disk etc.
    Zhi Liu, Feb 4, 2004
    #2
    1. Advertising

  3. sathyashrayan

    Jack Klein Guest

    On 3 Feb 2004 18:52:16 -0800,
    (sathyashrayan) wrote in comp.lang.c:

    > Friends,
    > As I was going through the standard draft of C (C99) I come across
    > the header file <time.h>. I wonder why the standard has included the
    > header file since it depends on the hardware that we work with. If


    Do you think so? Why do you think so? Do you think there is only one
    hardware computer platform in the entire universe?

    > somebody wants to access the time of the system then he has to use the
    > interrupt 1A in the real mode or access the timer chip (port id


    There are many, many computers out there that don't have an "interrupt
    1A", or "real mode".

    > 70-70h) pmode but that is off-topic in this group.


    Or "port id" anything, or "pmode".

    None of these things on any Macintosh or SparcStation, just to name a
    few.

    > I concluded that it is because of the running-time analysis that is
    > needed for a program.
    > (Correct me if I am wrong)


    You are wrong.

    > If the standard can include a *portable* way of accessing a hardware
    > why not the standard include for other routines also such as keyboard,
    > graphic device drivers, hard disk etc.


    Why do you think that this has anything to do with accessing hardware,
    let alone specific hardware in one specific type of computer? Opening
    and reading a file does not access hardware, at least not as far as C
    is concerned. The underlying platform how to connect that stream to
    some device or other.

    On many networks, all computers update their notion of real-world time
    from a designated server. There are time servers on the Internet as
    well. Computers with no hardware time-of-day clock could get their
    time from them.

    Nor does the existence of the function time() even require that all
    computers be able to provide this value. An implementation merely
    returns time_t(-1) if it cannot.

    Your horizon of both computer hardware and computer programming are
    far too narrow, almost tragically so.

    --
    Jack Klein
    Home: http://JK-Technology.Com
    FAQs for
    comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
    comp.lang.c++ http://www.parashift.com/c -faq-lite/
    alt.comp.lang.learn.c-c++
    http://www.contrib.andrew.cmu.edu/~ajo/docs/FAQ-acllc.html
    Jack Klein, Feb 4, 2004
    #3
  4. On Tue, 3 Feb 2004, sathyashrayan wrote:

    > Friends,
    > As I was going through the standard draft of C (C99) I come across
    > the header file <time.h>. I wonder why the standard has included the
    > header file since it depends on the hardware that we work with. If
    > somebody wants to access the time of the system then he has to use the
    > interrupt 1A in the real mode or access the timer chip (port id
    > 70-70h) pmode but that is off-topic in this group.
    > I concluded that it is because of the running-time analysis that is
    > needed for a program.
    > (Correct me if I am wrong)


    Consider yourself corrected. The time.h header files is there because
    there is a standard set of functions associated with time and clocks. This
    is nothing new to the C standard.

    > If the standard can include a *portable* way of accessing a hardware
    > why not the standard include for other routines also such as keyboard,
    > graphic device drivers, hard disk etc.


    If I take a moment and think about it, I am hard pressed to thing of a
    system that does not have some sort of clock or timer on it. The standard
    has allowed for systems that don't have a clock but I believe the norm is
    for a system to have a clock.

    I'm looking at four development systems on my desk that have no keyboard,
    no graphics and no hard drive support. Many of the systems I work with are
    like this. When I do a printf the standard output is to a memory buffer
    and a signal pin to let the host computer know there is data in the C I/O
    buffer ready for retrieval. My development environment retrieves the data
    from the target computer and displays it on the host computer.

    I have no need for graphic drivers or hard drive support. There is an
    entire world of development out there that is very different from Windows,
    UNIX and MacOS.

    NOTE: there are libraries, like curses, that are supported by many
    platforms. They attempt to do for displays what time.h does for
    clocks/timers.

    --
    Send e-mail to: darrell at cs dot toronto dot edu
    Don't send e-mail to
    Darrell Grainger, Feb 4, 2004
    #4
  5. sathyashrayan

    Dan Pop Guest

    In <> (sathyashrayan) writes:

    > As I was going through the standard draft of C (C99) I come across
    >the header file <time.h>. I wonder why the standard has included the
    >header file since it depends on the hardware that we work with.


    That's precisely why it was included in the standard. <time.h> is no
    different from <stdio.h> from this point of view: both hide the
    hardware/OS specific details and provide an implementation-neutral
    interface to the application programmer.

    >If
    >somebody wants to access the time of the system then he has to use the
    >interrupt 1A in the real mode or access the timer chip (port id
    >70-70h) pmode but that is off-topic in this group.


    And completely useless to people who don't program on PC hardware, as
    well as to people who do program on PC hardware, but whose OS doesn't
    allow direct access to the hardware ports.

    While <time.h> works for everybody, the same way, as long as the
    underlying hardware can keep track of the wall clock time.

    Dan
    --
    Dan Pop
    DESY Zeuthen, RZ group
    Email:
    Dan Pop, Feb 4, 2004
    #5
  6. Zhi Liu wrote:

    > hi,
    > The design of C is not to hide the hardware but to provide a general way
    > of programming on different platforms.
    > C runs on real system not the virtual machine.So almost every action has
    > something to do with the hardware. Standard I/O, setjmp, math lib....
    > In your question, the time library may be support by the hardware or the
    > OS or anything else, depending on the compiler and system architecture.
    > There is no *protable* way to access hardware, but *portable* software
    > interface implemented by compiler and libc.


    This is correct, but top-posting like you just did is considered rude.

    Do as I'm doing now, and as most people here do, and put your reply
    /below/ the text you are replying to. It makes it much, much easier for
    people to follow the thread of the conversation.

    So, to put it briefly, you could really make a big hit here (in a good
    way :) ) if you just put your text below what you are replying to.

    Thanks.

    >
    >
    > "sathyashrayan" <> ????
    > news:...
    >
    >>Friends,
    >> As I was going through the standard draft of C (C99) I come across
    >>the header file <time.h>. I wonder why the standard has included the
    >>header file since it depends on the hardware that we work with. If
    >>somebody wants to access the time of the system then he has to use the
    >>interrupt 1A in the real mode or access the timer chip (port id
    >>70-70h) pmode but that is off-topic in this group.
    >> I concluded that it is because of the running-time analysis that is
    >>needed for a program.
    >>(Correct me if I am wrong)
    >>If the standard can include a *portable* way of accessing a hardware
    >>why not the standard include for other routines also such as keyboard,
    >>graphic device drivers, hard disk etc.

    >
    >
    >
    >



    --
    My address is yvoregnevna gjragl-guerr gjb-gubhfnaq guerr ng lnubb qbg pbz
    Note: Rot13 and convert spelled-out numbers to numerical equivalents.
    August Derleth, Feb 5, 2004
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. steve.leach

    How standard is the standard library?

    steve.leach, Apr 18, 2005, in forum: Python
    Replies:
    1
    Views:
    388
    Christos TZOTZIOY Georgiou
    Apr 18, 2005
  2. funkyj
    Replies:
    5
    Views:
    1,122
    funkyj
    Jan 20, 2006
  3. Mr. SweatyFinger

    why why why why why

    Mr. SweatyFinger, Nov 28, 2006, in forum: ASP .Net
    Replies:
    4
    Views:
    875
    Mark Rae
    Dec 21, 2006
  4. Mr. SweatyFinger
    Replies:
    2
    Views:
    1,804
    Smokey Grindel
    Dec 2, 2006
  5. flamesrock
    Replies:
    8
    Views:
    449
    Hendrik van Rooyen
    Nov 24, 2006
Loading...

Share This Page