summaryrefslogtreecommitdiff
path: root/test/testlockperf.c
diff options
context:
space:
mode:
authorAaron Bannert <aaron@apache.org>2002-04-09 06:45:06 +0000
committerAaron Bannert <aaron@apache.org>2002-04-09 06:45:06 +0000
commit461f265f2521781c2aa031334db587c9bcbb432a (patch)
tree2262a87686e0925e7488d3a169904c0674ef4e86 /test/testlockperf.c
parent4941cb301a6eac4ad9eba47113856d5020bd1a6c (diff)
downloadapr-461f265f2521781c2aa031334db587c9bcbb432a.tar.gz
Remove all uses of the apr_lock.h API from the tests.
git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@63232 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'test/testlockperf.c')
-rw-r--r--test/testlockperf.c144
1 files changed, 2 insertions, 142 deletions
diff --git a/test/testlockperf.c b/test/testlockperf.c
index e7c8f1f43..c9515365b 100644
--- a/test/testlockperf.c
+++ b/test/testlockperf.c
@@ -56,7 +56,6 @@
#include "apr_thread_mutex.h"
#include "apr_thread_rwlock.h"
#include "apr_file_io.h"
-#include "apr_lock.h"
#include "apr_errno.h"
#include "apr_general.h"
#include "apr_getopt.h"
@@ -79,35 +78,19 @@ int main(void)
static long mutex_counter;
-static apr_lock_t *inter_lock;
static apr_thread_mutex_t *thread_lock;
-void * APR_THREAD_FUNC inter_mutex_func(apr_thread_t *thd, void *data);
void * APR_THREAD_FUNC thread_mutex_func(apr_thread_t *thd, void *data);
-apr_status_t test_inter_mutex(void); /* apr_lock_t -- INTRAPROCESS */
apr_status_t test_thread_mutex(void); /* apr_thread_mutex_t */
-static apr_lock_t *inter_rwlock;
static apr_thread_rwlock_t *thread_rwlock;
-void * APR_THREAD_FUNC inter_rwlock_func(apr_thread_t *thd, void *data);
void * APR_THREAD_FUNC thread_rwlock_func(apr_thread_t *thd, void *data);
-apr_status_t test_inter_rwlock(void); /* apr_lock_t -- READWRITE */
apr_status_t test_thread_rwlock(void); /* apr_thread_rwlock_t */
+int test_thread_mutex_nested(void);
+
apr_pool_t *pool;
int i = 0, x = 0;
-void * APR_THREAD_FUNC inter_mutex_func(apr_thread_t *thd, void *data)
-{
- int i;
-
- for (i = 0; i < MAX_COUNTER; i++) {
- apr_lock_acquire(inter_lock);
- mutex_counter++;
- apr_lock_release(inter_lock);
- }
- return NULL;
-}
-
void * APR_THREAD_FUNC thread_mutex_func(apr_thread_t *thd, void *data)
{
int i;
@@ -120,18 +103,6 @@ void * APR_THREAD_FUNC thread_mutex_func(apr_thread_t *thd, void *data)
return NULL;
}
-void * APR_THREAD_FUNC inter_rwlock_func(apr_thread_t *thd, void *data)
-{
- int i;
-
- for (i = 0; i < MAX_COUNTER; i++) {
- apr_lock_acquire_rw(inter_rwlock, APR_WRITER);
- mutex_counter++;
- apr_lock_release(inter_rwlock);
- }
- return NULL;
-}
-
void * APR_THREAD_FUNC thread_rwlock_func(apr_thread_t *thd, void *data)
{
int i;
@@ -144,57 +115,6 @@ void * APR_THREAD_FUNC thread_rwlock_func(apr_thread_t *thd, void *data)
return NULL;
}
-int test_inter_mutex(void)
-{
- apr_thread_t *t1, *t2, *t3, *t4;
- apr_status_t s1, s2, s3, s4;
- apr_time_t time_start, time_stop;
-
- mutex_counter = 0;
-
- printf("apr_lock(INTRAPROCESS, MUTEX) Lock Tests\n");
- printf("%-60s", " Initializing the apr_lock_t");
- s1 = apr_lock_create(&inter_lock, APR_MUTEX, APR_INTRAPROCESS,
- APR_LOCK_DEFAULT, "lock.file", pool);
- if (s1 != APR_SUCCESS) {
- printf("Failed!\n");
- return s1;
- }
- printf("OK\n");
-
- apr_lock_acquire(inter_lock);
- /* set_concurrency(4)? -aaron */
- printf("%-60s"," Starting all the threads");
- s1 = apr_thread_create(&t1, NULL, inter_mutex_func, NULL, pool);
- s2 = apr_thread_create(&t2, NULL, inter_mutex_func, NULL, pool);
- s3 = apr_thread_create(&t3, NULL, inter_mutex_func, NULL, pool);
- s4 = apr_thread_create(&t4, NULL, inter_mutex_func, NULL, pool);
- if (s1 != APR_SUCCESS || s2 != APR_SUCCESS ||
- s3 != APR_SUCCESS || s4 != APR_SUCCESS) {
- printf("Failed!\n");
- return s1;
- }
- printf("OK\n");
-
- time_start = apr_time_now();
- apr_lock_release(inter_lock);
-
- /* printf("%-60s", " Waiting for threads to exit"); */
- apr_thread_join(&s1, t1);
- apr_thread_join(&s2, t2);
- apr_thread_join(&s3, t3);
- apr_thread_join(&s4, t4);
- /* printf("OK\n"); */
-
- time_stop = apr_time_now();
- printf("microseconds: %" APR_INT64_T_FMT " usec\n",
- (time_stop - time_start));
- if (mutex_counter != MAX_COUNTER * 4)
- printf("error: counter = %ld\n", mutex_counter);
-
- return APR_SUCCESS;
-}
-
int test_thread_mutex(void)
{
apr_thread_t *t1, *t2, *t3, *t4;
@@ -294,54 +214,6 @@ int test_thread_mutex_nested(void)
return APR_SUCCESS;
}
-int test_inter_rwlock(void)
-{
- apr_thread_t *t1, *t2, *t3, *t4;
- apr_status_t s1, s2, s3, s4;
- apr_time_t time_start, time_stop;
-
- mutex_counter = 0;
-
- printf("apr_lock(INTRAPROCESS, READWRITE) Lock Tests\n");
- printf("%-60s", " Initializing the apr_lock_t");
- s1 = apr_lock_create(&inter_rwlock, APR_READWRITE, APR_INTRAPROCESS,
- APR_LOCK_DEFAULT, "lock.file", pool);
- if (s1 != APR_SUCCESS) {
- printf("Failed!\n");
- return s1;
- }
- printf("OK\n");
-
- apr_lock_acquire_rw(inter_rwlock, APR_WRITER);
- /* set_concurrency(4)? -aaron */
- s1 = apr_thread_create(&t1, NULL, inter_rwlock_func, NULL, pool);
- s2 = apr_thread_create(&t2, NULL, inter_rwlock_func, NULL, pool);
- s3 = apr_thread_create(&t3, NULL, inter_rwlock_func, NULL, pool);
- s4 = apr_thread_create(&t4, NULL, inter_rwlock_func, NULL, pool);
- if (s1 != APR_SUCCESS || s2 != APR_SUCCESS ||
- s3 != APR_SUCCESS || s4 != APR_SUCCESS) {
- printf("Failed!\n");
- return s1;
- }
-
- time_start = apr_time_now();
- apr_lock_release(inter_rwlock);
-
- /* printf("%-60s", " Waiting for threads to exit"); */
- apr_thread_join(&s1, t1);
- apr_thread_join(&s2, t2);
- apr_thread_join(&s3, t3);
- apr_thread_join(&s4, t4);
- /* printf("OK\n"); */
-
- time_stop = apr_time_now();
- printf("microseconds: %" APR_INT64_T_FMT " usec\n",
- (time_stop - time_start));
- if (mutex_counter != MAX_COUNTER * 4)
- printf("error: counter = %ld\n", mutex_counter);
-
- return APR_SUCCESS;
-}
int test_thread_rwlock(void)
{
@@ -426,12 +298,6 @@ int main(int argc, const char * const *argv)
exit(-1);
}
- if ((rv = test_inter_mutex()) != APR_SUCCESS) {
- fprintf(stderr,"apr_lock(INTRAPROCESS, MUTEX) test failed : [%d] %s\n",
- rv, apr_strerror(rv, (char*)errmsg, 200));
- exit(-2);
- }
-
if ((rv = test_thread_mutex()) != APR_SUCCESS) {
fprintf(stderr,"thread_mutex test failed : [%d] %s\n",
rv, apr_strerror(rv, (char*)errmsg, 200));
@@ -444,12 +310,6 @@ int main(int argc, const char * const *argv)
exit(-4);
}
- if ((rv = test_inter_rwlock()) != APR_SUCCESS) {
- fprintf(stderr,"apr_lock(INTRAPROCESS, READWRITE) test failed : [%d] %s\n",
- rv, apr_strerror(rv, (char*)errmsg, 200));
- exit(-5);
- }
-
if ((rv = test_thread_rwlock()) != APR_SUCCESS) {
fprintf(stderr,"thread_rwlock test failed : [%d] %s\n",
rv, apr_strerror(rv, (char*)errmsg, 200));