Re: [HACKERS] spin locks - Mailing list pgsql-hackers

From Jordan Henderson
Subject Re: [HACKERS] spin locks
Date
Msg-id 199802161421.JAA03346@jaguar.ccia.com
Whole thread Raw
In response to Re: [HACKERS] spin locks  (The Hermit Hacker <scrappy@hub.org>)
List pgsql-hackers
Folks,

On the thread in regards to spinlocks and multiple CPU's.
The line of thought appeared to be select a compile
time option to determine behavior, and whether to yield or not.

I am thinking that if it comes to having alternate code, the
system should be able to make the determination at runtime,
not compile time. I don't know if all of the platforms supported
have a version of the sysinfo utility, but here is how, at runtime
it gets the number of CPUS available:

**** EXCERPTED FROM SYSINFO SOURCE 3.3.1 ****
/*
 * Use sysconf() to find number of CPU's.
 */
extern char *GetNumCpuSysconf()
{
    int                Num = -1;
    static char               *NumStr = NULL;

    if (NumStr)
    return(NumStr);

#if    defined(_SC_NPROCESSORS_CONF)
    Num = (int) sysconf(_SC_NPROCESSORS_CONF);
    if (Num >= 0) {
    NumStr = itoa(Num);
    if (NumStr)
        NumStr = strdup(NumStr);
    }
#endif    /* _SC_NPROCESSORS_CONF */

    return(NumStr);
}

What I would propose, if the decision is made to yield,
that at initialization time, the number of CPU's available
are determined, and a flag set, or, an indirect jump
changed. This would allow the software to have both
personalities, depending on which system it found it
self running on.

Thoughts?
Jordan Henderson


pgsql-hackers by date:

Previous
From: sferac@bo.nettuno.it
Date:
Subject: Re: [BUGS] agregate function sum error
Next
From: "Kent S. Gordon"
Date:
Subject: Re: DB logging (was: Problem with the numbers I reported yesterday)