Re: [linux-audio-dev] MCS: 64 bit timestamps?

New Message Reply About this list Date view Thread view Subject view Author view Other groups

Subject: Re: [linux-audio-dev] MCS: 64 bit timestamps?
From: David Olofson (audiality_AT_swipnet.se)
Date: su loka   17 1999 - 12:12:23 EDT


On Sun, 17 Oct 1999, Paul Barton-Davis wrote:
> the non-atomic 64 bit stuff is more of a problem. i don't have an easy
> answer yet (or rather, i don't have an answer that doesn't involve
> taking a mutex).

You don't need a mutex for a pointer to a struct... But you *do* need
a bunch of structs in a circular buffer to ensure that the pointer a
thread grabs is valid long enough. It's not sexy, and not even fool
proof (some non-RT task can grab the pointer and go to sleep for a
while...), but it's sync free and simple.

----8<---( mcstime.h )-----------------
struct sync_point_t {
        .
        .
        .
};

extern sync_point_t *mcs_sync_point;
--------------------------------->8----

----8<---( engine.c )------------------
#define SYNCSTRUCTS <sensible value>
static int current_struct = 0;
static sync_point_t struct_tab[SYNCSTRUCTS];

sync_point_t *mcs_sync_point;

void update_sync(void)
{
        /* Fill in the new struct... */
        .
        .
        .
        struct_tab[current_struct].blah = ...;

        /* / / Critical: Atomic pointer write. / / */
        mcs_sync_point = &struct_tab[current_struct];
        /* / / / / / / / / / / / / / / / / / / / / */

        if(++current_struct >= SYNCSTRUCTS)
                current_struct = 0;
}
--------------------------------->8----

SYNCSTRUCTS needs to be sync_valid_time / resync_rate for this to be
safe, while soft RT systems and coding style make it impossible to
safely quarantee that the sync_valid_time limit is obeyed...

OTOH, long before that happens, timestamping is already pretty useless
anyway... And, what happens if an structure access collision occurs?
As long as you get a screwed up timestamp, and not a segfault or div
by zero, I'd say it's not a real problem.

//David

 ·A·U·D·I·A·L·I·T·Y· P r o f e s s i o n a l L i n u x A u d i o
- - ------------------------------------------------------------- - -
    ·Rock Solid David Olofson:
    ·Low Latency www.angelfire.com/or/audiality ·Audio Hacker
    ·Plug-Ins audiality_AT_swipnet.se ·Linux Advocate
    ·Open Source ·Singer/Composer


New Message Reply About this list Date view Thread view Subject view Author view Other groups

This archive was generated by hypermail 2b28 : pe maalis 10 2000 - 07:27:59 EST