- Where are the exception-objects allocated? - 1 Update
- std::atomic<T>::is_lock_free() - 17 Updates
- some questions - 2 Updates
- Where are the exception-objects allocated? - 3 Updates
- Polymorphic (abstract) variants - 1 Update
- Baluba - 1 Update
| Udo Steinbach <trashcan@udoline.de>: Nov 15 12:16PM +0100 Am 2019-11-13 um 19:28 schrieb Bonita Montero: > But I'm interested how this is actually implemented. Some years ago I have tested this with g++. Normal malloc(), if this misses, special static memory area, if this misses, normal malloc() --- endless loop. Yes, your found __cxa_allocate_exception(). I am not sure, but I can't remember of calling a user defined handling of this situation. That IS a thing every ordinary developer has to know, James. My only Idea is a handler, so that another part of the program can free(), but that would guarantee nothing. Or to loop and wait as it did. -- Fahrradverkehr in Deutschland: http://radwege.udoline.de/ GPG: A245 F153 0636 6E34 E2F3 E1EB 817A B14D 3E7E 482E |
| Bonita Montero <Bonita.Montero@gmail.com>: Nov 14 10:43AM +0100 > If the hardware has DWCAS, so does C++11... Either the type is lock-free > or not. > The method I used wrt dynamic code was well before C++11. C++ has no notion of DCAS; everything is transparent. |
| Bonita Montero <Bonita.Montero@gmail.com>: Nov 14 11:45AM +0100 > runtime libraries provide to variables of same type. For example it > may depend on how variable of a type is (unavoidably) aligned in > memory if it can be accessed without locks atomically. Lock-free Atomic operations don't depend on the operating-system, the dll-hell (weird idea) or the runtime-libraries. And you can be be sure that the specialized atomics that are lock-free are declared to be properly aligned at the class-definition. Do you want to compete with Melzzzz in expertise-unawareness? |
| Bonita Montero <Bonita.Montero@gmail.com>: Nov 14 01:11PM +0100 >> doesn't make sense for me. > Take a deep look at the following macros: > https://en.cppreference.com/w/c/atomic/ATOMIC_LOCK_FREE_consts Doesn't help with the question why lock-free-ness of basic atomic -datatypes might be determined at runtime since all these macros are evaluated at compile-time. |
| Bonita Montero <Bonita.Montero@gmail.com>: Nov 14 04:57PM +0100 > <http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2427.html#DiscussLockFree> > Why don't you go and participate in standardization if you are better > expert than those dimwits in working group 21. This paper doesn't say why is_lock_free can be evaluated at runtime. |
| Bonita Montero <Bonita.Montero@gmail.com>: Nov 14 05:28PM +0100 > Quote that statement of the paper. Ok, you're right: "The proposal provides run-time lock-free query functions rather than compile-time constants because subsequent implementations of a platform may upgrade locking operations with lock-free operations, so it is common for systems to abstract such facilities behind dynamic libraries, and we wish to leave that possiblility open. Furthermore, we recommend that implementations without hardware atomic support use that technique." But that's rather an abstract and untechnical statement. |
| Bonita Montero <Bonita.Montero@gmail.com>: Nov 14 05:26PM +0100 > That is official paper and it continues to say why lock free query > function was proposed to be dynamic per object for how long it > is archived. Quote that statement of the paper. |
| Bonita Montero <Bonita.Montero@gmail.com>: Nov 14 05:33PM +0100 > The proposal provides lock-free query functions on individual objects rather than whole types to permit unavoidably misaligned atomic variables without penalizing the performance of aligned atomic variables. That's rather stupid since the language says that access to unaligned data has an undefined behaviour. And there's not the least necessitiy in using unaligned atomics. |
| Melzzzzz <Melzzzzz@zzzzz.com>: Nov 14 07:08PM > be sure that the specialized atomics that are lock-free are declared > to be properly aligned at the class-definition. > Do you want to compete with Melzzzz in expertise-unawareness? Do you know what lock free means? -- press any key to continue or any other to quit... U ničemu ja ne uživam kao u svom statusu INVALIDA -- Zli Zec Svi smo svedoci - oko 3 godine intenzivne propagande je dovoljno da jedan narod poludi -- Zli Zec Na divljem zapadu i nije bilo tako puno nasilja, upravo zato jer su svi bili naoruzani. -- Mladen Gogala |
| Bonita Montero <Bonita.Montero@gmail.com>: Nov 14 08:12PM +0100 >> to be properly aligned at the class-definition. >> Do you want to compete with Melzzzz in expertise-unawareness? > Do you know what lock free means? You're the last who knows that. |
| "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com>: Nov 14 01:09PM -0800 On 11/14/2019 1:43 AM, Bonita Montero wrote: >> lock-free or not. >> The method I used wrt dynamic code was well before C++11. > C++ has no notion of DCAS; everything is transparent. C++11 can handle DWCAS. However, DCAS is something different. The DW stands for Double Width, so two _adjacent_ words in contiguous memory. DCAS can operate on two non-adjacent words. If its lock free wrt is_lock_free, well, it should be using cmpxchg8b on, say a 32 bit x86. Or, cmpxchg16b on a 64 bit x86. Itanium had the strange cmp8xchg16. These have some bits in cpuid, iirc. https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-isprocessorfeaturepresent |
| "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com>: Nov 14 01:35PM -0800 On 11/14/2019 11:12 AM, Bonita Montero wrote: >>> Do you want to compete with Melzzzz in expertise-unawareness? >> Do you know what lock free means? > You're the last who knows that. You are quite a character. Watch out Melzzzz, the Cruel Puppet BM is very strange! https://www.thezorklibrary.com/history/cruel_puppet.html CRUEL PUPPET Few creatures are more despised than the cruel puppet, one which uses its power not for good, evil or profit, but simply to hurt people's feelings. Staunch monarchs have been reduced to tears by these merciless shapeshifters; for it attacks by twisting itself into unflattering caricatures of its opponents, accompanied by jeers, rude noises and shocking accusations--which include the recital of nightly personal habits in excruciating detail, accusing its adversary's mother of shocking improprieties, reminding of weight gain, etc. They have also been known to practice existential put downs. "You're so ugly you're probably the creation of an unseen master who is controlling and shaping the world around you. Nothing is real and nothing you do will have any lasting effect on those around you. Welcome to the dark night of your soul" is but one example. More often, however, they just insult your knees. Insulting the cruel puppet in return is futile, for it feeds off of them. Straining to ignore these verbal attacks is the only known defense. Residents of Gurth City were warned during the mid-tenth century to keep away from the Forest of Youth, as it was known home to cruel puppets. During the Great Monster Uprising of the Second Age of Magic, cruel puppets were reported in the following regions: The abandoned Casino of Port Foozle, The Southern Wastes, The Coast Road near Borphee, Pheebor, Forest of Youth, Gurth Woodland Trail, the Lost Castle of Y'Syska, Crab Island, Egreth Castle, The Glass Maze, Bozbarland, Largoneth Castle, and the G.U.E. Tech Training Grounds in the Ethereal Plane of Atrii. Many perched in trees and other high and covert corners, raining handfuls of exploding chestnuts down upon luckless adventurers. |
| "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com>: Nov 14 01:37PM -0800 On 11/14/2019 1:32 PM, Chris M. Thomasson wrote: >>> may depend on how variable of a type is (unavoidably) aligned in >>> memory if it can be accessed without locks atomically. >> Lock-free Atomic operations don't depend on the operating-system, How can you say that? How do you know what the os is doing? |
| "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com>: Nov 14 01:32PM -0800 On 11/14/2019 2:45 AM, Bonita Montero wrote: >> may depend on how variable of a type is (unavoidably) aligned in >> memory if it can be accessed without locks atomically. > Lock-free Atomic operations don't depend on the operating-system, Are you sure about that? Remember that one can implement a pure std c++11 atomic lib using semaphores. Windows has some interesting checks wrt memory violations wrt its lock-free stack. Its all in the OS. |
| "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com>: Nov 14 01:33PM -0800 On 11/14/2019 8:16 AM, Öö Tiib wrote: > That is official paper and it continues to say why lock free query > function was proposed to be dynamic per object for how long it > is archived. BM is JG. am 99.98... percent sure.... |
| "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com>: Nov 14 01:41PM -0800 On 11/14/2019 8:33 AM, Bonita Montero wrote: > That's rather stupid since the language says that access to unaligned > data has an undefined behaviour. And there's not the least necessitiy > in using unaligned atomics. You are JG, right? |
| Bonita Montero <Bonita.Montero@gmail.com>: Nov 15 09:32AM +0100 >> Lock-free Atomic operations don't depend on the operating-system, ^^^^^^^^^^^^^^^^ > Are you sure about that? Remember that one can implement a pure std > c++11 atomic lib using semaphores. ... Wat of the underlined wording above don't you unterstand? |
| Bonita Montero <Bonita.Montero@gmail.com>: Nov 15 09:31AM +0100 >> data has an undefined behaviour. And there's not the least necessitiy >> in using unaligned atomics. > You are JG, right? Tell me of the sense to use non-aligned atomics. |
| Bonita Montero <Bonita.Montero@gmail.com>: Nov 14 05:24PM +0100 I use a vector to store one or two thread-objects which I emplace_back. I later join the threads. I'd rather like to use a array<thread, 2> but an array<> hasn't a dynamic size ore more precise, a size and a capacity. But I need a size since I can't determine if a thread-object has an attached thread (doing threadObj.getId() != thread::id() doesn't work). So there are two alternatives: 1. Is there a prebuilt class somewhere in boost or wherever that has a static internal capacity but a dynamic size? Something like a more advanced array<T, N>? 2. Is there another way to detect if a thread-object has an attached "physical" thread? |
| Bonita Montero <Bonita.Montero@gmail.com>: Nov 14 06:45PM +0100 Sorry, "threadObj.get_id() != thread::id()" worked. I did a "==" instead of a "!=". But the question of the dynamic / static array is still interesting for me. |
| Ian Collins <ian-news@hotmail.com>: Nov 14 08:11PM +1300 On 14/11/2019 08:41, Scott Lurndal wrote: >> h details are far easier to find in such specialized forums, rather than in= >> this one. > Or BM could simply download the compiler sources and figure it out. Rude trolls don't do that.. -- Ian. |
| "Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com>: Nov 14 12:42PM +0100 On 13.11.2019 17:59, Bonita Montero wrote: > allocation might fail? And remember that these objects even have > to live longer than a thread because you might refer to it by > an std::exception_ptr. For string data you can leverage the internal special immutable string class by using `std::runtime_error` or a derived class. It can of course throw when the original exception is created, but after that it's guaranteed that copying does not throw: C++17 §21.8.2/2: "Each standard library class T that derives from class exception shall have a publicly accessible copy constructor and a publicly accessible copy assignment operator that do not exit with an exception." For other data you have to ensure this guarantee yourself. A reasonable approach is to minimize the amount of other data in an exception. - Alf |
| Bonita Montero <Bonita.Montero@gmail.com>: Nov 14 01:07PM +0100 > "Each standard library class T that derives from class exception shall > have a publicly accessible copy constructor and a publicly accessible > copy assignment operator that do not exit with an exception." 1. I'm talking about the storage for the exception-object itself; this isn't allocated by your own code but the rundime-library. 2. I just posted my parallel merge-sort-algorithm. It gathers the exceptions which might occur in the sorting-threads in a single pre-allocated vector of exception_ptr's and moves this vector inside the exception which might be thrown later. If I would provide a copy-costructor or assignment-operator, this vector would be copied and an exception might get thrown. This might occur when you don't catch the exception by reference (I don't see any reason to catch exception-objects by value anyway). So there are good reasons to not to provide both. |
| Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk>: Nov 17 12:22AM On 17/11/2019 00:18, Alf P. Steinbach wrote: >> https://github.com/i42output/neolib/blob/master/include/neolib/plugin_variant.hpp > Polymorphic variants are nice. > Is it possible to sort of factor that out of neoGFX? Hi Alf, neolib is an independent project with no neoGFX dependencies; unlike neoGFX it also has a permissive licence. /Flibble -- "Snakes didn't evolve, instead talking snakes with legs changed into snakes." - Rick C. Hodgin "You won't burn in hell. But be nice anyway." – Ricky Gervais "I see Atheists are fighting and killing each other again, over who doesn't believe in any God the most. Oh, no..wait.. that never happens." – Ricky Gervais "Suppose it's all true, and you walk up to the pearly gates, and are confronted by God," Byrne asked on his show The Meaning of Life. "What will Stephen Fry say to him, her, or it?" "I'd say, bone cancer in children? What's that about?" Fry replied. "How dare you? How dare you create a world to which there is such misery that is not our fault. It's not right, it's utterly, utterly evil." "Why should I respect a capricious, mean-minded, stupid God who creates a world that is so full of injustice and pain. That's what I would say." |
| "Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com>: Nov 17 12:51AM +0100 #include <iostream> template< char c, class Type > struct Mut_t_; template< class Type > struct Mut_t_<'*', Type>{ using T = Type*; }; template< char c, class Type > using Mut_ = typename Mut_t_<c, Type>::T; #define $( c, ... ) Mut_<#c [0], __VA_ARGS__> void foo( const $(*, const char) s ) { std::cout << s << '\n'; } auto main() -> int { foo( "Baluba!" ); } |
| 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.lang.c+++unsubscribe@googlegroups.com. |
No comments:
Post a Comment