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

Create Spinlock Class #213

Open
Behemyth opened this issue Aug 16, 2018 · 0 comments
Open

Create Spinlock Class #213

Behemyth opened this issue Aug 16, 2018 · 0 comments
Labels
Enhancement The purpose of this issue is improvement

Comments

@Behemyth
Copy link
Member

Behemyth commented Aug 16, 2018

If you look in Soul Engine\Source\Parallelism\Fiber\SchedulerAlgorithm.h you will find on line 57 boost::fibers::detail::spinlock. Essentially, when many threads try to access the localQueues_ the spin-lock only allows one thread at a time. If you used a mutex like std::mutex the thread might give control to another thread. This is really bad as we would be letting the operating system wrest control from our carefully optimized program! So, for the few cycles needed to access localQueues_ we use a spin-lock. The boost spin-lock is sufficient, but we would love to remove the boost dependency someday. Implement a modern spin-lock class and place it somewhere like Soul Engine\Source\Parallelism\Thread\Spinlock.h/.cpp

Some helpful links:
https://stackoverflow.com/questions/5869825/when-should-one-use-a-spinlock-instead-of-mutex
https://www.boost.org/doc/libs/1_68_0/libs/fiber/doc/html/index.html
https://github.com/boostorg/fiber

@Behemyth Behemyth added Enhancement The purpose of this issue is improvement Algorithm labels Aug 16, 2018
@Behemyth Behemyth changed the title SchedulerAlgorithm Improvements Create Spinlock Class Sep 10, 2018
@Behemyth Behemyth changed the title Create Spinlock Class Create Spinlock Class Sep 10, 2018
@Behemyth Behemyth removed the C++ label Mar 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement The purpose of this issue is improvement
Projects
None yet
Development

No branches or pull requests

2 participants