Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old September 1st, 2008, 08:35 AM
chumly96@hotmail.com
Guest
 
Posts: n/a
Default Timer Cache Library help

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

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles