2012-07-03 3 views
0

"이 플랫폼에서 64 비트 NoBarrier_Store()가 구현되지 않았습니다." win7에서 vs2005와 함께 tcmalloc을 사용합니다. 내 애플 리케이션에 두 개의 스레드가있다. 하나는 malloc()이고 다른 하나는 free()이다. tcmalloc은 내 앱이 시작될 때이를 출력한다. 디버그 후, _ fun32는 _WIN32,64 비트 NoBarrier_Store()가이 플랫폼에 구현되지 않았습니다.

에서 작동하지 않는다.
// Return a suggested delay in nanoseconds for iteration number "loop" 
static int SuggestedDelayNS(int loop) { 
    // Weak pseudo-random number generator to get some spread between threads 
    // when many are spinning. 
    static base::subtle::Atomic64 rand; 
    uint64 r = base::subtle::NoBarrier_Load(&rand); 
    r = 0x5deece66dLL * r + 0xb; // numbers from nrand48() 
    base::subtle::NoBarrier_Store(&rand, r); 

    r <<= 16; // 48-bit random number now in top 48-bits. 
    if (loop < 0 || loop > 32) { // limit loop to 0..32 
    loop = 32; 
    } 
    // loop>>3 cannot exceed 4 because loop cannot exceed 32. 
    // Select top 20..24 bits of lower 48 bits, 
    // giving approximately 0ms to 16ms. 
    // Mean is exponential in loop for first 32 iterations, then 8ms. 
    // The futex path multiplies this by 16, since we expect explicit wakeups 
    // almost always on that path. 
    return r >> (44 - (loop >> 3)); 
} 

나는 이것을 win32에서 피하는 방법을 알고 싶다. 매우 감사합니다.

답변

1

메모리 장벽없이 원자로드 및 저장을 사용하는 것으로 보입니다. 일부 멀티 CPU 시스템에서이 작업을 조금 더 빠르게 수행 할 수 있습니다.

x86에서는 이러한 유형의 작업이 없습니다. 로드 및 저장은 시스템의 다른 코어에서 항상 볼 수 있습니다. 캐시 동기화는 하드웨어에서 구현되며 프로그램에서 제어 할 수 없습니다.

아마도 사용 된 Atomic 라이브러리에 NoBarrier 접두사없이로드 및 저장 작업이 있습니까? 그 대신에 사용하십시오.

+0

네, 맞습니다. tcmalloc은 이제 svn을 업데이트했습니다. 감사! – user1497861

관련 문제