Skip to content

Commit 63a1aa6

Browse files
committed
Remove prioritized waits from the PAL and remove WAIT_ABANDONED usage
1 parent 32c9e60 commit 63a1aa6

File tree

7 files changed

+33
-63
lines changed

7 files changed

+33
-63
lines changed

src/coreclr/pal/src/include/pal/corunix.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -571,8 +571,7 @@ namespace CorUnix
571571
RegisterWaitingThread(
572572
WaitType eWaitType,
573573
DWORD dwIndex,
574-
bool fAltertable,
575-
bool fPrioritize
574+
bool fAltertable
576575
) = 0;
577576

578577
//

src/coreclr/pal/src/include/pal/synchobjects.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ namespace CorUnix
3737
CONST HANDLE *lpHandles,
3838
BOOL bWaitAll,
3939
DWORD dwMilliseconds,
40-
BOOL bAlertable,
41-
BOOL bPrioritize = FALSE);
40+
BOOL bAlertable);
4241

4342
DWORD InternalSignalObjectAndWait(
4443
CPalThread *thread,

src/coreclr/pal/src/synchmgr/synchcontrollers.cpp

Lines changed: 18 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -247,8 +247,7 @@ namespace CorUnix
247247
PAL_ERROR CSynchWaitController::RegisterWaitingThread(
248248
WaitType wtWaitType,
249249
DWORD dwIndex,
250-
bool fAlertable,
251-
bool fPrioritize)
250+
bool fAlertable)
252251
{
253252
VALIDATEOBJECT(m_psdSynchData);
254253

@@ -366,7 +365,7 @@ namespace CorUnix
366365
}
367366

368367
// Add new node to queue
369-
m_psdSynchData->WaiterEnqueue(pwtlnNewNode, fPrioritize);
368+
m_psdSynchData->WaiterEnqueue(pwtlnNewNode);
370369

371370
// Succeeded: update object count
372371
ptwiWaitInfo->lObjCount++;
@@ -1113,60 +1112,32 @@ namespace CorUnix
11131112
Note: this method must be called while holding the local process
11141113
synchronization lock.
11151114
--*/
1116-
void CSynchData::WaiterEnqueue(WaitingThreadsListNode * pwtlnNewNode, bool fPrioritize)
1115+
void CSynchData::WaiterEnqueue(WaitingThreadsListNode * pwtlnNewNode)
11171116
{
11181117
VALIDATEOBJECT(this);
11191118
VALIDATEOBJECT(pwtlnNewNode);
11201119

1121-
if (!fPrioritize)
1122-
{
1123-
// Enqueue normally to the end of the queue
1124-
WaitingThreadsListNode * pwtlnCurrLast = m_ptrWTLTail.ptr;
1120+
// Enqueue normally to the end of the queue
1121+
WaitingThreadsListNode * pwtlnCurrLast = m_ptrWTLTail.ptr;
11251122

1126-
pwtlnNewNode->ptrNext.ptr = NULL;
1127-
if (NULL == pwtlnCurrLast)
1128-
{
1129-
_ASSERT_MSG(NULL == m_ptrWTLHead.ptr,
1130-
"Corrupted waiting list on local CSynchData @ %p\n",
1131-
this);
1132-
1133-
pwtlnNewNode->ptrPrev.ptr = NULL;
1134-
m_ptrWTLHead.ptr = pwtlnNewNode;
1135-
m_ptrWTLTail.ptr = pwtlnNewNode;
1136-
}
1137-
else
1138-
{
1139-
VALIDATEOBJECT(pwtlnCurrLast);
1123+
pwtlnNewNode->ptrNext.ptr = NULL;
1124+
if (NULL == pwtlnCurrLast)
1125+
{
1126+
_ASSERT_MSG(NULL == m_ptrWTLHead.ptr,
1127+
"Corrupted waiting list on local CSynchData @ %p\n",
1128+
this);
11401129

1141-
pwtlnNewNode->ptrPrev.ptr = pwtlnCurrLast;
1142-
pwtlnCurrLast->ptrNext.ptr = pwtlnNewNode;
1143-
m_ptrWTLTail.ptr = pwtlnNewNode;
1144-
}
1130+
pwtlnNewNode->ptrPrev.ptr = NULL;
1131+
m_ptrWTLHead.ptr = pwtlnNewNode;
1132+
m_ptrWTLTail.ptr = pwtlnNewNode;
11451133
}
11461134
else
11471135
{
1148-
// The wait is prioritized, enqueue to the beginning of the queue
1149-
WaitingThreadsListNode * pwtlnCurrFirst = m_ptrWTLHead.ptr;
1136+
VALIDATEOBJECT(pwtlnCurrLast);
11501137

1151-
pwtlnNewNode->ptrPrev.ptr = NULL;
1152-
if (NULL == pwtlnCurrFirst)
1153-
{
1154-
_ASSERT_MSG(NULL == m_ptrWTLTail.ptr,
1155-
"Corrupted waiting list on local CSynchData @ %p\n",
1156-
this);
1157-
1158-
pwtlnNewNode->ptrNext.ptr = NULL;
1159-
m_ptrWTLHead.ptr = pwtlnNewNode;
1160-
m_ptrWTLTail.ptr = pwtlnNewNode;
1161-
}
1162-
else
1163-
{
1164-
VALIDATEOBJECT(pwtlnCurrFirst);
1165-
1166-
pwtlnNewNode->ptrNext.ptr = pwtlnCurrFirst;
1167-
pwtlnCurrFirst->ptrPrev.ptr = pwtlnNewNode;
1168-
m_ptrWTLHead.ptr = pwtlnNewNode;
1169-
}
1138+
pwtlnNewNode->ptrPrev.ptr = pwtlnCurrLast;
1139+
pwtlnCurrLast->ptrNext.ptr = pwtlnNewNode;
1140+
m_ptrWTLTail.ptr = pwtlnNewNode;
11701141
}
11711142

11721143
m_ulcWaitingThreads += 1;

src/coreclr/pal/src/synchmgr/synchmanager.hpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ namespace CorUnix
179179
CPalThread * pthrCurrent,
180180
CPalThread * pthrTarget);
181181

182-
void WaiterEnqueue(WaitingThreadsListNode * pwtlnNewNode, bool fPrioritize);
182+
void WaiterEnqueue(WaitingThreadsListNode * pwtlnNewNode);
183183

184184
// Object Type accessor methods
185185
CObjectType * GetObjectType(void)
@@ -366,8 +366,7 @@ namespace CorUnix
366366
virtual PAL_ERROR RegisterWaitingThread(
367367
WaitType wtWaitType,
368368
DWORD dwIndex,
369-
bool fAlertable,
370-
bool fPrioritize);
369+
bool fAlertable);
371370

