Connecting Tech Pros Worldwide Help | Site Map

Timer Cache Library help

  #1  
Old September 1st, 2008, 08:35 AM
chumly96@hotmail.com
Guest
 
Posts: n/a
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");
}
}
  #2  
Old September 1st, 2008, 02:35 PM
Kenny McCormack
Guest
 
Posts: n/a

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...

  #3  
Old September 1st, 2008, 02:45 PM
Sjoerd
Guest
 
Posts: n/a

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
ASP.NET Ajax: ScriptResource.axd is being invoked 12 times per each aspx page request! Max2006 answers 3 September 21st, 2007 12:35 PM
Is this standard c++... Chris Thomasson answers 22 March 5th, 2007 04:55 AM