From 1f0191e5425474567dc786c14d84a59df597855f Mon Sep 17 00:00:00 2001 From: Christopher Faylor Date: Sun, 21 Oct 2001 23:44:43 +0000 Subject: [PATCH] * autoload.cc: Autoload GetProcessMemoryInfo. * resource.cc (fill_rusage): Calculate ru_maxrss and ru_majflt entries. (Bug report on this from Guido Serassio in the squid project). This requires including psapi.h. --- winsup/cygwin/ChangeLog | 17 ++++++++++++----- winsup/cygwin/autoload.cc | 2 ++ winsup/cygwin/resource.cc | 9 +++++++++ 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 9556f1cde..6fb321b57 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,10 @@ +2001-10-22 Robert Collins + + * autoload.cc: Autoload GetProcessMemoryInfo. + * resource.cc (fill_rusage): Calculate ru_maxrss and ru_majflt entries. + (Bug report on this from Guido Serassio in the squid project). + This requires including psapi.h. + 2001-10-20 Christopher Faylor * dll_init.cc (dll_list::alloc): Increase retry count to 1000. @@ -55,7 +62,7 @@ (fhandler_dev_tape::norewind): Eliminate. (fhandler_dev_tape::is_rewind_device): New method. * fhandler_raw.cc (fhandler_dev_raw::open): Open new - fixed device name devices using NT internal method. + fixed device name devices using NT internal method. Keep calling fhandler_base::open() for old mount table device mapping compatibility devices. (fhandler_dev_raw::fstat): Eliminate. Settings are done @@ -212,7 +219,7 @@ Sun Oct 14 08:10:12 2001 Gary R. Van Sickle * net.cc (cygwin_sendto): Use correct socket address when sending data to AF_UNIX socket. -Wed Oct 10 16:10:41 2001 Alexander Gottwald +Wed Oct 10 16:10:41 2001 Alexander Gottwald * net.cc (get_95_ifconf): Using other registry values pointing to correct networkdevice identification for Windows95. @@ -573,9 +580,9 @@ Sat Sep 29 18:26:00 2001 Robert Collins (__pthread_cond_dowait): New function, contains core logic from __pthread_cond_wait and __pthread_cond_timedwait. Decrement (*cond)->waiting before reentering the cond access mutex to allow detection of lost signals. - (__pthread_cond_timedwait): Rename to pthread_cond_timedwait, and call + (__pthread_cond_timedwait): Rename to pthread_cond_timedwait, and call __pthread_cond_dowait after calculating the wait length. - (__pthread_cond_wait): Rename to pthread_cond_wait, and call + (__pthread_cond_wait): Rename to pthread_cond_wait, and call __pthread_cond_dowait. * thread.h: New enum for use with verifyable_object_isvalid. Remove the extern exporting of __pthread_cond_timedwait and __pthread_cond_wait. @@ -688,7 +695,7 @@ Tue Sep 25 21:25:00 2001 Robert Collins (__pthread_mutexattr_getprotocol): Fix typo in magic number. (__pthread_mutexattr_getpshared): Ditto. (__pthread_mutexattr_gettype): Ditto. - * thread.h (verifyable_object_isvalid): Change prototype to recieve a pointer to a + * thread.h (verifyable_object_isvalid): Change prototype to recieve a pointer to a pointer for verification. * include/pthread.h: Fix typo for __cleanup_routine_type typedef. (Contrib from Net). diff --git a/winsup/cygwin/autoload.cc b/winsup/cygwin/autoload.cc index 259e3b4cd..c5fcdaf55 100644 --- a/winsup/cygwin/autoload.cc +++ b/winsup/cygwin/autoload.cc @@ -381,6 +381,8 @@ LoadDLLfuncEx (RtlInitUnicodeString, 8, ntdll, 1) LoadDLLfuncEx (RtlNtStatusToDosError, 4, ntdll, 1) LoadDLLfuncEx (ZwQuerySystemInformation, 16, ntdll, 1) +LoadDLLfuncEx (GetProcessMemoryInfo, 12, psapi, 1) + LoadDLLfuncEx (LsaDeregisterLogonProcess, 4, secur32, 1) LoadDLLfuncEx (LsaFreeReturnBuffer, 4, secur32, 1) LoadDLLfuncEx (LsaLogonUser, 56, secur32, 1) diff --git a/winsup/cygwin/resource.cc b/winsup/cygwin/resource.cc index 8dd373b6f..9c949e4c0 100644 --- a/winsup/cygwin/resource.cc +++ b/winsup/cygwin/resource.cc @@ -20,6 +20,7 @@ details. */ #include "sync.h" #include "sigproc.h" #include "pinfo.h" +#include "psapi.h" /* add timeval values */ static void @@ -73,6 +74,14 @@ fill_rusage (struct rusage *r, HANDLE h) add_timeval (&r->ru_stime, &tv); totimeval (&tv, &user_time, 0, 0); add_timeval (&r->ru_utime, &tv); + + PROCESS_MEMORY_COUNTERS pmc; + + if (GetProcessMemoryInfo( h, &pmc, sizeof (pmc))) + { + r->ru_maxrss += (long) (pmc.WorkingSetSize /1024); + r->ru_majflt += pmc.PageFaultCount; + } } extern "C"