[ros-diffs] [fireball] 49404: - Stop abusing non paged pool in arwinss. - Fix different time units usage in message queue code. - My timeout implementation still s..ks b..ls. See issue #5222 for more details.

fireball at svn.reactos.org fireball at svn.reactos.org
Mon Nov 1 14:36:47 UTC 2010


Author: fireball
Date: Mon Nov  1 14:36:45 2010
New Revision: 49404

URL: http://svn.reactos.org/svn/reactos?rev=49404&view=rev
Log:
- Stop abusing non paged pool in arwinss.
- Fix different time units usage in message queue code.
- My timeout implementation still s..ks b..ls.
See issue #5222 for more details.

Modified:
    branches/arwinss/reactos/subsystems/win32/win32k/include/winesup.h
    branches/arwinss/reactos/subsystems/win32/win32k/wine/queue.c
    branches/arwinss/reactos/subsystems/win32/win32k/wine/winesup.c

Modified: branches/arwinss/reactos/subsystems/win32/win32k/include/winesup.h
URL: http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win32/win32k/include/winesup.h?rev=49404&r1=49403&r2=49404&view=diff
==============================================================================
--- branches/arwinss/reactos/subsystems/win32/win32k/include/winesup.h [iso-8859-1] (original)
+++ branches/arwinss/reactos/subsystems/win32/win32k/include/winesup.h [iso-8859-1] Mon Nov  1 14:36:45 2010
@@ -129,11 +129,20 @@
     KDPC Dpc;
 };
 
-enum timeout_t;
 typedef PKDEFERRED_ROUTINE timeout_callback;
 #define TICKS_PER_SEC 10000000
 void remove_timeout_user( struct timeout_user *user );
 struct timeout_user *add_timeout_user( timeout_t when, timeout_callback func, void *private );
+
+VOID FORCEINLINE
+get_current_time(timeout_t *value)
+{
+    LARGE_INTEGER time;
+    KeQuerySystemTime(&time);
+
+    *value = time.QuadPart / 10;
+}
+
 
 thread_id_t get_thread_id (PTHREADINFO Thread);
 process_id_t get_process_id(PPROCESSINFO Process);

Modified: branches/arwinss/reactos/subsystems/win32/win32k/wine/queue.c
URL: http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win32/win32k/wine/queue.c?rev=49404&r1=49403&r2=49404&view=diff
==============================================================================
--- branches/arwinss/reactos/subsystems/win32/win32k/wine/queue.c [iso-8859-1] (original)
+++ branches/arwinss/reactos/subsystems/win32/win32k/wine/queue.c [iso-8859-1] Mon Nov  1 14:36:45 2010
@@ -278,7 +278,7 @@
         queue->timeout         = NULL;
         queue->input           = (struct thread_input *)grab_object( input );
         queue->hooks           = NULL;
-        KeQuerySystemTime((PLARGE_INTEGER)&queue->last_get_msg);
+        get_current_time(&queue->last_get_msg);
         list_init( &queue->send_result );
         list_init( &queue->callback_result );
         list_init( &queue->pending_timers );
