Skip to content

Commit 8d75755

Browse files
authored
Merge pull request #83 from sorenhein/master
Cumulative update from v2.9.0 beta to v2.9.0
2 parents 06cc599 + 54df5e4 commit 8d75755

File tree

9 files changed

+890
-865
lines changed

9 files changed

+890
-865
lines changed

ChangeLog

+8
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
Release Notes DDS 2.9.0
2+
-----------------------
3+
- Fixed crashes in certain multi-threading types
4+
- Added GetDDSInfo to Exports.def (thanks to Paul Barden)
5+
- Fixed casting problems with some compilers in ThreadMgr
6+
- Updated documentation
7+
8+
19
Release Notes DDS 2.9.0 beta
210
----------------------------
311
Included code for a number of multi-threading systems:

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ DDS offers a wide range of functions, including par-score calculations.
66

77
Please refer to the [home page](http://privat.bahnhof.se/wb758135) for details.
88

9-
The current version is DDS 2.9.0 beta, released in May 2018 and licensed under the Apache 2.0 license in the LICENSE FILE.
9+
The current version is DDS 2.9.0, released in August 2018 and licensed under the Apache 2.0 license in the LICENSE FILE.
1010

1111
Release notes are in the ChangeLog file.
1212

@@ -88,7 +88,7 @@ The DDS library interface is documented. You find the docs, including a Markdown
8888

8989
Bugs
9090
====
91-
Version 2.9.0 beta has no known bugs.
91+
Version 2.9.0 has no known bugs.
9292

9393
Please report bugs to [email protected] and [email protected].
9494

doc/DLL-dds_x.pdf

-116 KB
Binary file not shown.

doc/DLL-dds_x.rtf

+831-824
Large diffs are not rendered by default.

src/Exports.def

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ EXPORTS
66
SetThreading@4 = SetThreading
77
SetResources
88
SetResources@8 = SetResources
9+
GetDDSInfo
10+
GetDDSInfo@4 = GetDDSInfo
911
FreeMemory
1012
FreeMemory@0 = FreeMemory
1113
ErrorMessage

src/Makefiles/Makefile_Visual

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
# matters are CC_BOOST_INCL and CC_BOOST_LINK.
1818
# On my systems (there are two), they are here:
1919

20-
BOOST32_PATH1 = \User\sheins\boost_1_66_0_x32_new
20+
BOOST32_PATH1 = \Users\heins\Libraries\Boost\boost_1_66_0_x32_new
2121
BOOST32_LIB1 = $(BOOST32_PATH1)\lib32-msvc-14.1
2222

2323
BOOST32_PATH2 = \Users\s.hein\Documents\Programs\boost_1_66_0_x32_14_1

src/System.cpp

+7-10
Original file line numberDiff line numberDiff line change
@@ -570,15 +570,10 @@ int System::RunThreadsPPLIMPL()
570570
(* CallbackDuplList[runCat])(* bop, uniques, crossrefs);
571571

572572
static atomic<int> thrIdNext = 0;
573-
bool err = false;
573+
bool err = false, err2 = false;
574574

575575
threadMgr.Reset(numThreads);
576576

577-
using namespace Concurrency;
578-
Concurrency::Scheduler * sched = Concurrency::Scheduler::Create(
579-
SchedulerPolicy(1, MaxConcurrency, numThreads));
580-
sched->Attach();
581-
582577
Concurrency::parallel_for_each(uniques.begin(), uniques.end(),
583578
[&](int &bno)
584579
{
@@ -595,17 +590,19 @@ int System::RunThreadsPPLIMPL()
595590
(* CallbackSingleList[runCat])(realThrId, bno);
596591

597592
if (! threadMgr.Release(thrId))
598-
err = true;
593+
err2 = true;
599594
});
600595

601-
CurrentScheduler::Detach();
602-
sched->Release();
603-
604596
if (err)
605597
{
606598
cout << "Too many threads, numThreads " << numThreads << endl;
607599
return RETURN_THREAD_INDEX;
608600
}
601+
else if (err2)
602+
{
603+
cout << "Release failed, numThreads " << numThreads << endl;
604+
return RETURN_THREAD_INDEX;
605+
}
609606

610607
(* CallbackCopyList[runCat])(crossrefs);
611608
#endif

src/ThreadMgr.cpp

+37-26
Original file line numberDiff line numberDiff line change
@@ -36,35 +36,37 @@ ThreadMgr::~ThreadMgr()
3636

3737
void ThreadMgr::Reset(const int nThreads)
3838
{
39-
if (nThreads > numRealThreads)
39+
const unsigned n = static_cast<unsigned>(nThreads);
40+
if (n > numRealThreads)
4041
{
41-
realThreads.resize(nThreads);
42-
for (int t = numRealThreads; t < nThreads; t++)
42+
realThreads.resize(n);
43+
for (unsigned t = numRealThreads; t < n; t++)
4344
realThreads[t] = false;
44-
numRealThreads = nThreads;
45+
numRealThreads = n;
4546
}
4647

47-
if (nThreads > numMachineThreads)
48+
if (n > numMachineThreads)
4849
{
49-
machineThreads.resize(nThreads);
50-
for (int t = numMachineThreads; t < nThreads; t++)
50+
machineThreads.resize(n);
51+
for (unsigned t = numMachineThreads; t < n; t++)
5152
machineThreads[t] = -1;
52-
numMachineThreads = nThreads;
53+
numMachineThreads = n;
5354
}
5455
}
5556

5657

5758
int ThreadMgr::Occupy(const int machineId)
5859
{
59-
if (machineId >= numMachineThreads)
60+
const unsigned m = static_cast<unsigned>(machineId);
61+
if (m >= numMachineThreads)
6062
{
61-
numMachineThreads = machineId + 1;
63+
numMachineThreads = m + 1;
6264
machineThreads.resize(numMachineThreads);
63-
for (int t = machineId; t < numMachineThreads; t++)
65+
for (unsigned t = m; t < numMachineThreads; t++)
6466
machineThreads[t] = -1;
6567
}
6668

67-
if (machineThreads[machineId] != -1)
69+
if (machineThreads[m] != -1)
6870
{
6971
// Error: Already in use.
7072
return -1;
@@ -75,13 +77,14 @@ int ThreadMgr::Occupy(const int machineId)
7577
do
7678
{
7779
mtx.lock();
78-
for (int t = 0; t < numRealThreads; t++)
80+
for (unsigned t = 0; t < numRealThreads; t++)
7981
{
8082
if (realThreads[t] == false)
8183
{
84+
const int ti = static_cast<int>(t);
8285
realThreads[t] = true;
83-
machineThreads[machineId] = t;
84-
res = t;
86+
machineThreads[m] = ti;
87+
res = ti;
8588
break;
8689
}
8790
}
@@ -102,24 +105,32 @@ int ThreadMgr::Occupy(const int machineId)
102105

103106
bool ThreadMgr::Release(const int machineId)
104107
{
105-
const int r = machineThreads[machineId];
108+
mtx.lock();
109+
110+
bool ret;
111+
const unsigned m = static_cast<unsigned>(machineId);
112+
const int r = machineThreads[m];
113+
const unsigned ru = static_cast<unsigned>(r);
114+
106115
if (r == -1)
107116
{
108117
// Error: Not in use.
109-
return false;
118+
ret = false;
110119
}
111-
112-
if (! realThreads[r])
120+
else if (! realThreads[ru])
113121
{
114122
// Error: Refers to a real thread that is not in use.
115-
return false;
123+
ret = false;
124+
}
125+
else
126+
{
127+
realThreads[ru] = false;
128+
machineThreads[m] = -1;
129+
ret = true;
116130
}
117131

118-
mtx.lock();
119-
realThreads[r] = false;
120-
machineThreads[machineId] = -1;
121132
mtx.unlock();
122-
return true;
133+
return ret;
123134
}
124135

125136

@@ -133,15 +144,15 @@ void ThreadMgr::Print(
133144

134145
fo << tag <<
135146
": Real threads occupied (out of " << numRealThreads << "):\n";
136-
for (int t = 0; t < numRealThreads; t++)
147+
for (unsigned t = 0; t < numRealThreads; t++)
137148
{
138149
if (realThreads[t])
139150
fo << t << endl;
140151
}
141152
fo << endl;
142153

143154
fo << "Machine threads overview:\n";
144-
for (int t = 0; t < numMachineThreads; t++)
155+
for (unsigned t = 0; t < numMachineThreads; t++)
145156
{
146157
if (machineThreads[t] != -1)
147158
{

src/ThreadMgr.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ class ThreadMgr
2121

2222
vector<bool> realThreads;
2323
vector<int> machineThreads;
24-
int numRealThreads;
25-
int numMachineThreads;
24+
unsigned numRealThreads;
25+
unsigned numMachineThreads;
2626

2727
public:
2828

0 commit comments

Comments
 (0)