* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-static time_t start_time;
-static unsigned long __thread duration_interval;
-#define DURATION_TEST_DELAY_WRITE 4
-#define DURATION_TEST_DELAY_READ 100
+
+/* read-side C.S. duration, in us */
+static unsigned long rduration;
void *tret;
unsigned long long *count_reader, *count_writer;
unsigned long long tot_reads = 0, tot_writes = 0;
void *tret;
unsigned long long *count_reader, *count_writer;
unsigned long long tot_reads = 0, tot_writes = 0;
+ case 'a':
+ if (argc < i + 2) {
+ show_usage(argc, argv);
+ return -1;
+ }
+ a = atoi(argv[++i]);
+ CPU_SET(a, &affinity);
+ use_affinity = 1;
+ printf("Adding CPU %d affinity\n", a);
+ break;
+ case 'c':
+ if (argc < i + 2) {
+ show_usage(argc, argv);
+ return -1;
+ }
+ rduration = atoi(argv[++i]);
+ break;
printf("running test for %lu seconds, %u readers, %u writers.\n",
duration, nr_readers, nr_writers);
printf("Writer delay : %u us.\n", wdelay);
printf("running test for %lu seconds, %u readers, %u writers.\n",
duration, nr_readers, nr_writers);
printf("Writer delay : %u us.\n", wdelay);
printf("thread %-6s, thread id : %lx, tid %lu\n",
"main", pthread_self(), (unsigned long)gettid());
printf("thread %-6s, thread id : %lx, tid %lu\n",
"main", pthread_self(), (unsigned long)gettid());
tid_reader = malloc(sizeof(*tid_reader) * nr_readers);
tid_writer = malloc(sizeof(*tid_writer) * nr_writers);
tid_reader = malloc(sizeof(*tid_reader) * nr_readers);
tid_writer = malloc(sizeof(*tid_writer) * nr_writers);
for (i = 0; i < nr_readers; i++) {
err = pthread_join(tid_reader[i], &tret);
if (err != 0)
for (i = 0; i < nr_readers; i++) {
err = pthread_join(tid_reader[i], &tret);
if (err != 0)