- Available C++ Libraries FAQ - 1 Update
- what is the best way to get microseconds of time on Windows in C or C++ ? - 1 Update
- Windows does overcommit stacks ! - 1 Update
| Nikki Locke <nikki@trumphurst.com>: Nov 14 11:23PM Available C++ Libraries FAQ URL: http://www.trumphurst.com/cpplibs/ This is a searchable list of libraries and utilities (both free and commercial) available to C++ programmers. If you know of a library which is not in the list, why not fill in the form at http://www.trumphurst.com/cpplibs/cppsub.php Maintainer: Nikki Locke - if you wish to contact me, please use the form on the website. |
| Lynn McGuire <lynnmcguire5@gmail.com>: Nov 14 04:58PM -0600 On 11/4/2022 8:44 AM, Scott Lurndal wrote: >> Lynn > First answer here: > https://stackoverflow.com/questions/10905892/equivalent-of-gettimeday-for-windows "Nowadys I would use the following for gettimeofday() on Windows, which is using GetSystemTimePreciseAsFileTime() if compiled for Windows 8 or higher and GetSystemTimeAsFileTime() otherwise:" I used the gettimeofday function. Works well ! Thanks, Lynn |
| Bonita Montero <Bonita.Montero@gmail.com>: Nov 14 10:03PM +0100 To dispel the doubts that Windows Stacks is overcommitted, I wrote a small program that creates threads recursively and outputs every second how many threads have been created so far. Unless you set something else in the linker, Windows reserves one megabyte of address space for each new stack. I can easily create 250,000 threads on my machine with this program, which then consumes 250 gigabytes of address space. If all this were committed without being physically assigned, then I would need at least a lot of swap, which would keep the available swap in case the committed pages were also written. Here's the code: #include <iostream> #include <vector> #include <thread> #include <functional> #include <semaphore> #include <chrono> #include <syncstream> using namespace std; using namespace chrono; int main() { vector<jthread> threads; threads.reserve( 1'000'000 ); function<void ()> threadFn; atomic_uint32_t n; counting_semaphore semFinish( 0 ); steady_clock::time_point start = steady_clock::now(); atomic_uint lastElapsed = 0; auto create = [&]() { try { threads.emplace_back( threadFn ); ++n; unsigned elapsed = (unsigned)duration_cast<seconds>( steady_clock::now() - start ).count(); if( elapsed > lastElapsed ) osyncstream( cout ) << n << endl, lastElapsed = elapsed; semFinish.acquire(); } catch( system_error const & ) { semFinish.release( n ); } }; (threadFn = create)(); threads.resize( 0 ); cout << n << endl; } |
| 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