@@ -585,7 +585,7 @@
                                                     struct msg_queue *recv_queue,
                                                     struct message *msg, timeout_t timeout )
 {
-    struct message_result *result = ExAllocatePool( NonPagedPool, sizeof(*result) );
+    struct message_result *result = ExAllocatePool( PagedPool, sizeof(*result) );
     if (result)
     {
         result->msg       = msg;
@@ -804,11 +804,11 @@
 static int is_queue_hung( struct msg_queue *queue )
 {
     //struct wait_queue_entry *entry;
-    LARGE_INTEGER current_time;
-
-    KeQuerySystemTime(&current_time);
-
-    if (current_time.QuadPart - queue->last_get_msg <= 5 * TICKS_PER_SEC)
+    timeout_t current_time;
+
+    get_current_time(&current_time);
+
+    if (current_time - queue->last_get_msg <= 5 * TICKS_PER_SEC)
         return 0;  /* less than 5 seconds since last get message -> not hung */
 
 #if 0
@@ -1097,8 +1097,6 @@
     struct msg_queue *queue = Context;
     PQUEUE_WORKER_CONTEXT work_context;
 
-    ASSERT(queue);
-
     /* Allocate memory for the work iteam */
     work_context = ExAllocatePool(NonPagedPool, sizeof(QUEUE_WORKER_CONTEXT));
 
@@ -1133,11 +1131,11 @@
 /* restart an expired timer */
 static void restart_timer( struct msg_queue *queue, struct timer *timer )
 {
-    LARGE_INTEGER current_time;
-    KeQuerySystemTime(&current_time);
+    timeout_t current_time;
+    get_current_time(&current_time);
 
     list_remove( &timer->entry );
-    while (timer->when <= current_time.QuadPart) timer->when += (timeout_t)timer->rate * 10000;
+    while (timer->when <= current_time) timer->when += (timeout_t)timer->rate * 10000;
     link_timer( queue, timer );
     set_next_timer( queue );
 }
@@ -1165,15 +1163,15 @@
 /* add a timer */
 static struct timer *set_timer( struct msg_queue *queue, unsigned int rate )
 {
-    LARGE_INTEGER current_time;
+    timeout_t current_time;
     struct timer *timer;
-    KeQuerySystemTime(&current_time);
+    get_current_time(&current_time);
 
     timer = mem_alloc( sizeof(*timer) );
     if (timer)
     {
         timer->rate = max( rate, 1 );
-        timer->when = current_time.QuadPart + (timeout_t)timer->rate * 10000;
+        timer->when = current_time + (timeout_t)timer->rate * 10000;
         link_timer( queue, timer );
         /* check if we replaced the next timer */
         if (list_head( &queue->pending_timers ) == &timer->entry) set_next_timer( queue );
@@ -1564,7 +1562,7 @@
 
     if (!thread) return;
 
-    if (thread->queue && (msg = ExAllocatePool( NonPagedPool, sizeof(*msg) )))
+    if (thread->queue && (msg = ExAllocatePool( PagedPool, sizeof(*msg) )))
     {
         msg->type      = MSG_POSTED;
         msg->win       = get_user_full_handle( win );
@@ -1591,7 +1589,7 @@
 {
     struct message *msg;
 
-    if (thread->queue && (msg = ExAllocatePool( NonPagedPool, sizeof(*msg) )))
+    if (thread->queue && (msg = ExAllocatePool( PagedPool, sizeof(*msg) )))
     {
         struct winevent_msg_data *data;
 
@@ -1753,7 +1751,7 @@
         return;
     }
 
-    if ((msg = ExAllocatePool( NonPagedPool, sizeof(*msg) )))
+    if ((msg = ExAllocatePool( PagedPool, sizeof(*msg) )))
     {
         msg->type      = req->type;
         msg->win       = get_user_full_handle( req->win );
@@ -1844,7 +1842,7 @@
     data->y    = req->y;
     data->info = req->info;
 
-    if ((msg = ExAllocatePool( NonPagedPool, sizeof(*msg) )))
+    if ((msg = ExAllocatePool( PagedPool, sizeof(*msg) )))
     {
         msg->type      = MSG_HARDWARE;
         msg->win       = get_user_full_handle( req->win );
@@ -1878,7 +1876,7 @@
 /* get a message from the current queue */
 DECL_HANDLER(get_message)
 {
-    LARGE_INTEGER current_time;
+    timeout_t current_time;
     struct timer *timer;
     struct list *ptr;
     PPROCESSINFO process = PsGetCurrentProcessWin32Process();
@@ -1889,8 +1887,8 @@
     reply->active_hooks = get_active_hooks();
 
     if (!queue) return;
-    KeQuerySystemTime(&current_time);
-    queue->last_get_msg = current_time.QuadPart;
+    get_current_time(&current_time);
+    queue->last_get_msg = current_time;
     if (!filter) filter = QS_ALLINPUT;
 
     /* first check for sent messages */

Modified: branches/arwinss/reactos/subsystems/win32/win32k/wine/winesup.c
URL: http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win32/win32k/wine/winesup.c?rev=49404&r1=49403&r2=49404&view=diff
==============================================================================
--- branches/arwinss/reactos/subsystems/win32/win32k/wine/winesup.c [iso-8859-1] (original)
+++ branches/arwinss/reactos/subsystems/win32/win32k/wine/winesup.c [iso-8859-1] Mon Nov  1 14:36:45 2010
@@ -54,12 +54,12 @@
     LARGE_INTEGER DueTime;
     struct timeout_user *TimeoutUser;
 
-    DueTime.QuadPart = (LONGLONG)when;
-
-    DPRINT("add_timeout_user(when %I64d, func %p)\n", when, func);
+    DueTime.QuadPart = (LONGLONG)when * 10;
 
     /* Allocate memory for timeout structure */
     TimeoutUser = ExAllocatePool(NonPagedPool, sizeof(struct timeout_user));
+
+    //DPRINT1("add_timeout_user(%p when %I64d, diff %I64d msecs, func %p)\n", TimeoutUser, when, secs, func);
 
     /* Initialize timer and DPC objects */
     KeInitializeTimer(&TimeoutUser->Timer);
@@ -74,7 +74,7 @@
 /* remove a timeout user */
 void remove_timeout_user( struct timeout_user *user )
 {
-    DPRINT("remove_timeout_user %p\n", user);
+    //DPRINT1("remove_timeout_user %p, current time %I64d\n", user, current_time);
 
     /* Cancel the timer */
     KeCancelTimer(&user->Timer);




More information about the Ros-diffs mailing list