Sebastian Lackner : server: Increase size of PID table and do not reuse recently freed ptids.

Alexandre Julliard julliard at wine.codeweavers.com
Mon Apr 25 09:47:13 CDT 2016


Module: wine
Branch: master
Commit: 1025ed38c07102aa0bc4fb4e66b37ba35e5e9bd7
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=1025ed38c07102aa0bc4fb4e66b37ba35e5e9bd7

Author: Sebastian Lackner <sebastian at fds-team.de>
Date:   Thu Apr 21 12:34:00 2016 +0200

server: Increase size of PID table and do not reuse recently freed ptids.

Signed-off-by: Sebastian Lackner <sebastian at fds-team.de>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 server/process.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/server/process.c b/server/process.c
index 11d2987..d2eab45 100644
--- a/server/process.c
+++ b/server/process.c
@@ -338,6 +338,7 @@ static unsigned int used_ptid_entries;      /* number of entries in use */
 static unsigned int alloc_ptid_entries;     /* number of allocated entries */
 static unsigned int next_free_ptid;         /* next free entry */
 static unsigned int last_free_ptid;         /* last free entry */
+static unsigned int num_free_ptids;         /* number of free ptids */
 
 static void kill_all_processes(void);
 
@@ -354,16 +355,17 @@ unsigned int alloc_ptid( void *ptr )
         id = used_ptid_entries + PTID_OFFSET;
         entry = &ptid_entries[used_ptid_entries++];
     }
-    else if (next_free_ptid)
+    else if (next_free_ptid && num_free_ptids >= 256)
     {
         id = next_free_ptid;
         entry = &ptid_entries[id - PTID_OFFSET];
         if (!(next_free_ptid = entry->next)) last_free_ptid = 0;
+        num_free_ptids--;
     }
     else  /* need to grow the array */
     {
         unsigned int count = alloc_ptid_entries + (alloc_ptid_entries / 2);
-        if (!count) count = 64;
+        if (!count) count = 512;
         if (!(entry = realloc( ptid_entries, count * sizeof(*entry) )))
         {
             set_error( STATUS_NO_MEMORY );
@@ -390,8 +392,8 @@ void free_ptid( unsigned int id )
     /* append to end of free list so that we don't reuse it too early */
     if (last_free_ptid) ptid_entries[last_free_ptid - PTID_OFFSET].next = id;
     else next_free_ptid = id;
-
     last_free_ptid = id;
+    num_free_ptids++;
 }
 
 /* retrieve the pointer corresponding to a process or thread id */




More information about the wine-cvs mailing list