Replace critical section with boost::detail::spinlock cause dead lock on windows [closed] - c++

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
My platform is vs2010 win2003 server, I have an application working well. There is an integer protected by a critical section, when I modify and use boost::detail::spinlock instead then it goes to dead lock.

It's boost::detail::spinlock. That means it's intended for internal use only. If you want portable replacement for critical sections, use boost::mutex from Boost.Thread.
It's boost::detail::spinlock. Spinlocks usually busy-wait, which makes them faster, but usable only under tightly controlled conditions.
Boost 1.53 (the latest release) finally got Boost.Atomic, which is a portable (and C++11 compatible) replacement for interlocked operations.

Related

What are C++11 atomic classes? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I would like to know what are "C++11 atomic classes" that GCC-4.7.2 talks of in the 4.7 changelog. I have tried Googling but didn't get any useful information on this. Does this mean that all operations are atomic so the class is thread-safe and operations are linearizable?
To quote from this reference:
The atomic library provides components for fine-grained atomic operations allowing for lockless concurrent programming.
So in short yes all operations on an atomic variable are, well, atomic, and therefore threadsafe.

List of things that cant be portably(Win/Linux) implemented with C++11 +Boost? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
as a zealous fan of portable C++ :) I recommended to my boss to try to implement one project with C++11 and Boost(Instead of relying on #if and OS specific stuff), and Im confident we can do it with C++11 + Boost.
Now (as a fan of generalizing:) ) Im wondering what are the things that can't be done portably with c++11 + boost.
Afaik std::atomic removes need for Interlocked*, boost has ASIO for sockets, std and boos have threads and mutexes, boost has filesystem...
EDIT: ignore reality of partial support of C++11, lets assume total C++11 compiler support.
Actually this depends on the compilers you use un Windows and in Linux.
You can check a support matrix here. With it, you will exactly know which features you will be able to use, depending on your compilers in Linux and Windows.

Readers–writer lock Multithreading Scenario? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I have read a few links about Readers–writer lock. I had few doubts.
In case the system has to be designed for Multiple reads and single write ,and write should have priority.
In case the system has to be designed for multiple reads and multiple write
So should we be implementing a semaphore for multiple read and a mutex for multiple write? or when do i use a critical section?
Also,Does it depend on the operating system? (does it differ in case of Unix and Windows)?

Sequential and running in one thread time difference c++ [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
Here is my source code for testing multithread performance in C++. Please tell me why is time about 5x smaller for ONE thread running(WaitForMultipleObject()) then first sequential performance. I expect almost same result for sequential performance and running with only one thread. Thanks
http://pastebin.com/EeJ5qW03
OS will decide when will your thread start running and it will also decide if there's a need for dispatching, perhaps. Add to that, it also has to create a separate stack for your thread, perhaps.
Read about the overhead on thread creation. All in all, the overhead is system specific.

Problem with Atomic operations on a intel XScale(ARM) processor - XScale-IXP42x Family - c++ [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 11 years ago.
We are facing a possible problem on ARM processor machine.
We have done an implementation for smart pointers,which involves atomic operation for keeping track of the references.
We are getting crashes for that.
Is there a possible problem with atomic operations on ARM processor?
It's possible, but it's way more likely that there is a bug in your code.
Perhaps you should post some code.