izard: (Default)
[personal profile] izard
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.
This account has disabled anonymous posting.
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting

Profile

izard: (Default)
izard

November 2025

S M T W T F S
       1
2345678
910 1112131415
1617 1819202122
23242526272829
30      

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Mar. 10th, 2026 01:18 pm
Powered by Dreamwidth Studios