Google
 
Webnews.only-4-geeks.com
Interesting places
news.only-4-geeks.com Forum Index » C

Timer Cache Library help

 
Jump to:  
 
Guest
PostPosted: Mon Sep 01, 2008 5:35 am    Post subject: 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");
}
}
 

 
Sjoerd
PostPosted: Mon Sep 01, 2008 11:40 am    Post subject: 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.
 

 
Kenny McCormack
PostPosted: Mon Sep 01, 2008 1:33 pm    Post subject: Re: Timer Cache Library help
       
In article <FWMuk.138808$nD.136033@pd7urf1no>, <chumly96@hotmail.com> wrote:
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...
 

Page 1 of 1 .:.

Google
 
Webnews.only-4-geeks.com

Windows Update | C++ | C | PHP | JavaScript | Photoshop | Programming | Windows 2000 | Python | Windows XP | Object | Flash | Flash - ActionScript | Paint Shop Pro | Excel | PowerPoint | Access | Word | Windows 98 | Internet Explorer 6.0 | CorelDraw12 | Java | XML | asm x86 | Linux Mandrake | Linux RedHat | Outlook |  | news from newsgroups |_ | s

Web Templates

Awesome Website Templates ©

Sale konferencyjne Diety Suknie Ślubne Wrocław projekty domów parterowych mieszkanie Poznań