| Dmitry Knyaginin <knyaginin@gmail.com>: Apr 01 10:36PM -0700 Please check out my algorithm unbounded SPSC (wait free?) queue. This implementation is wait free? I tested this code on os x, windows, ubuntu. Everywhere works! ThreadSanitizer detect data race. C++ code http://pastebin.com/fWYjhyyv |
| sp9804@butternut.contek.com (Douglas Wells (USENET)): Apr 01 07:05PM (I'm retaining the three-year old original article.) In article <d0f72c4d-f70c-440e-aea1-173275458910@googlegroups.com>, >Is it safe to use this approach? It seems working with simple UT. But I >can not foresee its risk. >Thanks a lot. No, not according to the rules established by the earlier poster: >>I can't use standard thread local storage or implement it by >>myself with mutexes because these functions should not be >>called from a signal hanlder. You're using the function pthread_setspecific in a signal handler. This is not allowed by POSIX. (And I believe that Linux just follows POSIX in this regard.) There are only a very few functions that you are allowed to execute in a signal handler. Look up the concept "async-signal-safe." You might start in section "2.4.3 Signal Actions" of <http://pubs.opengroup.org/onlinepubs/9699919799/functions/V2_chap02.html#tag_15_04_04>. It's not at all clear that there is a way to solve this problem in general. Here are a few suggestions: - Your current code is likely (but not guaranteed) to work on many current platforms, including Linux. You could just live with that restriction. - If your rate of thread creation is low, you might be able to create a static, shared list of task-id to storage pointer associations (i.e., reimplement pthread's thread-specific storage). pthread_self() IS on the list of routines allowed to be used in a signal handler. But, the maintenance of this list will be complicated and require lots of use of atomic-variables in order to comply with POSIX. - It's possible that the thread-storage mechanism in C11 and C++11 can be used for this. The standard is not clear to me. Some sections hint that it might be supported; other hint that it might not. I don't know of an interpretation on this. Good luck, - dmw -- Douglas Wells . Connection Technologies . Internet: -sp201504- -at- -gmail.com- . |
| bleachbot <bleachbot@httrack.com>: Apr 01 04:00PM +0200 |
| Ramine <ramine@1.1>: Apr 01 10:03AM -0700 Hello, I want to share with you this beautiful song... It's now or never - Elvis Presley https://www.youtube.com/watch?v=qmjdxxAnsB4 Thank you, Amine Moulay Ramdane. |
| You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page. To unsubscribe from this group and stop receiving emails from it send an email to comp.programming.threads+unsubscribe@googlegroups.com. |
No comments:
Post a Comment