reorganizing repo

git-svn-id: svn://ultimatepp.org/upp/trunk@9206 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2015-11-22 11:23:48 +00:00
parent 7d17505cfe
commit e3e8d627f5
3840 changed files with 0 additions and 1161578 deletions

View file

@ -1,56 +0,0 @@
#include <Core/Core.h>
using namespace Upp;
static const int ITEMS = 10000;
static const int PASSES = 5;
static const int THREADS = 4;
volatile Atomic items[ITEMS];
static void ThreadProc(volatile Atomic *item, bool *finish)
{
AtomicInc(*item);
*finish = true;
}
static void TryMain()
{
for(int pass = 1; pass <= PASSES; pass++) {
puts(NFormat("pass #%d", pass));
fflush(stdout);
for(int i = 0; i < ITEMS; i += THREADS) {
if(i % (100 * THREADS) == 0) {
puts(NFormat("i = %d", i));
fflush(stdout);
}
bool thread_finished[THREADS];
for(int t = 0; t < THREADS; t++) {
if(i + t < ITEMS) {
thread_finished[t] = false;
Thread().Run(callback2(&ThreadProc, &items[i + t], &thread_finished[t]));
}
else
thread_finished[t] = true;
}
for(;;) {
bool done = true;
for(int t = 0; t < THREADS; t++)
if(!thread_finished[t]) {
done = false;
break;
}
if(done)
break;
Sleep(10);
}
}
for(int i = 0; i < ITEMS; i++)
if(items[i] != pass)
RLOG("pass #" << pass << ": error at [" << i << "] = " << (int)items[i]);
}
}
CONSOLE_APP_MAIN {
TryMain();
}