Nov. 29th, 2014

izard: (Default)
Here is teh code
static unsigned char array[128];
void main()
{
    for (i = 0; i < 64; i++) if ((int)(array + i) % 64 == 63) break;
    lock = (unsigned int*)(array + i);
    for (i = 0; i < 1024; i++) *(lock)++; // prime
    // TSC1
    for (i = 0; i < 1024*8; i++)
    {
       asm volatile (
        "lock xaddl %1, (%0)\n"
        : // no output
        : "r" (lock), "r" (1));
    }
    // TSC2
    printf(" %i\n", (TSC2-TSC1)/1024*8);
}

Normal memory increment never takes more than couple of hundreds nanoseconds. Unless it is a locked cache line split increment. Good catch, obvious reasons.

Profile

izard: (Default)
izard

June 2025

S M T W T F S
1234567
891011121314
15161718192021
22 23242526 2728
2930     

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Jun. 30th, 2025 06:44 am
Powered by Dreamwidth Studios