mirror of
https://github.com/OpenEtherCATsociety/SOEM.git
synced 2026-10-02 12:24:03 +08:00
fix(win32): detect CreateThread failure and pass correct handle to SetThreadPriority
Previously, osal_thread_create checked the wrong handle value, so thread creation failures were reported as success. Also, osal_thread_create_rt passed the handle pointer instead of the thread HANDLE to SetThreadPriority, so real-time priority was never applied. Fixes #977
This commit is contained in:
committed by
Hans-Erik Floryd
parent
7a8011bb28
commit
2f73eaa803
@@ -5,3 +5,4 @@ install
|
||||
/doc/html
|
||||
tags
|
||||
.vscode
|
||||
.vs
|
||||
|
||||
+7
-3
@@ -132,8 +132,10 @@ void osal_free(void *ptr)
|
||||
|
||||
int osal_thread_create(void *thandle, int stacksize, void *func, void *param)
|
||||
{
|
||||
*(OSAL_THREAD_HANDLE *)thandle = CreateThread(NULL, stacksize, func, param, 0, NULL);
|
||||
if (!thandle)
|
||||
HANDLE thread;
|
||||
thread = CreateThread(NULL, (SIZE_T)stacksize, (LPTHREAD_START_ROUTINE)func, param, 0, NULL);
|
||||
*(OSAL_THREAD_HANDLE*)thandle = thread;
|
||||
if (thread == NULL)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@@ -142,11 +144,13 @@ int osal_thread_create(void *thandle, int stacksize, void *func, void *param)
|
||||
|
||||
int osal_thread_create_rt(void *thandle, int stacksize, void *func, void *param)
|
||||
{
|
||||
HANDLE thread;
|
||||
int ret;
|
||||
ret = osal_thread_create(thandle, stacksize, func, param);
|
||||
if (ret)
|
||||
{
|
||||
ret = SetThreadPriority(thandle, THREAD_PRIORITY_TIME_CRITICAL);
|
||||
thread = *(OSAL_THREAD_HANDLE*)thandle;
|
||||
ret = SetThreadPriority(thread, THREAD_PRIORITY_TIME_CRITICAL);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user