Index: trunk/src/kernel32/HandleManager.cpp
===================================================================
--- trunk/src/kernel32/HandleManager.cpp	(revision 7530)
+++ trunk/src/kernel32/HandleManager.cpp	(revision 7532)
@@ -1,3 +1,3 @@
-/* $Id: HandleManager.cpp,v 1.81 2001-11-29 13:38:49 sandervl Exp $ */
+/* $Id: HandleManager.cpp,v 1.82 2001-12-03 12:13:06 sandervl Exp $ */
 
 /*
@@ -4044,5 +4044,5 @@
   {
       TabWin32Handles[iIndexNew].hmHandleData.hHMHandle = INVALID_HANDLE_VALUE;
-  return 0;                                           /* signal error */
+      return 0;                                           /* signal error */
   }
 
@@ -4076,5 +4076,5 @@
 
   pHMHandle = &TabWin32Handles[iIndex];               /* call device handler */
-  lpResult = pHMHandle->pDeviceHandler->GetThreadPriority(&TabWin32Handles[iIndex].hmHandleData);
+  lpResult = pHMHandle->pDeviceHandler->GetThreadPriority(hThread, &TabWin32Handles[iIndex].hmHandleData);
 
   return (lpResult);                                  /* deliver return code */
@@ -4107,5 +4107,5 @@
 
   pHMHandle = &TabWin32Handles[iIndex];               /* call device handler */
-  lpResult = pHMHandle->pDeviceHandler->SuspendThread(&TabWin32Handles[iIndex].hmHandleData);
+  lpResult = pHMHandle->pDeviceHandler->SuspendThread(hThread, &TabWin32Handles[iIndex].hmHandleData);
 
   return (lpResult);                                  /* deliver return code */
@@ -4138,5 +4138,5 @@
 
   pHMHandle = &TabWin32Handles[iIndex];               /* call device handler */
-  lpResult = pHMHandle->pDeviceHandler->SetThreadPriority(&TabWin32Handles[iIndex].hmHandleData, priority);
+  lpResult = pHMHandle->pDeviceHandler->SetThreadPriority(hThread, &TabWin32Handles[iIndex].hmHandleData, priority);
 
   return (lpResult);                                  /* deliver return code */
@@ -4169,5 +4169,5 @@
 
   pHMHandle = &TabWin32Handles[iIndex];               /* call device handler */
-  lpResult = pHMHandle->pDeviceHandler->GetThreadContext(&TabWin32Handles[iIndex].hmHandleData, lpContext);
+  lpResult = pHMHandle->pDeviceHandler->GetThreadContext(hThread, &TabWin32Handles[iIndex].hmHandleData, lpContext);
 
   return (lpResult);                                  /* deliver return code */
@@ -4200,5 +4200,5 @@
 
   pHMHandle = &TabWin32Handles[iIndex];               /* call device handler */
-  lpResult = pHMHandle->pDeviceHandler->SetThreadContext(&TabWin32Handles[iIndex].hmHandleData, lpContext);
+  lpResult = pHMHandle->pDeviceHandler->SetThreadContext(hThread, &TabWin32Handles[iIndex].hmHandleData, lpContext);
 
   return (lpResult);                                  /* deliver return code */
@@ -4231,5 +4231,5 @@
 
   pHMHandle = &TabWin32Handles[iIndex];               /* call device handler */
-  lpResult = pHMHandle->pDeviceHandler->TerminateThread(&TabWin32Handles[iIndex].hmHandleData, exitcode);
+  lpResult = pHMHandle->pDeviceHandler->TerminateThread(hThread, &TabWin32Handles[iIndex].hmHandleData, exitcode);
 
   return (lpResult);                                  /* deliver return code */
@@ -4262,5 +4262,5 @@
 
   pHMHandle = &TabWin32Handles[iIndex];               /* call device handler */
-  lpResult = pHMHandle->pDeviceHandler->ResumeThread(&TabWin32Handles[iIndex].hmHandleData);
+  lpResult = pHMHandle->pDeviceHandler->ResumeThread(hThread, &TabWin32Handles[iIndex].hmHandleData);
 
   return (lpResult);                                  /* deliver return code */
@@ -4294,5 +4294,5 @@
 
   pHMHandle = &TabWin32Handles[iIndex];               /* call device handler */
