PAL_ERROR palError = NO_ERROR;
CPalThread *pTargetThread = NULL;
IPalObject *pobjThread = NULL;
-
+
+ int st;
int policy;
struct sched_param schedParam;
int max_priority;
iNewPriority, schedParam.sched_priority);
/* Finally, set the new priority into place */
- if (pthread_setschedparam(
- pTargetThread->GetPThreadSelf(),
- policy,
- &schedParam
- ) != 0)
+ st = pthread_setschedparam(pTargetThread->GetPThreadSelf(), policy, &schedParam);
+ if (st != 0)
{
#if SET_SCHEDPARAM_NEEDS_PRIVS
- if (EPERM == errno)
+ if (EPERM == st)
{
// UNIXTODO: Should log a warning to the event log
TRACE("Caller does not have OS privileges to call pthread_setschedparam\n");
}
#endif
- ASSERT("Unable to set thread priority (errno %d)\n", errno);
+ ASSERT("Unable to set thread priority to %d (error %d)\n", (int)posix_priority, st);
palError = ERROR_INTERNAL_ERROR;
goto InternalSetThreadPriorityExit;
}
HANDLE hDupThread;
DWORD dwThreadId = 0;
LPTHREAD_START_ROUTINE lpStartAddress = &CreateTestThread;
+ HANDLE hSyncEvent;
int threadPriority;
int duplicatePriority;
return (FAIL);
}
+ LPSECURITY_ATTRIBUTES lpEventAttributes = NULL;
+ BOOL bManualReset = TRUE;
+ BOOL bInitialState = FALSE;
+ hSyncEvent = CreateEvent(lpEventAttributes,
+ bManualReset,
+ bInitialState,
+ NULL);
+
+ if (hSyncEvent == NULL)
+ {
+ Fail("ERROR:%u: Unable to create sync event.\n",
+ GetLastError());
+ }
+
/* Create a thread.*/
hThread = CreateThread(NULL, /* SD*/
(DWORD)0, /* initial stack size*/
lpStartAddress, /* thread function*/
- NULL, /* thread argument*/
+ (VOID*)hSyncEvent,/* thread argument*/
(DWORD)0, /* creation option*/
&dwThreadId); /* thread identifier*/
if (hThread == NULL)
Fail("");
}
+ /* Signal the helper thread that it can shut down */
+ if (!SetEvent(hSyncEvent))
+ {
+ Fail("ERROR:%u: Failed to set event.\n",
+ GetLastError());
+ }
+
/* Wait on the original thread.*/
if((WaitForSingleObject(hThread, 100)) != WAIT_OBJECT_0)
{
}
/* Clean-up thread and Terminate the PAL.*/
+ CloseHandle(hSyncEvent);
CloseHandle(hThread);
CloseHandle(hDupThread);
PAL_Terminate();
return PASS;
}
-/*Thread testing function, only return '0'*/
+/*Thread testing function*/
DWORD PALAPI CreateTestThread(LPVOID lpParam)
{
+ HANDLE hSyncEvent = (HANDLE)lpParam;
+
+ /* Wait until the main thread signals that this helper thread should shut down */
+ WaitForSingleObject(hSyncEvent, INFINITE);
+
return (DWORD)0;
}
+