Connecting Tech Pros Worldwide Forums | Help | Site Map

Timer Cache Library help

chumly96@hotmail.com
Guest
 
Posts: n/a
#1: Sep 1 '08
Hi All,
I need some help writing a library for a fedora box.
What I need to do is intercept timer calls, and cache the results that are
within 1ms.
eg: first call, get time. Second call, check if its within 1ms, if so, then
return stored time, else call gettime.

I have an example of such a function for solarice, but I need to have tis
built for fedora.
Could someone write this up for me?
thanks so much!
Chumly


Example:
#include <sys/types.h>
#include <time.h>
#include <stdio.h>
#include <dlfcn.h>

/* time in nanoseconds to cache the time system call */
#define DELTA 1000000 /* 1 millisecond */

static time_t (*func) (time_t *);

time_t time(time_t *tloc)
{
static time_t global = 0;
static hrtime_t old = 0;

hrtime_t new = gethrtime();
if(new - old DELTA ){
global = func(tloc);
old = new;
}
return global;
}

#pragma init (init_func)
void init_func()
{
func = (time_t (*) (time_t *)) dlsym (RTLD_NEXT, "time");
if (!func)
{
fprintf(stderr, "Error initializing library\n");
}
}

Kenny McCormack
Guest
 
Posts: n/a
#2: Sep 1 '08

re: Timer Cache Library help


In article <FWMuk.138808$nD.136033@pd7urf1no>, <chumly96@hotmail.comwrote:
Quote:
>Hi All,
>I need some help writing a library for a fedora box.
I didn't know that hat boxes now contain microprocessors.

The things they're doing wtih computers nowadays...

Sjoerd
Guest
 
Posts: n/a
#3: Sep 1 '08

re: Timer Cache Library help


On Mon, 01 Sep 2008 07:35:01 +0000, chumly96 wrote:
Quote:
Could someone write this up for me?
People in newsgroups may help you, but they will not typically do your
work for you. You may want to describe what you have already tried and
why your example failed.
Closed Thread