main_lock_numa.c
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/epoll.h>
#include <unistd.h>
#include <sys/syscall.h>
#include <sys/types.h>
#define __USE_GNU
#include <sched.h>
#include <ctype.h>
#include <pthread.h>
#include <stdbool.h>
#include "common.h"
#include "mempool.h"
#define LOOPCOUNT 0xFFFFFF
long long g_alstarttime[128];
long long g_alendtime[128];
int g_arun[128] = {
0};
long long g_allAv[128] = {
0};
struct testData g_stTestData = {
0};
void * g_pbuf;
int loopht(unsigned int *puilock)
{
int i;
int iValue = 0;
for(i = 0; i < LOOPCOUNT; i++)
{
(void)__sync_add_and_fetch(puilock, 1);
//(*puilock) ++;
//iValue = *puilock;
}
iValue = __sync_add_and_fetch(puilock, 1);
return iValue;
}
void go_test(int cpucoreid)
{
long long t1, t2, diff, av, pav = 0,max,min;
int i;
int iValue;
unsigned int uiRWFlag = g_stTestData.uiRWFlag;
char *pcflag;
unsigned int uiloopcount = g_stTestData.uiLoopCount;
unsigned int *puilock;
if (0 == uiRWFlag)
{
pcflag = "AllLock";
puilock = (unsigned int *)g_pbuf;
}
else
{
pcflag = "SelfLock";
puilock = (unsigned int *)((unsigned char *)g_pbuf +