mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-29 21:47:59 +00:00
delete
This commit is contained in:
parent
1911d3aabe
commit
26ec6d6655
@ -1,163 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 1998 Internet Software Consortium.
|
|
||||||
*
|
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
|
||||||
* copyright notice and this permission notice appear in all copies.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
|
|
||||||
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
|
||||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
|
|
||||||
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
|
||||||
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
|
||||||
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
|
||||||
* SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <config.h>
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <pthread.h>
|
|
||||||
#ifdef SOLARIS
|
|
||||||
#include <thread.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <isc/assertions.h>
|
|
||||||
#include <isc/mem.h>
|
|
||||||
|
|
||||||
char *ptr1[50000];
|
|
||||||
char *ptr2[50000];
|
|
||||||
|
|
||||||
#define ALLOCSZ 100
|
|
||||||
|
|
||||||
#undef THREADS
|
|
||||||
#undef LOCKMUTEX
|
|
||||||
#undef FINELOCK
|
|
||||||
#undef GLOBALMUTEX
|
|
||||||
#undef GLOBALMEMCTX
|
|
||||||
#undef USE_MALLOC
|
|
||||||
#undef FILL
|
|
||||||
#define STATS
|
|
||||||
|
|
||||||
pthread_mutex_t global_mutex = PTHREAD_MUTEX_INITIALIZER;
|
|
||||||
mem_context_t global_ctx = NULL;
|
|
||||||
|
|
||||||
static void
|
|
||||||
work(int n, char **p, mem_context_t m, pthread_mutex_t *mutex) {
|
|
||||||
int i;
|
|
||||||
|
|
||||||
#if !defined(LOCKMUTEX)
|
|
||||||
/* Always "use" mutex, so compilers don't complain. */
|
|
||||||
mutex = NULL;
|
|
||||||
#endif
|
|
||||||
#if defined(THREADS) && defined(LOCKMUTEX) && !defined(FINELOCK)
|
|
||||||
INSIST(pthread_mutex_lock(mutex) == 0);
|
|
||||||
#endif
|
|
||||||
for (i = 0; i < n; i++) {
|
|
||||||
#if defined(THREADS) && defined(LOCKMUTEX) && defined(FINELOCK)
|
|
||||||
INSIST(pthread_mutex_lock(mutex) == 0);
|
|
||||||
#endif
|
|
||||||
#ifdef USE_MALLOC
|
|
||||||
p[i] = malloc(ALLOCSZ);
|
|
||||||
#else
|
|
||||||
p[i] = mem_allocate(m, ALLOCSZ);
|
|
||||||
#endif
|
|
||||||
#if defined(THREADS) && defined(LOCKMUTEX) && defined(FINELOCK)
|
|
||||||
INSIST(pthread_mutex_unlock(mutex) == 0);
|
|
||||||
#endif
|
|
||||||
INSIST(p[i] != NULL);
|
|
||||||
#if defined(FILL)
|
|
||||||
{
|
|
||||||
int j;
|
|
||||||
|
|
||||||
for (j = 0; j < ALLOCSZ; j++)
|
|
||||||
p[i][j] = j;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
#if defined(THREADS) && defined(LOCKMUTEX) && !defined(FINELOCK)
|
|
||||||
INSIST(pthread_mutex_unlock(mutex) == 0);
|
|
||||||
#endif
|
|
||||||
#if defined(THREADS) && defined(LOCKMUTEX) && !defined(FINELOCK)
|
|
||||||
INSIST(pthread_mutex_lock(mutex) == 0);
|
|
||||||
#endif
|
|
||||||
for (i = 0; i < n; i++) {
|
|
||||||
#if defined(THREADS) && defined(LOCKMUTEX) && defined(FINELOCK)
|
|
||||||
INSIST(pthread_mutex_lock(mutex) == 0);
|
|
||||||
#endif
|
|
||||||
#ifdef USE_MALLOC
|
|
||||||
free(p[i]);
|
|
||||||
#else
|
|
||||||
mem_free(m, p[i]);
|
|
||||||
#endif
|
|
||||||
#if defined(THREADS) && defined(LOCKMUTEX) && defined(FINELOCK)
|
|
||||||
INSIST(pthread_mutex_unlock(mutex) == 0);
|
|
||||||
#endif
|
|
||||||
p[i] = NULL;
|
|
||||||
}
|
|
||||||
#if defined(THREADS) && defined(LOCKMUTEX) && !defined(FINELOCK)
|
|
||||||
INSIST(pthread_mutex_unlock(mutex) == 0);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
static void *
|
|
||||||
run(void *arg) {
|
|
||||||
char **p = arg;
|
|
||||||
mem_context_t m;
|
|
||||||
pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
|
|
||||||
pthread_mutex_t *mutexp;
|
|
||||||
|
|
||||||
#ifdef GLOBALMUTEX
|
|
||||||
mutexp = &global_mutex;
|
|
||||||
#else
|
|
||||||
mutexp = &mutex;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef GLOBALMEMCTX
|
|
||||||
m = global_ctx;
|
|
||||||
#else
|
|
||||||
INSIST(mem_context_create(0, 0, &m) == 0);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
work(50000, p, m, mutexp);
|
|
||||||
work(50000, p, m, mutexp);
|
|
||||||
work(50000, p, m, mutexp);
|
|
||||||
work(50000, p, m, mutexp);
|
|
||||||
work(50000, p, m, mutexp);
|
|
||||||
work(50000, p, m, mutexp);
|
|
||||||
work(50000, p, m, mutexp);
|
|
||||||
work(50000, p, m, mutexp);
|
|
||||||
work(50000, p, m, mutexp);
|
|
||||||
work(50000, p, m, mutexp);
|
|
||||||
#ifdef STATS
|
|
||||||
mem_stats(m, stdout);
|
|
||||||
#endif
|
|
||||||
return (NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
main(void) {
|
|
||||||
#ifdef THREADS
|
|
||||||
pthread_t t1, t2;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef GLOBALMEMCTX
|
|
||||||
INSIST(mem_context_create(0, 0, &global_ctx) == 0);
|
|
||||||
#endif
|
|
||||||
#ifdef SOLARIS
|
|
||||||
thr_setconcurrency(2); /* Ick. */
|
|
||||||
#endif
|
|
||||||
#ifdef THREADS
|
|
||||||
INSIST(pthread_create(&t1, NULL, run, ptr1) == 0);
|
|
||||||
INSIST(pthread_create(&t2, NULL, run, ptr2) == 0);
|
|
||||||
(void)pthread_join(t1, NULL);
|
|
||||||
(void)pthread_join(t2, NULL);
|
|
||||||
#else
|
|
||||||
run(ptr1);
|
|
||||||
run(ptr2);
|
|
||||||
#endif
|
|
||||||
return (0);
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user