-  lpResult = pHMHandle->pDeviceHandler->GetExitCodeThread(&TabWin32Handles[iIndex].hmHandleData, lpExitCode);
+  lpResult = pHMHandle->pDeviceHandler->GetExitCodeThread(hThread, &TabWin32Handles[iIndex].hmHandleData, lpExitCode);
 
   return (lpResult);                                  /* deliver return code */
@@ -4325,5 +4325,5 @@
 
   pHMHandle = &TabWin32Handles[iIndex];               /* call device handler */
-  lpResult = pHMHandle->pDeviceHandler->SetThreadTerminated(&TabWin32Handles[iIndex].hmHandleData);
+  lpResult = pHMHandle->pDeviceHandler->SetThreadTerminated(hThread, &TabWin32Handles[iIndex].hmHandleData);
 
   return (lpResult);                                  /* deliver return code */
Index: trunk/src/kernel32/hmdevice.cpp
===================================================================
--- trunk/src/kernel32/hmdevice.cpp	(revision 7530)
+++ trunk/src/kernel32/hmdevice.cpp	(revision 7532)
@@ -1,3 +1,3 @@
-/* $Id: hmdevice.cpp,v 1.29 2001-11-26 14:54:00 sandervl Exp $ */
+/* $Id: hmdevice.cpp,v 1.30 2001-12-03 12:13:08 sandervl Exp $ */
 
 /*
@@ -1483,10 +1483,10 @@
  * Author    : SvL
  *****************************************************************************/
-INT HMDeviceHandler::GetThreadPriority(PHMHANDLEDATA pHMHandleData)
+INT HMDeviceHandler::GetThreadPriority(HANDLE hThread, PHMHANDLEDATA pHMHandleData)
 {
   dprintf(("KERNEL32: ERROR: HandleManager::DeviceHandler::GetThreadPriority %08xh",
            pHMHandleData->hHMHandle));
 
-  return ERROR_INVALID_HANDLE;
+  return THREAD_PRIORITY_ERROR_RETURN;
 }
 /*****************************************************************************
@@ -1500,10 +1500,10 @@
  * Author    : SvL
  *****************************************************************************/
-DWORD HMDeviceHandler::SuspendThread(PHMHANDLEDATA pHMHandleData)
+DWORD HMDeviceHandler::SuspendThread(HANDLE hThread, PHMHANDLEDATA pHMHandleData)
 {
   dprintf(("KERNEL32: ERROR: HandleManager::DeviceHandler::SuspendThread %08xh",
            pHMHandleData->hHMHandle));
 
-  return ERROR_INVALID_HANDLE;
+  return -1;
 }
 /*****************************************************************************
@@ -1517,10 +1517,10 @@
  * Author    : SvL
  *****************************************************************************/
-BOOL HMDeviceHandler::SetThreadPriority(PHMHANDLEDATA pHMHandleData, int priority)
+BOOL HMDeviceHandler::SetThreadPriority(HANDLE hThread, PHMHANDLEDATA pHMHandleData, int priority)
 {
   dprintf(("KERNEL32: ERROR: HandleManager::DeviceHandler::SetThreadPriority %08xh",
            pHMHandleData->hHMHandle));
 
-  return ERROR_INVALID_HANDLE;
+  return FALSE;
 }
 /*****************************************************************************
@@ -1534,10 +1534,10 @@
  * Author    : SvL
  *****************************************************************************/
-BOOL HMDeviceHandler::GetThreadContext(PHMHANDLEDATA pHMHandleData, PCONTEXT lpContext)
+BOOL HMDeviceHandler::GetThreadContext(HANDLE hThread, PHMHANDLEDATA pHMHandleData, PCONTEXT lpContext)
 {
   dprintf(("KERNEL32: ERROR: HandleManager::DeviceHandler::GetThreadContext %08xh",
            pHMHandleData->hHMHandle));
 
-  return ERROR_INVALID_HANDLE;
+  return FALSE;
 }
 /*****************************************************************************
@@ -1551,10 +1551,10 @@
  * Author    : SvL
  *****************************************************************************/
