Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
OpenXG-RAN
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ZhouShuya
OpenXG-RAN
Commits
f18a438c
Commit
f18a438c
authored
Aug 09, 2018
by
Cedric Roux
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
T: simplify
Don't use shm anymore. Use mmap directly.
parent
781133b7
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
57 deletions
+40
-57
common/utils/T/T.c
common/utils/T/T.c
+31
-26
common/utils/T/T_defs.h
common/utils/T/T_defs.h
+0
-2
common/utils/T/local_tracer.c
common/utils/T/local_tracer.c
+9
-29
No files found.
common/utils/T/T.c
View file @
f18a438c
...
...
@@ -91,7 +91,7 @@ static void new_thread(void *(*f)(void *), void *data)
/* defined in local_tracer.c */
void
T_local_tracer_main
(
int
remote_port
,
int
wait_for_tracer
,
int
local_socket
,
char
*
shm_file
);
int
local_socket
,
void
*
shm_array
);
/* We monitor the tracee and the local tracer processes.
* When one dies we forcefully kill the other.
...
...
@@ -114,22 +114,31 @@ void T_init(int remote_port, int wait_for_tracer, int dont_fork)
{
int
socket_pair
[
2
];
int
s
;
int
T_shm_fd
;
int
child1
,
child2
;
char
shm_file
[
128
];
sprintf
(
shm_file
,
"/%s%d"
,
T_SHM_FILENAME
,
getpid
());
int
i
;
if
(
socketpair
(
AF_UNIX
,
SOCK_STREAM
,
0
,
socket_pair
))
{
perror
(
"socketpair"
);
abort
();
}
/* setup shared memory */
T_cache
=
mmap
(
NULL
,
T_CACHE_SIZE
*
sizeof
(
T_cache_t
),
PROT_READ
|
PROT_WRITE
,
MAP_SHARED
|
MAP_ANONYMOUS
,
-
1
,
0
);
if
(
T_cache
==
MAP_FAILED
)
{
perror
(
"mmap"
);
abort
();
}
/* let's garbage the memory to catch some potential problems
* (think multiprocessor sync issues, barriers, etc.)
*/
memset
(
T_cache
,
0x55
,
T_CACHE_SIZE
*
sizeof
(
T_cache_t
));
for
(
i
=
0
;
i
<
T_CACHE_SIZE
;
i
++
)
T_cache
[
i
].
busy
=
0
;
/* child1 runs the local tracer and child2 (or main) runs the tracee */
child1
=
fork
();
if
(
child1
==
-
1
)
abort
();
if
(
child1
==
0
)
{
close
(
socket_pair
[
1
]);
T_local_tracer_main
(
remote_port
,
wait_for_tracer
,
socket_pair
[
0
],
shm_fil
e
);
T_cach
e
);
exit
(
0
);
}
close
(
socket_pair
[
0
]);
...
...
@@ -138,6 +147,7 @@ void T_init(int remote_port, int wait_for_tracer, int dont_fork)
child2
=
fork
();
if
(
child2
==
-
1
)
abort
();
if
(
child2
!=
0
)
{
close
(
socket_pair
[
1
]);
munmap
(
T_cache
,
T_CACHE_SIZE
*
sizeof
(
T_cache_t
));
monitor_and_kill
(
child1
,
child2
);
}
}
...
...
@@ -148,34 +158,29 @@ void T_init(int remote_port, int wait_for_tracer, int dont_fork)
T_socket
=
s
;
/* setup shared memory */
T_shm_fd
=
shm_open
(
shm_file
,
O_RDWR
/*| O_SYNC*/
,
0666
);
shm_unlink
(
shm_file
);
if
(
T_shm_fd
==
-
1
)
{
perror
(
shm_file
);
abort
();
}
T_cache
=
mmap
(
NULL
,
T_CACHE_SIZE
*
sizeof
(
T_cache_t
),
PROT_READ
|
PROT_WRITE
,
MAP_SHARED
,
T_shm_fd
,
0
);
if
(
T_cache
==
MAP_FAILED
)
{
perror
(
shm_file
);
abort
();
}
close
(
T_shm_fd
);
new_thread
(
T_receive_thread
,
NULL
);
}
void
T_Config_Init
(
void
)
{
int
T_port
;
/* by default we wait for the tracer */
int
T_nowait
;
/* default port to listen to to wait for the tracer */
int
T_dont_fork
;
/* default is to fork, see 'T_init' to understand */
int
T_port
;
/* by default we wait for the tracer */
int
T_nowait
;
/* default port to listen to to wait for the tracer */
int
T_dont_fork
;
/* default is to fork, see 'T_init' to understand */
paramdef_t
ttraceparams
[]
=
CMDLINE_TTRACEPARAMS_DESC
;
paramdef_t
ttraceparams
[]
=
CMDLINE_TTRACEPARAMS_DESC
;
/* for a cleaner config file, TTracer params should be defined in a specific section... */
config_get
(
ttraceparams
,
sizeof
(
ttraceparams
)
/
sizeof
(
paramdef_t
),
TTRACER_CONFIG_PREFIX
);
/* for a cleaner config file, TTracer params should be defined in a
* specific section...
*/
config_get
(
ttraceparams
,
sizeof
(
ttraceparams
)
/
sizeof
(
paramdef_t
),
TTRACER_CONFIG_PREFIX
);
/* compatibility: look for TTracer command line options in root section */
config_process_cmdline
(
ttraceparams
,
sizeof
(
ttraceparams
)
/
sizeof
(
paramdef_t
),
NULL
);
/* compatibility: look for TTracer command line options in root section */
config_process_cmdline
(
ttraceparams
,
sizeof
(
ttraceparams
)
/
sizeof
(
paramdef_t
),
NULL
);
if
(
T_stdout
==
0
)
{
if
(
T_stdout
==
0
)
T_init
(
T_port
,
1
-
T_nowait
,
T_dont_fork
);
}
}
common/utils/T/T_defs.h
View file @
f18a438c
...
...
@@ -36,8 +36,6 @@ typedef struct {
int
length
;
}
T_cache_t
;
#define T_SHM_FILENAME "/T_shm_segment"
/* number of VCD functions (to be kept up to date! see in T_messages.txt) */
#define VCD_NUM_FUNCTIONS 190
...
...
common/utils/T/local_tracer.c
View file @
f18a438c
...
...
@@ -340,51 +340,31 @@ static void wait_message(void)
while
(
T_local_cache
[
T_busylist_head
].
busy
==
0
)
usleep
(
1000
);
}
static
void
init_shm
(
char
*
shm_file
)
{
int
i
;
int
s
=
shm_open
(
shm_file
,
O_RDWR
|
O_CREAT
/*| O_SYNC*/
,
0666
);
if
(
s
==
-
1
)
{
perror
(
shm_file
);
abort
();
}
if
(
ftruncate
(
s
,
T_CACHE_SIZE
*
sizeof
(
T_cache_t
)))
{
perror
(
shm_file
);
abort
();
}
T_local_cache
=
mmap
(
NULL
,
T_CACHE_SIZE
*
sizeof
(
T_cache_t
),
PROT_READ
|
PROT_WRITE
,
MAP_SHARED
,
s
,
0
);
if
(
T_local_cache
==
MAP_FAILED
)
{
perror
(
shm_file
);
abort
();
}
close
(
s
);
/* let's garbage the memory to catch some potential problems
* (think multiprocessor sync issues, barriers, etc.)
*/
memset
(
T_local_cache
,
0x55
,
T_CACHE_SIZE
*
sizeof
(
T_cache_t
));
for
(
i
=
0
;
i
<
T_CACHE_SIZE
;
i
++
)
T_local_cache
[
i
].
busy
=
0
;
}
void
T_local_tracer_main
(
int
remote_port
,
int
wait_for_tracer
,
int
local_socket
,
char
*
shm_file
)
int
local_socket
,
void
*
shm_array
)
{
int
s
;
int
port
=
remote_port
;
int
dont_wait
=
wait_for_tracer
?
0
:
1
;
void
*
f
;
printf
(
"local tracer starting
\n
"
);
/* write on a socket fails if the other end is closed and we get SIGPIPE */
if
(
signal
(
SIGPIPE
,
SIG_IGN
)
==
SIG_ERR
){
if
(
signal
(
SIGPIPE
,
SIG_IGN
)
==
SIG_ERR
)
{
printf
(
"local tracer received SIGPIPE
\n
"
);
abort
();
}
}
T_local_cache
=
shm_array
;
init_shm
(
shm_file
);
s
=
local_socket
;
printf
(
"local tracer starting step 2
\n
"
);
if
(
dont_wait
)
{
char
t
=
2
;
printf
(
"local tracer in no wait mode
\n
"
);
if
(
write
(
s
,
&
t
,
1
)
!=
1
)
abort
();
}
printf
(
"local tracer starting step 3
\n
"
);
f
=
forwarder
(
port
,
s
);
printf
(
"local tracer main loop....
\n
"
);
/* read messages */
while
(
1
)
{
wait_message
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment