mirror of https://github.com/PCSX2/pcsx2.git
pcsx2:linux: disable thread timing information. It seems to work only with eglibc (debian/ubuntu)
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@4908 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
parent
537dbcc58c
commit
0f354b7bcd
|
@ -55,6 +55,12 @@ __forceinline void Threading::DisableHiresScheduler()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// pthread_getcpuclockid causes a segmentation fault on Mandriva/Mageia.
|
||||||
|
// It seems to impact fedora users so I bet it is an issue with glic (the library was
|
||||||
|
// replaced by eglibc on Debian/Ubuntu)
|
||||||
|
// So for the moment I disable this feature -- Gregory
|
||||||
|
#define LNX_DISABLE_THREAD_TIME 1
|
||||||
|
|
||||||
u64 Threading::GetThreadTicksPerSecond()
|
u64 Threading::GetThreadTicksPerSecond()
|
||||||
{
|
{
|
||||||
// Note the value is not correct but I'm not sure we can do better because
|
// Note the value is not correct but I'm not sure we can do better because
|
||||||
|
@ -67,8 +73,12 @@ u64 Threading::GetThreadTicksPerSecond()
|
||||||
The actual frequency is hidden from userspace, deliberately. Indeed, some systems
|
The actual frequency is hidden from userspace, deliberately. Indeed, some systems
|
||||||
use dynamic ticks or "tickless" systems, so there aren't really any at all.
|
use dynamic ticks or "tickless" systems, so there aren't really any at all.
|
||||||
*/
|
*/
|
||||||
|
#ifndef LNX_DISABLE_THREAD_TIME
|
||||||
u32 hertz = sysconf(_SC_CLK_TCK);
|
u32 hertz = sysconf(_SC_CLK_TCK);
|
||||||
return hertz;
|
return hertz;
|
||||||
|
#else
|
||||||
|
return 0;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
u64 Threading::GetThreadCpuTime()
|
u64 Threading::GetThreadCpuTime()
|
||||||
|
@ -77,16 +87,20 @@ u64 Threading::GetThreadCpuTime()
|
||||||
// thread has used on the CPU (scaled by the value returned by GetThreadTicksPerSecond(),
|
// thread has used on the CPU (scaled by the value returned by GetThreadTicksPerSecond(),
|
||||||
// which typically would be an OS-provided scalar or some sort).
|
// which typically would be an OS-provided scalar or some sort).
|
||||||
|
|
||||||
|
#ifndef LNX_DISABLE_THREAD_TIME
|
||||||
clockid_t cid;
|
clockid_t cid;
|
||||||
int err = pthread_getcpuclockid(pthread_self(), &cid);
|
int err = pthread_getcpuclockid(pthread_self(), &cid);
|
||||||
if (err) return 0;
|
if (err) return 0;
|
||||||
|
|
||||||
struct timespec ts;
|
struct timespec ts;
|
||||||
clock_gettime(cid, &ts);
|
err = clock_gettime(cid, &ts);
|
||||||
|
if (err) return 0;
|
||||||
unsigned long timeJiff = (ts.tv_sec*1e6 + ts.tv_nsec / 1000)/1e6 * GetThreadTicksPerSecond();
|
unsigned long timeJiff = (ts.tv_sec*1e6 + ts.tv_nsec / 1000)/1e6 * GetThreadTicksPerSecond();
|
||||||
|
|
||||||
return timeJiff;
|
return timeJiff;
|
||||||
|
#else
|
||||||
|
return 0;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
u64 Threading::pxThread::GetCpuTime() const
|
u64 Threading::pxThread::GetCpuTime() const
|
||||||
|
@ -96,16 +110,20 @@ u64 Threading::pxThread::GetCpuTime() const
|
||||||
// thread has used on the CPU (scaled by the value returned by GetThreadTicksPerSecond(),
|
// thread has used on the CPU (scaled by the value returned by GetThreadTicksPerSecond(),
|
||||||
// which typically would be an OS-provided scalar or some sort).
|
// which typically would be an OS-provided scalar or some sort).
|
||||||
|
|
||||||
|
#ifndef LNX_DISABLE_THREAD_TIME
|
||||||
clockid_t cid;
|
clockid_t cid;
|
||||||
int err = pthread_getcpuclockid(m_native_id, &cid);
|
int err = pthread_getcpuclockid(m_native_id, &cid);
|
||||||
if (err) return 0;
|
if (err) return 0;
|
||||||
|
|
||||||
struct timespec ts;
|
struct timespec ts;
|
||||||
clock_gettime(cid, &ts);
|
err = clock_gettime(cid, &ts);
|
||||||
|
if (err) return 0;
|
||||||
unsigned long timeJiff = (ts.tv_sec*1e6 + ts.tv_nsec / 1000)/1e6 * GetThreadTicksPerSecond();
|
unsigned long timeJiff = (ts.tv_sec*1e6 + ts.tv_nsec / 1000)/1e6 * GetThreadTicksPerSecond();
|
||||||
|
|
||||||
return timeJiff;
|
return timeJiff;
|
||||||
|
#else
|
||||||
|
return 0;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void Threading::pxThread::_platform_specific_OnStartInThread()
|
void Threading::pxThread::_platform_specific_OnStartInThread()
|
||||||
|
|
Loading…
Reference in New Issue