-BOOL HMDeviceHandler::SetThreadContext(PHMHANDLEDATA pHMHandleData, const CONTEXT *lpContext)
+BOOL HMDeviceHandler::SetThreadContext(HANDLE hThread, PHMHANDLEDATA pHMHandleData, const CONTEXT *lpContext)
 {
   dprintf(("KERNEL32: ERROR: HandleManager::DeviceHandler::SetThreadContext %08xh",
            pHMHandleData->hHMHandle));
 
-  return ERROR_INVALID_HANDLE;
+  return FALSE;
 }
 /*****************************************************************************
@@ -1568,10 +1568,10 @@
  * Author    : SvL
  *****************************************************************************/
-BOOL HMDeviceHandler::TerminateThread(PHMHANDLEDATA pHMHandleData, DWORD exitcode)
+BOOL HMDeviceHandler::TerminateThread(HANDLE hThread, PHMHANDLEDATA pHMHandleData, DWORD exitcode)
 {
   dprintf(("KERNEL32: ERROR: HandleManager::DeviceHandler::TerminateThread %08xh",
            pHMHandleData->hHMHandle));
 
-  return ERROR_INVALID_HANDLE;
+  return FALSE;
 }
 /*****************************************************************************
@@ -1585,10 +1585,10 @@
  * Author    : SvL
  *****************************************************************************/
-DWORD  HMDeviceHandler::ResumeThread(PHMHANDLEDATA pHMHandleData)
+DWORD  HMDeviceHandler::ResumeThread(HANDLE hThread, PHMHANDLEDATA pHMHandleData)
 {
   dprintf(("KERNEL32: ERROR: HandleManager::DeviceHandler::ResumeThread %08xh",
            pHMHandleData->hHMHandle));
 
-  return ERROR_INVALID_HANDLE;
+  return -1;
 }
 /*****************************************************************************
@@ -1602,10 +1602,10 @@
  * Author    : SvL
  *****************************************************************************/
-BOOL HMDeviceHandler::GetExitCodeThread(PHMHANDLEDATA pHMHandleData, LPDWORD lpExitCode)
+BOOL HMDeviceHandler::GetExitCodeThread(HANDLE hThread, PHMHANDLEDATA pHMHandleData, LPDWORD lpExitCode)
 {
   dprintf(("KERNEL32: ERROR: HandleManager::DeviceHandler::GetExitCodeThread %08xh",
            pHMHandleData->hHMHandle));
 
-  return ERROR_INVALID_HANDLE;
+  return FALSE;
 }
 /*****************************************************************************
@@ -1619,5 +1619,5 @@
  * Author    : SvL
  *****************************************************************************/
