mirror of
https://sourceware.org/git/glibc.git
synced 2025-07-29 11:41:21 +03:00
tst-malloc-thread-exit: Use fewer system resources
This commit is contained in:
@ -1,3 +1,10 @@
|
|||||||
|
2016-02-19 Florian Weimer <fweimer@redhat.com>
|
||||||
|
|
||||||
|
* malloc/tst-malloc-thread-exit.c: Include test-skeleton.c early.
|
||||||
|
(do_test): Limit the number of arenas, so that we can use fewer
|
||||||
|
outer threads. Limit timeout to 3 seconds, in preparation for a
|
||||||
|
larger TIMEOUT value.
|
||||||
|
|
||||||
2016-02-19 Joseph Myers <joseph@codesourcery.com>
|
2016-02-19 Joseph Myers <joseph@codesourcery.com>
|
||||||
|
|
||||||
[BZ #19674]
|
[BZ #19674]
|
||||||
|
@ -26,13 +26,17 @@
|
|||||||
particularly related to the arena free list. */
|
particularly related to the arena free list. */
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <malloc.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#define TIMEOUT 7
|
static int do_test (void);
|
||||||
|
|
||||||
|
#define TEST_FUNCTION do_test ()
|
||||||
|
#include "../test-skeleton.c"
|
||||||
|
|
||||||
static bool termination_requested;
|
static bool termination_requested;
|
||||||
static int inner_thread_count = 4;
|
static int inner_thread_count = 4;
|
||||||
@ -156,20 +160,20 @@ outer_thread (void *closure)
|
|||||||
static int
|
static int
|
||||||
do_test (void)
|
do_test (void)
|
||||||
{
|
{
|
||||||
/* The number of top-level threads should be equal to the number of
|
/* The number of threads should be smaller than the number of
|
||||||
arenas. See arena_get2. */
|
arenas, so that there will be some free arenas to add to the
|
||||||
long outer_thread_count = sysconf (_SC_NPROCESSORS_ONLN);
|
arena free list. */
|
||||||
if (outer_thread_count >= 1)
|
enum { outer_thread_count = 2 };
|
||||||
|
if (mallopt (M_ARENA_MAX, 8) == 0)
|
||||||
{
|
{
|
||||||
/* See NARENAS_FROM_NCORES in malloc.c. */
|
printf ("error: mallopt (M_ARENA_MAX) failed\n");
|
||||||
if (sizeof (long) == 4)
|
return 1;
|
||||||
outer_thread_count *= 2;
|
|
||||||
else
|
|
||||||
outer_thread_count *= 8;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Leave some room for shutting down all threads gracefully. */
|
/* Leave some room for shutting down all threads gracefully. */
|
||||||
int timeout = TIMEOUT - 2;
|
int timeout = 3;
|
||||||
|
if (timeout > TIMEOUT)
|
||||||
|
timeout = TIMEOUT - 1;
|
||||||
|
|
||||||
pthread_t *threads = calloc (sizeof (*threads), outer_thread_count);
|
pthread_t *threads = calloc (sizeof (*threads), outer_thread_count);
|
||||||
if (threads == NULL)
|
if (threads == NULL)
|
||||||
@ -212,6 +216,3 @@ do_test (void)
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define TEST_FUNCTION do_test ()
|
|
||||||
#include "../test-skeleton.c"
|
|
||||||
|
Reference in New Issue
Block a user