[ros-dev] free handle table entries

Thomas Weidenmueller w3seek at reactos.com
Sat Mar 19 11:56:33 CET 2005


Hartmut Birr wrote:

>Hi,
>
>currently the free handle entry list is a lifo list. This is not a good
>solution for process and thread ids because a id from a currently
>deleted process or thread is valid again after a very short time. I
>would like it to change the free list to a fifo list by using a double
>linked list. The u2 part of  an entry has enough room for a list entry
>instead an index.
>  
>
Actually, win 2000 uses a lifo list, you can see this by compiling and 
running the attached code. Each time a thread is created and terminated 
it receives the same client id. win xp however seems to mark client ids 
as invalid for a certain amount of time or uses a fifo list, I haven't 
investigated further though, the test code however displays different 
client ids in XP.

Since win2000 does it the same way, I think we shouldn't worry too much. 
We however could add some debugging stuff where deleted client id 
handles are not destroyed but marked as invalid to track down wrong code 
easier.

Best Regards,
Thomas
-------------- next part --------------
#include <windows.h>
#include <stdio.h>

DWORD WINAPI ThrdProc(LPVOID lpParameter)
{
  return 0;
}

int main(int argc, char* argv[])
{  
   for(;;)
   {
     DWORD tid;
     
     HANDLE hThread = CreateThread(NULL, 0, ThrdProc, NULL, 0, &tid);
     if(hThread != NULL)
     {
       printf("tid: %d\n", (int)tid);
       WaitForSingleObject(hThread, INFINITE);
       CloseHandle(hThread);
     }
     else
     {
       printf("CreateThread failed!\n");
       return 0;
     }
   }

   return(0);
}


More information about the Ros-dev mailing list