372371
virtual void ReleaseController(void);
373372

src/coreclr/pal/src/synchmgr/wait.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -321,8 +321,7 @@ DWORD CorUnix::InternalWaitForMultipleObjectsEx(
321321
CONST HANDLE *lpHandles,
322322
BOOL bWaitAll,
323323
DWORD dwMilliseconds,
324-
BOOL bAlertable,
325-
BOOL bPrioritize)
324+
BOOL bAlertable)
326325
{
327326
DWORD dwRet = WAIT_FAILED;
328327
PAL_ERROR palErr = NO_ERROR;
@@ -516,8 +515,7 @@ DWORD CorUnix::InternalWaitForMultipleObjectsEx(
516515
palErr = ppISyncWaitCtrlrs[i]->RegisterWaitingThread(
517516
wtWaitType,
518517
i,
519-
(TRUE == bAlertable),
520-
bPrioritize != FALSE);
518+
(TRUE == bAlertable));
521519
if (NO_ERROR != palErr)
522520
{
523521
ERROR("RegisterWaitingThread() failed for %d-th object "

src/coreclr/vm/finalizerthread.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -249,8 +249,6 @@ void FinalizerThread::WaitForFinalizerEvent (CLREvent *event)
249249
{
250250
case (WAIT_OBJECT_0):
251251
return;
252-
case (WAIT_ABANDONED):
253-
return;
254252
case (WAIT_TIMEOUT):
255253
break;
256254
}
@@ -312,8 +310,6 @@ void FinalizerThread::WaitForFinalizerEvent (CLREvent *event)
312310
{
313311
case (WAIT_OBJECT_0):
314312
return;
315-
case (WAIT_ABANDONED):
316-
return;
317313
case (WAIT_TIMEOUT):
318314
break;
319315
}

src/coreclr/vm/threads.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3361,7 +3361,6 @@ DWORD Thread::DoAppropriateWaitWorker(int countHandles, HANDLE *handles, BOOL wa
33613361
goto retry;
33623362
}
33633363
_ASSERTE((ret >= WAIT_OBJECT_0 && ret < (WAIT_OBJECT_0 + (DWORD)countHandles)) ||
3364-
(ret >= WAIT_ABANDONED && ret < (WAIT_ABANDONED + (DWORD)countHandles)) ||
33653364
(ret == WAIT_TIMEOUT) || (ret == WAIT_FAILED));
33663365
// countHandles is used as an unsigned -- it should never be negative.
33673366
_ASSERTE(countHandles >= 0);
@@ -3460,11 +3459,13 @@ DWORD Thread::DoAppropriateWaitWorker(int countHandles, HANDLE *handles, BOOL wa
34603459
DWORD subRet = WaitForSingleObject (handles[i], 0);
34613460
if ((subRet == WAIT_OBJECT_0) || (subRet == WAIT_FAILED))
34623461
break;
3462+
#ifdef HOST_WINDOWS
34633463
if (subRet == WAIT_ABANDONED)
34643464
{
34653465
ret = (ret - WAIT_OBJECT_0) + WAIT_ABANDONED;
34663466
break;
34673467
}
3468+
#endif // HOST_WINDOWS
34683469
// If we get alerted it just masks the real state of the current
34693470
// handle, so retry the wait.
34703471
if (subRet == WAIT_IO_COMPLETION)
@@ -3622,11 +3623,18 @@ DWORD Thread::DoSignalAndWaitWorker(HANDLE* pHandles, DWORD millis,BOOL alertabl
36223623
WaitCompleted:
36233624

36243625
//Check that the return state is valid
3626+
#ifdef HOST_WINDOWS
36253627
_ASSERTE(WAIT_OBJECT_0 == ret ||
36263628
WAIT_ABANDONED == ret ||
36273629
WAIT_TIMEOUT == ret ||
36283630
WAIT_FAILED == ret ||
36293631
ERROR_TOO_MANY_POSTS == ret);
3632+
#else
3633+
_ASSERTE(WAIT_OBJECT_0 == ret ||
3634+
WAIT_TIMEOUT == ret ||
3635+
WAIT_FAILED == ret ||
3636+
ERROR_TOO_MANY_POSTS == ret);
3637+
#endif // HOST_WINDOWS
36303638

36313639
//Wrong to time out if the wait was infinite
36323640
_ASSERTE((WAIT_TIMEOUT != ret) || (INFINITE != millis));

0 commit comments

Comments
 (0)