- C++ MemPool for real-time systems - 2 Updates
- Read again, i correct - 2 Updates
- About my MemPool and real-time systems... - 1 Update
- Possibly, taking advantage of blocking... - 1 Update
- Initialization of static non-const and general purpose class members - 3 Updates
- Sequencing - 5 Updates
- Static constructors and destructors? - 2 Updates
- The Lord calls out to you for repentance, salvation - 3 Updates
- Aliasing a class - 1 Update
- Unable to push back objects to a static vector in the constructor - 1 Update
- [PPP2] page 360: The else branch will never be reached - 3 Updates
Ramine <toto@toto.net>: Mar 13 06:26PM -0400 Hello, C++ MemPool for real-time systems Description: Real-Time Memory Management In C++, memory management is normally performed using new,delete etc. The run-time system's heap offers great flexibility and efficiency, but it cannot fulfil real-time requirements. The run-time requirements are non-deterministic. In addition, they may require blocking task switches, which makes them unusable for interrupt handlers. MemPool uses templates and offers memory management with real-time capabilities through Memory Pools. A Memory Pool is an isolated heap with data buffers as objects of equal size. Any number of memory pools can exist simultaneously. A pool is initialized once and allocated a certain number of buffers as objects. Thereafter, buffers as objects can be allocated and deallocated from the pool under real-time conditions. How to use it? The parameters of the constructor are: The first parameter is the number of items and the second parameter is a boolean parameter that will tell MemPool to grow or not, if it is set to true it will grow, set it to false for real-time systems, if you don't pass any parameter, the number of items will be set to 200 and the MemPool will not grow and thus it will be set for real-time systems. The New() method returns a reference to the object. The Return() method returns the reference to the object to the stack. Please look at the test.cpp example to learn how to use MemPool. Language: GNU C++ and Visual C++ and C++Builder You can download my MemPool for real-time systems from: https://sites.google.com/site/aminer68/c-mempool-for-real-time-systems Thank you, Amine Mouay Ramdane. |
"Rick C. Hodgin" <rick.c.hodgin@gmail.com>: Mar 13 04:30PM -0700 Ramine, Thank you for your sharing attitude with regards to your software algorithms. It reveals much about your caring for other people. Thank you, Rick C. Hodgin |
Ramine <toto@toto.net>: Mar 13 07:05PM -0400 Hello......... About my MemPool and real-time systems... I am a white arab, and i am a computer programmer and i have a diploma in Microelectronics and informatics and i have also studied and succeeded one year of mathematics at university.. I am actually working on real-time OSs and systems such as VxWorks and QNX and One Time RTOS-32, and as you have seen me i have first wrote my MemPool for real-time systems for Delphi that works on One Time RTOS-32 that is a real-time OS, and now i have ported my MemPool for real-time systems to C++, please look at how is more efficient my C++ code, next step i will port my Threadpool for C++ and Delphi to real-time systems and i will port my scalale AMLock that is a scalable lock dor C++ and Delphi to real-time systems, and i will port my SemaMonitor for C++ and Delphi to real-time systems. And here is also some of my inventions, because i am also an inventor: You can download and read about my C++ synchronization objects library for Windows and Linux from here: https://sites.google.com/site/aminer68/c-synchronization-objects-library Thank you, Amine Moulay Ramdane. |
Real Troll <real.troll@trolls.com>: Mar 13 07:30PM -0400 On 13/03/2017 23:05, Ramine wrote: > I am a white arab, and i am a computer programmer and i have a diploma > in Microelectronics and informatics and i have also studied and > succeeded one year of mathematics at university.. Very useful. > And here is also some of my inventions, because i am also an inventor: > You can download and read about my C++ synchronization objects library > for Windows and Linux from here: Can you release something for C# as this language has become very popular because many people have started using it in their ASP projects. |
Ramine <toto@toto.net>: Mar 13 06:58PM -0400 Hello......... About my MemPool and real-time systems... I am a white arab, and i am a computer programmer and i have a diploma in Microelectronics and informatics and i have also studied and succeeded one year of mathematics at university.. I am actually working on real-time OSs and systems such us VxWorks and QNX and One Time RTOS-32, and as you have seen me i have first wrote my MemPool for real-time systems for Delphi that works on One Time RTOS-32 that is a real-time OS, and now i have ported my MemPool for real-time systems to C++, please look at how is more efficient my C++ code, next step i will port my Threadpool for C++ and Delphi to real-time systems and i will port my scalale AMLock that is a scalable lock dor C++ and Delphi to real-time systems, and i will port my SemaMonitor for C++ and Delphi to real-time systems. And here is also some of my inventions, because i am also an inventor: You can download and read about my C++ synchronization objects library for Windows and Linux from here: https://sites.google.com/site/aminer68/c-synchronization-objects-library Thank you, Amine Moulay Ramdane. |
"Chris M. Thomasson" <invalid@invalid.invalid>: Mar 13 03:54PM -0700 On 3/12/2017 12:19 AM, Paavo Helde wrote: > possible. Typically just a pointer will be added or removed from a queue > during the lock. Therefore the mutex would become available very soon > and there would be no point to try anything else during that time. Try to put mutex queue under sustained pressure. Then take a look at the fast-path vs slow-paths, it does not scale that well. The lock based queue can fall apart under blocking. The adaptive nature of some mutexs will spin before hitting the kernel for a real blocking wait. The little algorithm I laid out is like an adaptive mutex in a sense, except instead of spin wait, it tries to do other work. |
"Rick C. Hodgin" <rick.c.hodgin@gmail.com>: Mar 13 08:59AM -0700 Why can't I do this (what is the reasoning behind the decision to prohibit this from occurring at compile-time)? class xyz { public: xyz(); ~xyz(); private: static char abc[] = "abc text"; } I don't understand why that would not be allowed. In my thinking, it would resolve to a public variable that's observable only through/to a class, so that its token name is in scope only there, and there is only one instance of that value per class, one which is populated at startup. In my thinking it could even be aliased to global memory so that the compiler treats it as though you had done this (giving it a unique internal name so there are no name collisions, but the principle would still be the same): static char abc[] = "abc text"; class xyz { public: xyz(); ~xyz(); } Thank you, Rick C. Hodgin |
"Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com>: Mar 13 06:09PM +0100 On 13-Mar-17 4:59 PM, Rick C. Hodgin wrote: > private: > static char abc[] = "abc text"; > }; (Missing semicolon added – please do post real code.) It's for the same reason that you can't do class Oh { auto x = 3.14; }; … even though you can do auto x = 3.14; … in namespace scope or local scope in a function. As far as I know that reason is that variable declarations, data member declarations and formal function argument declarations have /evolved/, somewhat haphazardly and independently. > through/to a class, so that its token name is in scope only there, > and there is only one instance of that value per class, one which > is populated at startup. There's much that C++ could automate for you, but doesn't. Still, what you /can/ do is quite simple, once you know about it: #include <iostream> using namespace std; struct xyz { static constexpr auto& abc = "abc text"; }; auto main() -> int { cout << xyz::abc << endl; } Cheers & hth., - Alf |
David Brown <david.brown@hesbynett.no>: Mar 13 10:23PM +0100 On 13/03/17 16:59, Rick C. Hodgin wrote: > private: > static char abc[] = "abc text"; > } It is allowed if you have: static constexpr const char abc[] = "abc text"; For non-integral members, you have to have a "constexpr const" to be able to initialise them inside the class definition, rather than outside it. I don't know why that is the case. |
Alvin <Alvin@invalid.invalid>: Mar 13 12:13PM +0100 On 2017-03-11 11:23, Alvin wrote: > int fn() { > return fn1() + fn2(); > } template<class T> T sequenced_sum(std::initializer_list<T> l) { return std::accumulate(l.begin(), l.end(), 0); } int fn() { return sequenced_sum({ fn1(), fn2() }); } |
"Öö Tiib" <ootiib@hot.ee>: Mar 13 09:16AM -0700 On Monday, 13 March 2017 13:14:06 UTC+2, Alvin wrote: > int fn() { > return sequenced_sum({ fn1(), fn2() }); > } Other suggestions in this thread seemed better-looking. |
Alvin <Alvin@invalid.invalid>: Mar 13 06:41PM +0100 On 2017-03-13 17:16, Öö Tiib wrote: >> return sequenced_sum({ fn1(), fn2() }); >> } > Other suggestions in this thread seemed better-looking. For 2 functions I would probably use the versions with one or two temporary variables. For more, this is IMHO the best version so far. |
"Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com>: Mar 13 08:15PM +0100 On 13-Mar-17 6:41 PM, Alvin wrote: >> Other suggestions in this thread seemed better-looking. > For 2 functions I would probably use the versions with one or two > temporary variables. For more, this is IMHO the best version so far. Uhm, well. How often does one have a sum of N different argument expressions, which all have side effects so that they must be evaluated in order? For a reasonable number of such arguments, say f1(), f2() and f3() all with side-effects, which is a case that for me has occurred less than 1 time in 35 years, I'd just do int sum = 0; for( int x : {f1(), f2(), f3()} ) { sum += x; } But then, I prefer to not use STL algorithms where similar size directly expressed code can do it. Because with the directly expressed code one doesn't have to know or look up details about the STL algorithm in question. And I tend to forget such details. Cheers!, - Alf |
Daniel <danielaparker@gmail.com>: Mar 13 12:34PM -0700 On Monday, March 13, 2017 at 3:15:17 PM UTC-4, Alf P. Steinbach wrote: > expressed code can do it. Because with the directly expressed code one > doesn't have to know or look up details about the STL algorithm in > question. And I tend to forget such details. Emphatic agreement! Daniel |
"Rick C. Hodgin" <rick.c.hodgin@gmail.com>: Mar 13 09:04AM -0700 Does C++ offer a static constructor? Something that can be called at startup to initialize anything specific to static members of a class? Something like: class xyz { public: xyz(); // Called for each instance ~xyz(); // Called for each instance static xyz(); // Called at startup static ~xyz(); // Called at normal shutdown } Or do I need to define my own separate un-encapsulated function somewhere which then initializes any values I might need for the class before it's used the first time, so as to not take the test- on-each-instantiation/deinstantiation performance hit? Thank you, Rick C. Hodgin |
Bonita Montero <Bonita.Montero@gmail.com>: Mar 13 05:31PM +0100 I think the best way would be to define another class (maybe a nested class) and have a static member in the class needing something like a "static constructor". -- http://facebook.com/bonita.montero/ |
Juha Nieminen <nospam@thanks.invalid>: Mar 13 07:24AM > The message is simple: He wants to forgive your sin and give you eternal > life in the paradise of God. Fuck off, you hypocrite. You don't even yourself follow your own holy book. |
"Rick C. Hodgin" <rick.c.hodgin@gmail.com>: Mar 13 02:10AM -0700 Juha Nieminen wrote: > .. you hypocrite. You don't even yourself follow your own holy book. How so? Thank you, Rick C. Hodgin |
"Rick C. Hodgin" <rick.c.hodgin@gmail.com>: Mar 13 02:51AM -0700 An inspiring message for the heart in repentance: The Judgment Seat of Christ Leonard Ravenhill https://www.youtube.com/watch?v=ZP22kA70cdM God encourages you toward holiness and service to Him and His eternal Kingdom ... even while we are yet here on Earth. It is the highest privilege to serve the Lord. Thank you, Rick C. Hodgin |
Juha Nieminen <nospam@thanks.invalid>: Mar 13 07:20AM > There's always typedef. Or a using directive How exactly does "Serial.println()" indicate that "Serial" is a type? If "Serial" and "Serial1" are objects, then what you want is a reference. |
Juha Nieminen <nospam@thanks.invalid>: Mar 13 07:15AM >> Maybe because it is commented out? > I commented it out to show the code that does not work! "Does not work" isn't very helpful. Describe what is it that you are getting. |
Barry Schwarz <schwarzb@dqel.com>: Mar 12 04:27PM -0700 On Sun, 12 Mar 2017 22:37:14 +0100, "Alf P. Steinbach" >Oh, well this is a definite bug. `if( !x ) {...} else if( x ) { ... } >else { /* spurious conclusion */ }`. There's no "possible" about it, >it's very definitely a bug. If the two if expressions are identical except for the '!', one could make a valid argument for this. But in the case in question was not std::cin and !std.cin. It was std.cin and std::cin.fail(). Is the compiler expected to know the ramifications of every class and member function in the standard library? It would be interesting to see which compilers do a better job if std:cin.fail() is replace with !std::cin. Mine does not. -- Remove del for email |
"Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com>: Mar 13 01:11AM +0100 On 13-Mar-17 12:27 AM, Barry Schwarz wrote: > If the two if expressions are identical except for the '!', one could > make a valid argument for this. But in the case in question was not > std::cin and !std.cin. It was std.cin and std::cin.fail(). C++14 $27.5.5.4/1: [quote] explicit operator bool() const; Returns: !fail() [/quote] This conversion of stream object to boolean, used in `if( cin )` in the book's code, has been defined directly in terms of `fail()` since C++98. The only difference is that since C++11 it's been defined as `explicit operator bool`, while in C++98 it was an `operator void`, because C++98 didn't support `explicit` for a conversion operator. > Is the > compiler expected to know the ramifications of every class and member > function in the standard library? No, but /we/ are expected to know what the things we use, do. ;-) And the logic is unaffected by what the compiler is able to deduce. /We/ know that `fail` doesn't modify the object, and hence that the two conditions must have opposite results, even though the compiler doesn't. > It would be interesting to see which compilers do a better job if > std:cin.fail() is replace with !std::cin. Mine does not. If you mean that it ideally should warn about that code, well, the problem there is that the average compiler doesn't know that `fail` can't change the state of the stream object. For the `const`-ness of that member function doesn't prevent `fail` from modifying, even if that's clearly /indicated/ and even if it's not circumvented by `mutable` or `const_cast`. That's because the stream object might have e.g. a pointer to an owned, mutable buffer that `fail` conceivably could modify, and on which its result could depend. This problem, that the compiler can't see the intended pure inspection function nature of `fail` without having that knowledge hardwired, is because the standard language (unfortunately) has no way to express in general that a function is pure. `constexpr` comes close. But it does not correspond exactly, and it's not applicable here. Still, when I tested this now I was surprised that g++ didn't warn, because I seem to recall that g++ has a language extension that allows one to annotate a function as pure, and I'd expect that to be used in its standard library implementation, for improved diagnostics. But alas. Cheers!, - Alf |
"Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com>: Mar 13 01:15AM +0100 On 13-Mar-17 1:11 AM, Alf P. Steinbach wrote: > it was an `operator void`, void* Mumble, grumble. Cheers!, - Alf |
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