Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cache line #114

Open
ytgui opened this issue Apr 18, 2020 · 2 comments
Open

cache line #114

ytgui opened this issue Apr 18, 2020 · 2 comments

Comments

@ytgui
Copy link
Owner

ytgui commented Apr 18, 2020

No description provided.

@ytgui
Copy link
Owner Author

ytgui commented Apr 18, 2020

array vs vector

false sharing

https://software.intel.com/en-us/articles/avoiding-and-identifying-false-sharing-among-threads

row major and slide window size

spinlock

https://zhuanlan.zhihu.com/p/133445693

MESI protocol

@ytgui
Copy link
Owner Author

ytgui commented Apr 20, 2020

Spinlock

struct spinlock {
        int locked;
};
void spin_lock(struct spinlock *lock)
{
    // test_and_set: set flag to `1` and return old value
    // if the func returns 0, flag 0->1, means get the lock
    while (atomic_test_and_set(&lock->locked));
}
void spin_lock(struct spinlock *lock)
{
    // `test_and_set` always write to cache line, which cause performance issue
    // read only op before write, reduce cache line flush
    while (!lock->locked && atomic_test_and_set(&lock->locked));
}
void spin_unlock(struct spinlock *lock)
{
    lock->locked = 0;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant