/***********************************************************************
* *
* 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 "terror.h"
/* Test concurrency locking based on Atomic Scalar Operations
**
** Written by Kiem-Phong Vo
*/
#ifndef N_PROC
#endif
{
if(locking == 0) /* unlocking a slot */
{ if(size == sizeof(char))
else if(size == sizeof(short))
terror("Process %3d(pid=%d): unlocking %d(pid=%d)?",
if(size == sizeof(char))
else if(size == sizeof(short))
terror("Process %3d(pid=%d): unlocking CAS error %d",
return 0;
}
{ if(size == sizeof(char))
else if(size == sizeof(short))
if(aso == 0)
break;
else if(aso < 0)
terror("Process %3d(pid=%d): locking CAS error %d",
else if(k > 0 && (k%10000) == 0)
twarn("Process %3d(pid=%d): locking loop %d blocked by %d",
}
{ if(size == sizeof(char))
else if(size == sizeof(short))
terror("Process %3d(pid=%d): at step %d lock=%d?",
}
return 0;
}
{
int k, r;
for(k = 0; k < N_STEP; ++k)
{ if(k > 0 && (k%100) == 0)
terror("Process %3d(pid=%d): bad int lock %d",
terror("Process %3d(pid=%d): bad short lock %d",
terror("Process %3d(pid=%d): bad char lock %d",
}
}
tmain()
{
ssize_t k, z;
int zerof;
{
twarn("only ASO_INTRINSIC methods are tested by default");
texit(0);
}
tchild();
/* get shared memory */
N_SLOT*sizeof(unsigned char) +
N_SLOT*sizeof(unsigned short) +
N_SLOT*sizeof(unsigned int);
terror("mmap failed");
for(k = 1; k <= N_PROC; ++k)
terror("Can't create a child process");
else if(pid > 0 ) /* parent process */
continue;
}
else /* child process */
break;
workload(k); /* now start working concurrently */
texit(0);
}
}
terror("workload subprocess error");
terror("Some subprocess did not finish its workload");
texit(0);
}