-BOOL HMDeviceHandler::SetThreadTerminated(PHMHANDLEDATA pHMHandleData)
+BOOL HMDeviceHandler::SetThreadTerminated(HANDLE hThread, PHMHANDLEDATA pHMHandleData)
 {
     return FALSE;
Index: trunk/src/kernel32/hmdevice.h
===================================================================
--- trunk/src/kernel32/hmdevice.h	(revision 7530)
+++ trunk/src/kernel32/hmdevice.h	(revision 7532)
@@ -1,3 +1,3 @@
-/* $Id: hmdevice.h,v 1.30 2001-11-26 14:54:00 sandervl Exp $ */
+/* $Id: hmdevice.h,v 1.31 2001-12-03 12:13:08 sandervl Exp $ */
 
 /*
@@ -399,16 +399,16 @@
                              BOOL                   fFirstThread);
 
- virtual INT    GetThreadPriority(PHMHANDLEDATA pHMHandleData);
- virtual DWORD  SuspendThread(PHMHANDLEDATA pHMHandleData);
- virtual BOOL   SetThreadPriority(PHMHANDLEDATA pHMHandleData, int priority);
-
- virtual BOOL   GetThreadContext(PHMHANDLEDATA pHMHandleData, PCONTEXT lpContext);
- virtual BOOL   SetThreadContext(PHMHANDLEDATA pHMHandleData, const CONTEXT *lpContext);
-
- virtual BOOL   TerminateThread(PHMHANDLEDATA pHMHandleData, DWORD exitcode);
- virtual DWORD  ResumeThread(PHMHANDLEDATA pHMHandleData);
- virtual BOOL   SetThreadTerminated(PHMHANDLEDATA pHMHandleData);
-
- virtual BOOL   GetExitCodeThread(PHMHANDLEDATA pHMHandleData, LPDWORD lpExitCode);
+ virtual INT    GetThreadPriority(HANDLE hThread, PHMHANDLEDATA pHMHandleData);
+ virtual DWORD  SuspendThread(HANDLE hThread, PHMHANDLEDATA pHMHandleData);
+ virtual BOOL   SetThreadPriority(HANDLE hThread, PHMHANDLEDATA pHMHandleData, int priority);
+
+ virtual BOOL   GetThreadContext(HANDLE hThread, PHMHANDLEDATA pHMHandleData, PCONTEXT lpContext);
+ virtual BOOL   SetThreadContext(HANDLE hThread, PHMHANDLEDATA pHMHandleData, const CONTEXT *lpContext);
+
+ virtual BOOL   TerminateThread(HANDLE hThread, PHMHANDLEDATA pHMHandleData, DWORD exitcode);
+ virtual DWORD  ResumeThread(HANDLE hThread, PHMHANDLEDATA pHMHandleData);
+ virtual BOOL   SetThreadTerminated(HANDLE hThread, PHMHANDLEDATA pHMHandleData);
+
+ virtual BOOL   GetExitCodeThread(HANDLE hThread, PHMHANDLEDATA pHMHandleData, LPDWORD lpExitCode);
 
  /* Named pipes */
Index: trunk/src/kernel32/hmthread.cpp
===================================================================
--- trunk/src/kernel32/hmthread.cpp	(revision 7530)
+++ trunk/src/kernel32/hmthread.cpp	(revision 7532)
@@ -1,3 +1,3 @@
-/* $Id: hmthread.cpp,v 1.8 2001-06-06 18:59:57 phaller Exp $ */
+/* $Id: hmthread.cpp,v 1.9 2001-12-03 12:13:08 sandervl Exp $ */
 
 /*
@@ -21,7 +21,9 @@
 #include <string.h>
 #include <misc.h>
+#include <wprocess.h>
 
 #include <HandleManager.H>
 #include "HMThread.h"
+#include "oslibdos.h"
 
 #include <win\thread.h>
@@ -61,7 +63,8 @@
   winthread = new Win32Thread(lpStartAddr, lpvThreadParm, fdwCreate, pHMHandleData->hHMHandle);
 
-  if(winthread == 0)
-    return(0);
-
+  if(winthread == 0) {
+      SetLastError(ERROR_NOT_ENOUGH_MEMORY);
+      return(0);
+  }
   // @@@PH Note: with debug code enabled, ODIN might request more stack space!
   //SvL: Also need more stack in release build (RealPlayer 7 sometimes runs
@@ -85,32 +88,54 @@
 //******************************************************************************
 //******************************************************************************
-INT HMDeviceThreadClass::GetThreadPriority(PHMHANDLEDATA pHMHandleData)
-{
+DWORD HMDeviceThreadClass::SuspendThread(HANDLE hThread, PHMHANDLEDATA pHMHandleData)
+{
+    dprintf(("SuspendThread %08xh)\n", pHMHandleData->hHMHandle));
+
+    return O32_SuspendThread(pHMHandleData->hHMHandle);
+}
+//******************************************************************************
+//******************************************************************************
+INT HMDeviceThreadClass::GetThreadPriority(HANDLE hThread, PHMHANDLEDATA pHMHandleData)
+{
+    TEB *teb;
+
     dprintf(("GetThreadPriority(%08xh)\n", pHMHandleData->hHMHandle));
 
-    return O32_GetThreadPriority(pHMHandleData->hHMHandle);
-}
-//******************************************************************************
-//******************************************************************************
-DWORD HMDeviceThreadClass::SuspendThread(PHMHANDLEDATA pHMHandleData)
-{
-    dprintf(("SuspendThread %08xh)\n", pHMHandleData->hHMHandle));
-
-    return O32_SuspendThread(pHMHandleData->hHMHandle);
-}
-//******************************************************************************
-//******************************************************************************
-BOOL HMDeviceThreadClass::SetThreadPriority(PHMHANDLEDATA pHMHandleData, int priority)
-{
-    dprintf(("SetThreadPriority (%08xh,%08xh)\n",
-             pHMHandleData->hHMHandle,
-             priority));
-
-    return O32_SetThreadPriority(pHMHandleData->hHMHandle, priority);
+    teb = GetTEBFromThreadHandle(hThread);
+    if(teb == NULL) {
+        dprintf(("!WARNING!: TEB not found!!"));
+        SetLastError(ERROR_INVALID_HANDLE);
+        return THREAD_PRIORITY_ERROR_RETURN;
+    }
+    return teb->delta_priority;
+}
+//******************************************************************************
+//******************************************************************************
+BOOL HMDeviceThreadClass::SetThreadPriority(HANDLE hThread, PHMHANDLEDATA pHMHandleData, int priority)
+{
+    TEB  *teb;
+
+    dprintf(("SetThreadPriority (%08xh,%08xh)", pHMHandleData->hHMHandle, priority));
+
+    teb = GetTEBFromThreadHandle(hThread);
+    if(teb == NULL) {
+        dprintf(("!WARNING!: TEB not found!!"));
+        SetLastError(ERROR_INVALID_HANDLE);
+        return THREAD_PRIORITY_ERROR_RETURN;
+    }
+    DWORD ret = OSLibDosSetPriority(teb->o.odin.threadId, priority);
+    if(ret == ERROR_SUCCESS) {
+        teb->delta_priority = priority;
+        return TRUE;
+    }
+    else {
+        dprintf(("DosSetPriority failed with rc %d", ret));
+        return FALSE;
+    }
 }
 //******************************************************************************
 //TODO: Implement this??
 //******************************************************************************
-BOOL HMDeviceThreadClass::GetThreadContext(PHMHANDLEDATA pHMHandleData, PCONTEXT lpContext)
+BOOL HMDeviceThreadClass::GetThreadContext(HANDLE hThread, PHMHANDLEDATA pHMHandleData, PCONTEXT lpContext)
 {
   dprintf(("GetThreadContext NOT IMPLEMENTED!! (TRUE)\n"));
@@ -130,5 +155,5 @@
 //TODO: Implement this??
 //******************************************************************************
-BOOL HMDeviceThreadClass::SetThreadContext(PHMHANDLEDATA pHMHandleData, const CONTEXT *lpContext)
+BOOL HMDeviceThreadClass::SetThreadContext(HANDLE hThread, PHMHANDLEDATA pHMHandleData, const CONTEXT *lpContext)
 {
   dprintf(("SetThreadContext NOT IMPLEMENTED!!\n"));
@@ -138,5 +163,5 @@
 //******************************************************************************
 //******************************************************************************
-BOOL HMDeviceThreadClass::TerminateThread(PHMHANDLEDATA pHMHandleData, DWORD exitcode)
+BOOL HMDeviceThreadClass::TerminateThread(HANDLE hThread, PHMHANDLEDATA pHMHandleData, DWORD exitcode)
 {
     dprintf(("TerminateThread (%08xh,%08xh)\n",
@@ -149,5 +174,5 @@
 //******************************************************************************
 //******************************************************************************
-BOOL HMDeviceThreadClass::SetThreadTerminated(PHMHANDLEDATA pHMHandleData)
+BOOL HMDeviceThreadClass::SetThreadTerminated(HANDLE hThread, PHMHANDLEDATA pHMHandleData)
 {
     pHMHandleData->dwUserData = THREAD_TERMINATED;
@@ -156,5 +181,5 @@
 //******************************************************************************
 //******************************************************************************
-DWORD HMDeviceThreadClass::ResumeThread(PHMHANDLEDATA pHMHandleData)
+DWORD HMDeviceThreadClass::ResumeThread(HANDLE hThread, PHMHANDLEDATA pHMHandleData)
 {
     dprintf(("ResumeThread (%08xh)\n",
@@ -165,5 +190,5 @@
 //******************************************************************************
 //******************************************************************************
-BOOL HMDeviceThreadClass::GetExitCodeThread(PHMHANDLEDATA pHMHandleData, LPDWORD lpExitCode)
+BOOL HMDeviceThreadClass::GetExitCodeThread(HANDLE hThread, PHMHANDLEDATA pHMHandleData, LPDWORD lpExitCode)
 {
     dprintf(("GetExitCodeThread (%08xh,%08xh)\n",
Index: trunk/src/kernel32/hmthread.h
===================================================================
--- trunk/src/kernel32/hmthread.h	(revision 7530)
+++ trunk/src/kernel32/hmthread.h	(revision 7532)
@@ -1,3 +1,3 @@
-/* $Id: hmthread.h,v 1.3 2001-04-26 13:22:47 sandervl Exp $ */
+/* $Id: hmthread.h,v 1.4 2001-12-03 12:13:09 sandervl Exp $ */
 
 /*
@@ -34,25 +34,25 @@
 
   /* this is a handler method for calls to WaitForSingleObject */
-  virtual DWORD WaitForSingleObject(PHMHANDLEDATA pHMHandleData,
-                                    DWORD  dwTimeout);
+  virtual DWORD  WaitForSingleObject(PHMHANDLEDATA pHMHandleData,
+                                     DWORD  dwTimeout);
 
   /* this is a handler method for calls to WaitForSingleObjectEx */
-  virtual DWORD WaitForSingleObjectEx(PHMHANDLEDATA pHMHandleData,
-                                      DWORD  dwTimeout,
-                                      BOOL   fAlertable);
+  virtual DWORD  WaitForSingleObjectEx(PHMHANDLEDATA pHMHandleData,
+                                       DWORD  dwTimeout,
+                                       BOOL   fAlertable);
 
-  virtual INT    GetThreadPriority(PHMHANDLEDATA pHMHandleData);
-  virtual DWORD  SuspendThread(PHMHANDLEDATA pHMHandleData);
-  virtual BOOL   SetThreadPriority(PHMHANDLEDATA pHMHandleData, int priority);
+  virtual INT    GetThreadPriority(HANDLE hThread, PHMHANDLEDATA pHMHandleData);
+  virtual DWORD  SuspendThread(HANDLE hThread, PHMHANDLEDATA pHMHandleData);
+  virtual BOOL   SetThreadPriority(HANDLE hThread, PHMHANDLEDATA pHMHandleData, int priority);
 
-  virtual BOOL   GetThreadContext(PHMHANDLEDATA pHMHandleData, PCONTEXT lpContext);
-  virtual BOOL   SetThreadContext(PHMHANDLEDATA pHMHandleData, const CONTEXT *lpContext);
+  virtual BOOL   GetThreadContext(HANDLE hThread, PHMHANDLEDATA pHMHandleData, PCONTEXT lpContext);
+  virtual BOOL   SetThreadContext(HANDLE hThread, PHMHANDLEDATA pHMHandleData, const CONTEXT *lpContext);
  
-  virtual BOOL   TerminateThread(PHMHANDLEDATA pHMHandleData, DWORD exitcode);
-  virtual DWORD  ResumeThread(PHMHANDLEDATA pHMHandleData);
-  virtual BOOL   GetExitCodeThread(PHMHANDLEDATA pHMHandleData, LPDWORD lpExitCode);
-  virtual BOOL   SetThreadTerminated(PHMHANDLEDATA pHMHandleData);
+  virtual BOOL   TerminateThread(HANDLE hThread, PHMHANDLEDATA pHMHandleData, DWORD exitcode);
+  virtual DWORD  ResumeThread(HANDLE hThread, PHMHANDLEDATA pHMHandleData);
+  virtual BOOL   GetExitCodeThread(HANDLE hThread, PHMHANDLEDATA pHMHandleData, LPDWORD lpExitCode);
+  virtual BOOL   SetThreadTerminated(HANDLE hThread, PHMHANDLEDATA pHMHandleData);
 
-  virtual BOOL CloseHandle(PHMHANDLEDATA pHMHandleData);
+  virtual BOOL   CloseHandle(PHMHANDLEDATA pHMHandleData);
 };
 
