Re: function for clockticks since 1980?
- From: Ben Bacarisse <ben.usenet@xxxxxxxxx>
- Date: Sun, 29 Jul 2007 01:58:17 +0100
nsa.usa@xxxxxxxxx writes:
Hi,
I used to use a function in other languages (TP or asm don't remember)
where I could get number of clockticks since 1980. Is there a similar
function in C? I don't seem to find it.
I need to seed the random generator and since it's a web-server app, I
can't seed with the date/time because the resolution is not great
enough. If the app runs twice in the same second (or millisecond or
whatever the resolution is) then the random generator will be seeded
with the same value! not good. Also don't want to use clockticks
processor has used so far to run the program. It seems to me this
function of ticks since 1980 is what I need, or another guranteed
incremental value.
The only function that comes close in standard C is 'time' about which
the standard says:
#include <time.h>
time_t time(time_t *timer);
The time function determines the current calendar time. The
encoding of the value is unspecified.
so you can't rely on much variability there (it *may* be fine, but the
solution would not be portable).
Since there is not ideal portable solution, your best bet may well be
to accept that go fully platform dependent. A small 'get_random_seed'
function will be a couple of lines long and can be written easily for
(reasonable) platform on which a web application might run. Post in a
newsgroup for your which every platform you are currently using for
ideas about getting a good random seed.
--
Ben.
.
- Follow-Ups:
- Re: function for clockticks since 1980?
- From: Ben Pfaff
- Re: function for clockticks since 1980?
- From: nsa . usa
- Re: function for clockticks since 1980?
- References:
- function for clockticks since 1980?
- From: nsa . usa
- function for clockticks since 1980?
- Prev by Date: Re: The chart of comp.lang.c
- Next by Date: Re: The chart of comp.lang.c
- Previous by thread: Re: function for clockticks since 1980?
- Next by thread: Re: function for clockticks since 1980?
- Index(es):
Relevant Pages
|