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