* fork.cc (fork_parent): Stop malloc activity while fork is in control of the

heap.
* sigproc.cc (NZOMBIES): Rename from ZOMBIEMAX for clarity.
(zombies): Revert to original behavior.  Allocating zombie array resulted in
performance hit.
* winsup.h: Declare malloc lock routines.
This commit is contained in:
Christopher Faylor 2001-09-09 03:34:36 +00:00
parent c12a96d12f
commit e2ea684e4e
5 changed files with 25 additions and 22 deletions

View File

@ -1,3 +1,12 @@
Sat Sep 8 23:32:18 2001 Christopher Faylor <cgf@cygnus.com>
* fork.cc (fork_parent): Stop malloc activity while fork is in control
of the heap.
* sigproc.cc (NZOMBIES): Rename from ZOMBIEMAX for clarity.
(zombies): Revert to original behavior. Allocating zombie array
resulted in performance hit.
* winsup.h: Declare malloc lock routines.
Fri Sep 7 21:35:35 2001 Christopher Faylor <cgf@cygnus.com> Fri Sep 7 21:35:35 2001 Christopher Faylor <cgf@cygnus.com>
* cygwin.din: Add gamm*_r function exports. * cygwin.din: Add gamm*_r function exports.

View File

@ -462,6 +462,7 @@ fork_parent (HANDLE& hParent, dll *&first_dll,
char sa_buf[1024]; char sa_buf[1024];
syscall_printf ("CreateProcess (%s, %s, 0, 0, 1, %x, 0, 0, %p, %p)", syscall_printf ("CreateProcess (%s, %s, 0, 0, 1, %x, 0, 0, %p, %p)",
myself->progname, myself->progname, c_flags, &si, &pi); myself->progname, myself->progname, c_flags, &si, &pi);
__malloc_lock (_reent_clib ());
cygheap_setup_for_child (&ch); cygheap_setup_for_child (&ch);
rc = CreateProcess (myself->progname, /* image to run */ rc = CreateProcess (myself->progname, /* image to run */
myself->progname, /* what we send in arg0 */ myself->progname, /* what we send in arg0 */
@ -557,6 +558,7 @@ fork_parent (HANDLE& hParent, dll *&first_dll,
dll_data_start, dll_data_end, dll_data_start, dll_data_end,
dll_bss_start, dll_bss_end, NULL); dll_bss_start, dll_bss_end, NULL);
__malloc_unlock (_reent_clib ());
MALLOC_CHECK; MALLOC_CHECK;
if (!rc) if (!rc)
goto cleanup; goto cleanup;

View File

@ -154,8 +154,7 @@ _strdup_r (struct _reent *, const char *s)
/* These routines are used by the application if it /* These routines are used by the application if it
doesn't provide its own malloc. */ doesn't provide its own malloc. */
extern "C" extern "C" void
void
export_free (void *p) export_free (void *p)
{ {
malloc_printf ("(%p), called by %x", p, ((int *)&p)[-1]); malloc_printf ("(%p), called by %x", p, ((int *)&p)[-1]);
@ -165,8 +164,7 @@ export_free (void *p)
user_data->free (p); user_data->free (p);
} }
extern "C" extern "C" void *
void *
export_malloc (int size) export_malloc (int size)
{ {
void *res; void *res;
@ -179,8 +177,7 @@ export_malloc (int size)
return res; return res;
} }
extern "C" extern "C" void *
void *
export_realloc (void *p, int size) export_realloc (void *p, int size)
{ {
void *res; void *res;
@ -192,8 +189,7 @@ export_realloc (void *p, int size)
return res; return res;
} }
extern "C" extern "C" void *
void *
export_calloc (size_t nmemb, size_t size) export_calloc (size_t nmemb, size_t size)
{ {
void *res; void *res;
@ -234,15 +230,13 @@ malloc_init ()
} }
} }
extern "C" extern "C" void
void
__malloc_lock (struct _reent *) __malloc_lock (struct _reent *)
{ {
mprotect->acquire (); mprotect->acquire ();
} }
extern "C" extern "C" void
void
__malloc_unlock (struct _reent *) __malloc_unlock (struct _reent *)
{ {
mprotect->release (); mprotect->release ();

View File

@ -46,7 +46,7 @@ details. */
#define no_signals_available() (!hwait_sig || !sig_loop_wait) #define no_signals_available() (!hwait_sig || !sig_loop_wait)
#define ZOMBIEMAX 4096 #define NZOMBIES 4096
/* /*
* Global variables * Global variables
@ -99,12 +99,12 @@ Static HANDLE wait_sig_inited = NULL; // Control synchronization of
/* Used by WaitForMultipleObjects. These are handles to child processes. /* Used by WaitForMultipleObjects. These are handles to child processes.
*/ */
Static HANDLE events[PSIZE + 1] = {0}; // All my children's handles++ Static HANDLE events[PSIZE + 1] = {0}; // All my children's handles++
#define hchildren (events + 1) // Where the children handles begin #define hchildren (events + 1) // Where the children handles begin
Static pinfo pchildren[PSIZE]; // All my children info Static pinfo pchildren[PSIZE]; // All my children info
Static int nchildren = 0; // Number of active children Static int nchildren = 0; // Number of active children
static pinfo *zombies; // All my deceased children info Static pinfo zombies[NZOMBIES]; // All my deceased children info
static int nzombies; // Number of deceased children Static int nzombies = 0; // Number of deceased children
Static waitq waitq_head = {0, 0, 0, 0, 0, 0, 0};// Start of queue for wait'ing threads Static waitq waitq_head = {0, 0, 0, 0, 0, 0, 0};// Start of queue for wait'ing threads
Static waitq waitq_main; // Storage for main thread Static waitq waitq_main; // Storage for main thread
@ -318,7 +318,7 @@ proc_subproc (DWORD what, DWORD val)
filled up our table or if we're ignoring SIGCHLD, then we immediately filled up our table or if we're ignoring SIGCHLD, then we immediately
remove the process and move on. Otherwise, this process becomes a zombie remove the process and move on. Otherwise, this process becomes a zombie
which must be reaped by a wait() call. */ which must be reaped by a wait() call. */
if (nzombies >= ZOMBIEMAX if (nzombies >= NZOMBIES
|| myself->getsig (SIGCHLD).sa_handler == (void *) SIG_IGN) || myself->getsig (SIGCHLD).sa_handler == (void *) SIG_IGN)
{ {
sigproc_printf ("automatically removing zombie %d", thiszombie); sigproc_printf ("automatically removing zombie %d", thiszombie);
@ -543,11 +543,6 @@ sig_dispatch_pending (int justwake)
void __stdcall void __stdcall
sigproc_init () sigproc_init ()
{ {
if (!zombies)
zombies = (pinfo *) malloc (sizeof (pinfo) * ZOMBIEMAX);
else
nzombies = 0;
wait_sig_inited = CreateEvent (&sec_none_nih, TRUE, FALSE, NULL); wait_sig_inited = CreateEvent (&sec_none_nih, TRUE, FALSE, NULL);
ProtectHandle (wait_sig_inited); ProtectHandle (wait_sig_inited);

View File

@ -211,6 +211,9 @@ extern "C" void __api_fatal (const char *, ...) __attribute__ ((noreturn));
extern "C" int __small_sprintf (char *dst, const char *fmt, ...) /*__attribute__ ((regparm (2)))*/; extern "C" int __small_sprintf (char *dst, const char *fmt, ...) /*__attribute__ ((regparm (2)))*/;
extern "C" int __small_vsprintf (char *dst, const char *fmt, va_list ap) /*__attribute__ ((regparm (3)))*/; extern "C" int __small_vsprintf (char *dst, const char *fmt, va_list ap) /*__attribute__ ((regparm (3)))*/;
extern "C" void __malloc_lock (struct _reent *);
extern "C" void __malloc_unlock (struct _reent *);
/**************************** Exports ******************************/ /**************************** Exports ******************************/
extern "C" { extern "C" {