/***********************************************************************
* *
* This software is part of the ast package *
* Copyright (c) 1999-2012 AT&T Intellectual Property *
* and is licensed under the *
* Eclipse Public License, Version 1.0 *
* by AT&T Intellectual Property *
* *
* A copy of the License is available at *
* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
* *
* Information and Software Systems Research *
* AT&T Research *
* Florham Park NJ *
* *
* Glenn Fowler <gsf@research.att.com> *
* *
***********************************************************************/
#include "dttest.h"
#include <vmalloc.h>
#include <pthread.h>
/* Test concurrency by volleying objects between two dictionaries. */
/* an object to be bounced back and forth */
typedef struct obj_s
} Obj_t;
/* Cdt discipline to allocate memory from a vmalloc region */
typedef struct _mydisc_s
} Mydisc_t;
static int Nthreads;
/* allocate data from the shared memory region */
{
}
/* compare two objects by their integer keys */
{
}
{
return *((unsigned*)key);
}
/* open a shared dictionary */
{
/* create region to allocate memory from */
terror("Couldn't create vmalloc region");
/* discipline for objects identified by their decimal values */
terror("Can't open dictionary");
return dt;
}
/* swap objects from one dictionary to another */
{
asorelax(1);
n_move = 0;
continue;
n_move += 1;
}
else if(rv)
if(k%100 == 0)
asorelax(1);
}
}
return 0;
}
tmain()
{
size_t k, p, n;
topts();
/* create two dictionaries to volley objects back and forth */
for(n = 0; n < 2; ++n)
terror("Can't open dictionary %d", n);
/* make objects */
terror("vmalloc failed %d", n);
terror("Insert failed n=%d k=%d", n, k);
terror("Search failed n=%d k=%d", n, k);
o->ins[n] += 1;
}
}
for(p = 0; p < N_THREADS; ++p )
for(p = 0; p < N_THREADS; ++p )
pthread_join(thread[p], 0);
tinfo("\tCheck integrity");
tinfo("Dict[0]=%d Dict[1]=%d", n, p);
if((n+p) != N_OBJ)
{ for(k = 0; k < N_OBJ; ++k)
continue;
continue;
twarn("%d not found", k);
}
terror("Expecting %d objects but got (Dict[0]=%d + Dict[1]=%d) = %d",
N_OBJ, n, p, n+p);
}
texit(0);
}