OSDN Git Service

* miscfuncs.cc (low_priority_sleep): Correct thinko which caused SetPriority to
authorcgf <cgf>
Fri, 12 Dec 2003 04:15:31 +0000 (04:15 +0000)
committercgf <cgf>
Fri, 12 Dec 2003 04:15:31 +0000 (04:15 +0000)
be called unnecessarily.
* thread.cc (pthread::init_main_thread): Call new create_cancel_event function.
(pthread::precreate): Ditto.
(pthread::postcreate): Remove cancel_event creation.
(pthread::create_cancel_event): Define new function.
* thread.h (pthread::create_cancel_event): Declare new function.

winsup/cygwin/ChangeLog
winsup/cygwin/miscfuncs.cc
winsup/cygwin/thread.cc
winsup/cygwin/thread.h

index 3d1cab7..8cc59fd 100644 (file)
@@ -1,3 +1,14 @@
+2003-12-11  Christopher Faylor  <cgf@redhat.com>
+
+       * miscfuncs.cc (low_priority_sleep): Correct thinko which caused
+       SetPriority to be called unnecessarily.
+       * thread.cc (pthread::init_main_thread): Call new create_cancel_event
+       function.
+       (pthread::precreate): Ditto.
+       (pthread::postcreate): Remove cancel_event creation.
+       (pthread::create_cancel_event): Define new function.
+       * thread.h (pthread::create_cancel_event): Declare new function.
+
 2003-12-11  Brian Ford  <ford@vss.fsi.com>
 
        * fhandler_serial.cc (fhandler_serial::tcflush): Simplify.  Remove
 2003-12-03  Corinna Vinschen  <corinna@vinschen.de>
 
        * fhandler_disk_file.cc (fhandler_disk_file::lock): Use UINT32_MAX
-       instead of 0xffffffff.  Accomodate Win 9x bug in evaluating length
+       instead of 0xffffffff.  Accommodate Win 9x bug in evaluating length
        of area to lock when given length is 0.
 
 2003-12-03  Pierre Humblet <pierre.humblet@ieee.org>
        struct __flock64 *.
        * fhandler_disk_file.cc (fhandler_disk_file::lock): Ditto.  Rework
        to be 64 bit aware.
-       * fhandler.h: Accomodate above method argument changes.
+       * fhandler.h: Accommodate above method argument changes.
        * include/cygwin/types.h: Add struct __flock32 and __flock64.
        Define struct flock according to setting of __CYGWIN_USE_BIG_TYPES__.
        * include/cygwin/version.h: Bump API minor number.
        Use appropriate security attribute for process shared semaphores.
        (semaphore::semaphore): New constructor for named semaphores.
        (semaphore::~semaphore): Care for semaphore name.
-       (semaphore::_post): Accomodate failing ReleaseSemaphore. Use value
+       (semaphore::_post): Accommodate failing ReleaseSemaphore. Use value
        returned by ReleaseSemaphore vor currentvalue.
        (semaphore::_getvalue): New method.
        (semaphore::_timedwait): Ditto.
        orig_gid to saved_psid, saved_uid and saved_gid respectively.
        Rename methods orig_sid and set_orig_sid to saved_sid and set_saved_sid
        respectively.
-       * sec_helper.cc (sec_acl): Accomodate above changes.
+       * sec_helper.cc (sec_acl): Accommodate above changes.
        * spawn.cc (spawn_guts): Ditto.
        * uinfo.cc (uinfo_init): Ditto.
 
        * mmap.cc: Restructure. Add, remove and rewrite comments throughout
        for better readability.  Change function names for better
        understanding.
-       (MAP_SET): Accomodate name change from map_map_ to page_map_.
+       (MAP_SET): Accommodate name change from map_map_ to page_map_.
        (MAP_CLR): Ditto.
        (MAP_ISSET): Ditto.
        (mmap_record::page_map_): Rename from page_map_.
index 8d0c5b3..37ef3a4 100644 (file)
@@ -334,7 +334,7 @@ low_priority_sleep (DWORD secs)
        SetThreadPriority (thisthread, new_prio);
       Sleep (secs);
 
-      if (!staylow || curr_prio == new_prio)
+      if (!staylow && curr_prio != new_prio)
        SetThreadPriority (thisthread, curr_prio);
     }
 
index a6b2f99..b2ba543 100644 (file)
@@ -233,6 +233,7 @@ pthread::init_mainthread ()
                        0, FALSE, DUPLICATE_SAME_ACCESS))
     thread->win32_obj_id = NULL;
   thread->set_tls_self_pointer ();
+  (void) thread->create_cancel_event ();
   thread->postcreate ();
 }
 
@@ -282,6 +283,19 @@ pthread::~pthread ()
     threads.remove (this);
 }
 
+bool
+pthread::create_cancel_event ()
+{
+  cancel_event = ::CreateEvent (&sec_none_nih, TRUE, FALSE, NULL);
+  if (!cancel_event)
+    {
+      system_printf ("couldn't create cancel event for main thread, %E");
+      /* we need the event for correct behaviour */
+      return false;
+    }
+  return true;
+}
+
 void
 pthread::precreate (pthread_attr *newattr)
 {
@@ -308,6 +322,8 @@ pthread::precreate (pthread_attr *newattr)
     }
   /* Change the mutex type to NORMAL to speed up mutex operations */
   mutex.type = PTHREAD_MUTEX_NORMAL;
+  if (!create_cancel_event ())
+    magic = 0;
 }
 
 void
@@ -340,15 +356,6 @@ pthread::create (void *(*func) (void *), pthread_attr *newattr,
 void
 pthread::postcreate ()
 {
-  cancel_event = ::CreateEvent (&sec_none_nih, TRUE, FALSE, NULL);
-  if (!cancel_event)
-    {
-      system_printf ("couldn't create cancel event for main thread, %E");
-      /* we need the event for correct behaviour */
-      magic = 0;
-      return;
-    }
-
   valid = true;
 
   InterlockedIncrement (&MT_INTERFACE->threadcount);
index ef0e59a..e530a64 100644 (file)
@@ -545,6 +545,7 @@ private:
   void precreate (pthread_attr *);
   void postcreate ();
   void set_tls_self_pointer ();
+  bool create_cancel_event ();
   static pthread *get_tls_self_pointer ();
   void cancel_self ();
   DWORD get_thread_id ();