Commit 3a71ecb7 authored by Cedric Roux's avatar Cedric Roux

remove T_USE_SHARED_MEMORY

The T only works when it's TRUE, the version without shared memory
is not supported anymore.
parent 655e48c5
...@@ -1487,7 +1487,6 @@ set(CMAKE_MODULE_PATH "${OPENAIR_DIR}/cmake_targets/tools/MODULES" "${CMAKE_MODU ...@@ -1487,7 +1487,6 @@ set(CMAKE_MODULE_PATH "${OPENAIR_DIR}/cmake_targets/tools/MODULES" "${CMAKE_MODU
#add the T tracer #add the T tracer
add_boolean_option(T_TRACER True "Activate the T tracer" ) add_boolean_option(T_TRACER True "Activate the T tracer" )
include_directories("${OPENAIR_DIR}/common/utils/T") include_directories("${OPENAIR_DIR}/common/utils/T")
add_boolean_option(T_USE_SHARED_MEMORY True "Use shared memory to communicate with the T tracer" )
set(T_SOURCE set(T_SOURCE
${OPENAIR_DIR}/common/utils/T/T.c) ${OPENAIR_DIR}/common/utils/T/T.c)
set (T_LIB "-lrt") set (T_LIB "-lrt")
......
CC=gcc CC=gcc
CFLAGS=-Wall -g -pthread -DT_TRACER CFLAGS=-Wall -g -pthread -DT_TRACER
#comment those two lines to NOT use shared memory
CFLAGS += -DT_USE_SHARED_MEMORY
LIBS += -lrt LIBS += -lrt
PROG=t PROG=t
......
...@@ -62,42 +62,6 @@ printf("got mess %d\n", t); ...@@ -62,42 +62,6 @@ printf("got mess %d\n", t);
} }
} }
#ifndef T_USE_SHARED_MEMORY
static void *T_send_thread(void *_)
{
while (1) {
usleep(5000);
__sync_synchronize();
while (T_cache[T_busylist_head].busy) {
char *b;
int l;
/* TODO: be sure about those memory barriers - in doubt one is
* put here too
*/
__sync_synchronize();
b = T_cache[T_busylist_head].buffer;
l = T_cache[T_busylist_head].length;
while (l) {
int done = write(T_socket, b, l);
if (done <= 0) {
printf("%s:%d:%s: error sending to socket\n",
__FILE__, __LINE__, __FUNCTION__);
abort();
}
b += done;
l -= done;
}
T_cache[T_busylist_head].busy = 0;
T_busylist_head++;
T_busylist_head &= T_CACHE_SIZE - 1;
}
}
return NULL;
}
#endif /* T_USE_SHARED_MEMORY */
static void *T_receive_thread(void *_) static void *T_receive_thread(void *_)
{ {
while (1) get_message(T_socket); while (1) get_message(T_socket);
...@@ -123,9 +87,7 @@ void T_connect_to_tracer(char *addr, int port) ...@@ -123,9 +87,7 @@ void T_connect_to_tracer(char *addr, int port)
{ {
struct sockaddr_in a; struct sockaddr_in a;
int s; int s;
#ifdef T_USE_SHARED_MEMORY
int T_shm_fd; int T_shm_fd;
#endif
unsigned char *buf; unsigned char *buf;
int len; int len;
...@@ -156,7 +118,6 @@ again: ...@@ -156,7 +118,6 @@ again:
T_socket = s; T_socket = s;
#ifdef T_USE_SHARED_MEMORY
/* setup shared memory */ /* setup shared memory */
T_shm_fd = shm_open(T_SHM_FILENAME, O_RDWR /*| O_SYNC*/, 0666); T_shm_fd = shm_open(T_SHM_FILENAME, O_RDWR /*| O_SYNC*/, 0666);
shm_unlink(T_SHM_FILENAME); shm_unlink(T_SHM_FILENAME);
...@@ -166,11 +127,7 @@ again: ...@@ -166,11 +127,7 @@ again:
if (T_cache == NULL) if (T_cache == NULL)
{ perror(T_SHM_FILENAME); abort(); } { perror(T_SHM_FILENAME); abort(); }
close(T_shm_fd); close(T_shm_fd);
#endif
#ifndef T_USE_SHARED_MEMORY
new_thread(T_send_thread, NULL);
#endif
new_thread(T_receive_thread, NULL); new_thread(T_receive_thread, NULL);
/* trace T_message.txt /* trace T_message.txt
......
...@@ -127,26 +127,12 @@ extern T_cache_t *T_cache; ...@@ -127,26 +127,12 @@ extern T_cache_t *T_cache;
#define T_ACTIVE(x) T_active[(intptr_t)x] #define T_ACTIVE(x) T_active[(intptr_t)x]
#ifdef T_USE_SHARED_MEMORY
#define T_SEND() \ #define T_SEND() \
T_cache[T_LOCAL_slot].length = T_LOCAL_size; \ T_cache[T_LOCAL_slot].length = T_LOCAL_size; \
__sync_synchronize(); \ __sync_synchronize(); \
T_cache[T_LOCAL_slot].busy = 1; \ T_cache[T_LOCAL_slot].busy = 1; \
T_send(T_LOCAL_buf, T_LOCAL_size) T_send(T_LOCAL_buf, T_LOCAL_size)
#else /* T_USE_SHARED_MEMORY */
/* when not using shared memory, wait for send to finish */
#define T_SEND() \
T_cache[T_LOCAL_slot].length = T_LOCAL_size; \
__sync_synchronize(); \
T_cache[T_LOCAL_slot].busy = 1; \
T_send(T_LOCAL_buf, T_LOCAL_size); \
while (T_cache[T_LOCAL_slot].busy) usleep(1*1000)
#endif /* T_USE_SHARED_MEMORY */
#define T_CHECK_SIZE(len, argnum) \ #define T_CHECK_SIZE(len, argnum) \
if (T_LOCAL_size + (len) > T_BUFFER_MAX) { \ if (T_LOCAL_size + (len) > T_BUFFER_MAX) { \
printf("%s:%d:%s: cannot put argument %d in T macro, not enough space" \ printf("%s:%d:%s: cannot put argument %d in T macro, not enough space" \
...@@ -575,26 +561,8 @@ extern T_cache_t *T_cache; ...@@ -575,26 +561,8 @@ extern T_cache_t *T_cache;
} \ } \
} while (0) } while (0)
#ifndef T_USE_SHARED_MEMORY
#include <stdio.h>
static inline void T_send(char *buf, int size)
{
int i;
return;
printf("sending %d bytes", size);
for (i = 0; i < size; i++)
printf("%s%2.2x", i?" ":"\n", (unsigned char)buf[i]);
printf("\n");
}
#else /* T_USE_SHARED_MEMORY */
#define T_send(...) /**/ #define T_send(...) /**/
#endif /* T_USE_SHARED_MEMORY */
extern int *T_active; extern int *T_active;
void T_connect_to_tracer(char *addr, int port); void T_connect_to_tracer(char *addr, int port);
......
CC=gcc CC=gcc
CFLAGS=-Wall -g -pthread -DT_TRACER -DT_USE_SHARED_MEMORY -I. CFLAGS=-Wall -g -pthread -DT_TRACER -I.
PROG=tracee PROG=tracee
OBJS=tracee.o ../T.o OBJS=tracee.o ../T.o
......
...@@ -3,7 +3,6 @@ CFLAGS=-Wall -g -pthread -DT_TRACER ...@@ -3,7 +3,6 @@ CFLAGS=-Wall -g -pthread -DT_TRACER
#CFLAGS += -O3 -ffast-math -fomit-frame-pointer #CFLAGS += -O3 -ffast-math -fomit-frame-pointer
CFLAGS += -DT_USE_SHARED_MEMORY
LIBS += -lrt LIBS += -lrt
PROG=tracer_local PROG=tracer_local
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment