From a3c5ad4e77e1498e919eb84c8248bb801914594c Mon Sep 17 00:00:00 2001 From: Peter Hunnisett Date: Fri, 28 Feb 2003 21:50:47 +0000 Subject: [PATCH] Suspended threads should not acquire synchronization objects. --- server/process.c | 8 ++++++-- server/thread.c | 11 +++++++++-- server/thread.h | 1 + 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/server/process.c b/server/process.c index 785c4cbb495..c3cf4366d7f 100644 --- a/server/process.c +++ b/server/process.c @@ -673,7 +673,11 @@ void resume_process( struct process *process ) while (thread) { struct thread *next = thread->proc_next; - if (!thread->suspend) continue_thread( thread ); + if (!thread->suspend) + { + continue_thread( thread ); + wake_thread( thread ); + } thread = next; } } @@ -818,7 +822,7 @@ static void write_process_memory( struct process *process, int *addr, size_t len if (!check_process_write_access( thread, addr, len )) { set_error( STATUS_ACCESS_DENIED ); - return; + goto done; } /* first word is special */ if (len > 1) diff --git a/server/thread.c b/server/thread.c index 1a9244f8323..7e4ae690699 100644 --- a/server/thread.c +++ b/server/thread.c @@ -319,7 +319,11 @@ int resume_thread( struct thread *thread ) int old_count = thread->suspend; if (thread->suspend > 0) { - if (!(--thread->suspend + thread->process->suspend)) continue_thread( thread ); + if (!(--thread->suspend + thread->process->suspend)) + { + continue_thread( thread ); + wake_thread( thread ); + } } return old_count; } @@ -403,6 +407,9 @@ static int check_wait( struct thread *thread ) struct thread_wait *wait = thread->wait; struct wait_queue_entry *entry = wait->queues; + /* Suspended threads may not acquire locks */ + if( thread->process->suspend + thread->suspend > 0 ) return -1; + assert( wait ); if (wait->flags & SELECT_ALL) { @@ -465,7 +472,7 @@ static int send_thread_wakeup( struct thread *thread, void *cookie, int signaled /* attempt to wake up a thread */ /* return >0 if OK, 0 if the wait condition is still not satisfied */ -static int wake_thread( struct thread *thread ) +int wake_thread( struct thread *thread ) { int signaled, count; void *cookie; diff --git a/server/thread.h b/server/thread.h index a46f3897602..6e244c6c1a5 100644 --- a/server/thread.h +++ b/server/thread.h @@ -112,6 +112,7 @@ extern struct thread *get_thread_from_handle( obj_handle_t handle, unsigned int extern struct thread *get_thread_from_pid( int pid ); extern int suspend_thread( struct thread *thread, int check_limit ); extern int resume_thread( struct thread *thread ); +extern int wake_thread( struct thread *thread ); extern int add_queue( struct object *obj, struct wait_queue_entry *entry ); extern void remove_queue( struct object *obj, struct wait_queue_entry *entry ); extern void kill_thread( struct thread *thread, int violent_death );