Index: trunk/src/kernel32/oslibdos.cpp
===================================================================
--- trunk/src/kernel32/oslibdos.cpp	(revision 7530)
+++ trunk/src/kernel32/oslibdos.cpp	(revision 7532)
@@ -1,3 +1,3 @@
-/* $Id: oslibdos.cpp,v 1.88 2001-11-29 13:38:51 sandervl Exp $ */
+/* $Id: oslibdos.cpp,v 1.89 2001-12-03 12:13:09 sandervl Exp $ */
 /*
  * Wrappers for OS/2 Dos* API
@@ -2899,4 +2899,58 @@
 //******************************************************************************
 //******************************************************************************
+DWORD OSLibDosSetPriority(ULONG tid, int priority)
+{
+    DWORD  ret, os2priorityclass;
+    LONG   os2prioritydelta;
+    APIRET rc;
+
+    switch(priority) 
+    {
+    case THREAD_PRIORITY_IDLE_W:
+        os2priorityclass = PRTYC_IDLETIME;
+        os2prioritydelta = 0;
+        break;
+    case THREAD_PRIORITY_LOWEST_W:
+        os2priorityclass = PRTYC_REGULAR;
+        os2prioritydelta = PRTYD_MINIMUM;
+        break;
+    case THREAD_PRIORITY_BELOW_NORMAL_W:
+        os2priorityclass = PRTYC_REGULAR;
+        os2prioritydelta = -15;
+        break;
+    case THREAD_PRIORITY_NORMAL_W:
+        os2priorityclass = PRTYC_REGULAR;
+        os2prioritydelta = 0;
+        break;
+    case THREAD_PRIORITY_ABOVE_NORMAL_W:
+        os2priorityclass = PRTYC_REGULAR;
+        os2prioritydelta = 15;
+        break;
+    case THREAD_PRIORITY_HIGHEST_W:
+        os2priorityclass = PRTYC_REGULAR;
+        os2prioritydelta = PRTYD_MAXIMUM;
+        break;
+    case THREAD_PRIORITY_TIME_CRITICAL_W:
+        os2priorityclass = PRTYC_TIMECRITICAL;
+        os2prioritydelta = 0;
+        break;
+    default:
+        dprintf(("!WARNING!: Invalid priority!!"));
+        SetLastError(ERROR_INVALID_PARAMETER_W);
+        return ERROR_INVALID_PARAMETER_W;
+    }
+    rc = DosSetPriority(PRTYS_THREAD, os2priorityclass, os2prioritydelta, tid);
+    ret = error2WinError(rc, ERROR_INVALID_PARAMETER);
+    SetLastError(ret);
+    return ret;
+}
+//******************************************************************************
+//******************************************************************************
+void  OSLibDosSleep(ULONG msecs)
+{
+  DosSleep(msecs);
+}
+//******************************************************************************
+//******************************************************************************
 DWORD OSLibDosDevConfig(PVOID pdevinfo,
                          ULONG item)
@@ -2904,2 +2958,4 @@
   return (DWORD)DosDevConfig(pdevinfo, item);
 }
+//******************************************************************************
+//******************************************************************************
Index: trunk/src/kernel32/oslibdos.h
===================================================================
--- trunk/src/kernel32/oslibdos.h	(revision 7530)
+++ trunk/src/kernel32/oslibdos.h	(revision 7532)
@@ -1,3 +1,3 @@
-/* $Id: oslibdos.h,v 1.40 2001-11-29 10:53:28 phaller Exp $ */
+/* $Id: oslibdos.h,v 1.41 2001-12-03 12:13:09 sandervl Exp $ */
 
 /*
@@ -359,4 +359,7 @@
 
 DWORD OSLibDosDevConfig(PVOID pdevinfo, ULONG item);
+void  OSLibDosSleep(ULONG msecs);
+
+DWORD OSLibDosSetPriority(ULONG tid, int priority);
 
 #endif //__OSLIBDOS_H__
Index: trunk/src/kernel32/thread.cpp
===================================================================
--- trunk/src/kernel32/thread.cpp	(revision 7530)
+++ trunk/src/kernel32/thread.cpp	(revision 7532)
@@ -1,3 +1,3 @@
-/* $Id: thread.cpp,v 1.37 2001-12-01 20:41:37 sandervl Exp $ */
+/* $Id: thread.cpp,v 1.38 2001-12-03 12:13:10 sandervl Exp $ */
 
 /*
@@ -39,10 +39,5 @@
 ODINDEBUGCHANNEL(KERNEL32-THREAD)
 
-
-// The function GetThreadTEB() is defined in wprocess.cpp
-// This macro is for performance improvement only.
-// DWORD TIBFlatPtr is exported from wprocess.cpp
-#define GetThreadTEB() (TIBFlatPtr) ? ((TEB *)*TIBFlatPtr) : 0
-
+static ULONG priorityclass = NORMAL_PRIORITY_CLASS;
 
 //******************************************************************************
@@ -74,7 +69,8 @@
     return teb->o.odin.hThread;
 }
-
+//******************************************************************************
 // these two debugging functions allow access to a
 // calldepth counter inside the TEB block of each thread
+//******************************************************************************
 ULONG WIN32API dbg_GetThreadCallDepth()
 {
@@ -91,6 +87,6 @@
 #endif
 }
-
-
+//******************************************************************************
+//******************************************************************************
 void WIN32API dbg_IncThreadCallDepth()
 {
@@ -103,7 +99,7 @@
 #endif
 }
-
-
+//******************************************************************************
 #define MAX_CALLSTACK_SIZE 128
+//******************************************************************************
 void WIN32API dbg_ThreadPushCall(char *pszCaller)
 {
@@ -130,6 +126,6 @@
 #endif
 }
-
-
+//******************************************************************************
+//******************************************************************************
 void WIN32API dbg_DecThreadCallDepth()
 {
@@ -142,6 +138,6 @@
 #endif
 }
-
-
+//******************************************************************************
+//******************************************************************************
 void WIN32API dbg_ThreadPopCall()
 {
@@ -165,5 +161,6 @@
 #endif
 }
-
+//******************************************************************************
+//******************************************************************************
 char* WIN32API dbg_GetLastCallerName()
 {
@@ -187,6 +184,4 @@
   return NULL;
 }
-
-
 //******************************************************************************
 //******************************************************************************
@@ -247,4 +242,28 @@
 //******************************************************************************
 //******************************************************************************
+VOID WIN32API Sleep(DWORD mSecs)
+{
+    dprintf2(("KERNEL32: Sleep %d", mSecs));
+    OSLibDosSleep(mSecs);
+}
+//******************************************************************************
+//******************************************************************************
+DWORD WIN32API GetPriorityClass(HANDLE hProcess)
+{
+    dprintf(("KERNEL32: GetPriorityClass %x", hProcess));
+    return priorityclass;
+//    return O32_GetPriorityClass(hProcess);
+}
+//******************************************************************************
+//******************************************************************************
+BOOL WIN32API SetPriorityClass(HANDLE hProcess, DWORD dwPriority)
+{
+    dprintf(("KERNEL32: SetPriorityClass %x %x", hProcess, dwPriority));
+    priorityclass = dwPriority;
+    return TRUE;
+//    return O32_SetPriorityClass(hProcess, dwPriority);
+}
+//******************************************************************************
+//******************************************************************************
 Win32Thread::Win32Thread(LPTHREAD_START_ROUTINE pUserCallback, LPVOID lpData, DWORD dwFlags, HANDLE hThread)
 {
Index: trunk/src/kernel32/wprocess.cpp
===================================================================
--- trunk/src/kernel32/wprocess.cpp	(revision 7530)
+++ trunk/src/kernel32/wprocess.cpp	(revision 7532)
@@ -1,3 +1,3 @@
-/* $Id: wprocess.cpp,v 1.138 2001-12-01 20:41:38 sandervl Exp $ */
+/* $Id: wprocess.cpp,v 1.139 2001-12-03 12:13:10 sandervl Exp $ */
 
 /*
@@ -183,5 +183,6 @@
     winteb->tls_ptr     = &winteb->tls_array[0];   /* 2c Pointer to TLS array */
     winteb->process     = &ProcessPDB;             /* 30 owning process (used by NT3.51 applets)*/
-
+    
+    winteb->delta_priority  = THREAD_PRIORITY_NORMAL;
     winteb->process         = &ProcessPDB;
 ////    winteb->exit_code       = 0x103; /* STILL_ACTIVE */
@@ -1935,25 +1936,4 @@
   else  return O32_WaitForInputIdle(hProcess, dwTimeOut);
 }
-//******************************************************************************
-//******************************************************************************
-VOID WIN32API Sleep(DWORD arg1)
-{
-    dprintf2(("KERNEL32:  Sleep %d\n", arg1));
-    O32_Sleep(arg1);
-}
-//******************************************************************************
-//******************************************************************************
-DWORD WIN32API GetPriorityClass(HANDLE hProcess)
-{
-    dprintf(("KERNEL32: GetPriorityClass %x", hProcess));
-    return O32_GetPriorityClass(hProcess);
-}
-//******************************************************************************
-//******************************************************************************
-BOOL WIN32API SetPriorityClass(HANDLE hProcess, DWORD dwPriority)
-{
-    dprintf(("KERNEL32: SetPriorityClass %x %x", hProcess, dwPriority));
-    return O32_SetPriorityClass(hProcess, dwPriority);
-}
 /**********************************************************************
  * LoadModule    (KERNEL32.499)
