Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
OAI-RAN-5G-sheduler_MaxTBS
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
MAQ5G-PFC
OAI-RAN-5G-sheduler_MaxTBS
Commits
f18a438c
Commit
f18a438c
authored
6 years ago
by
Cedric Roux
Browse files
Options
Downloads
Patches
Plain Diff
T: simplify
Don't use shm anymore. Use mmap directly.
parent
781133b7
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
common/utils/T/T.c
+31
-26
31 additions, 26 deletions
common/utils/T/T.c
common/utils/T/T_defs.h
+0
-2
0 additions, 2 deletions
common/utils/T/T_defs.h
common/utils/T/local_tracer.c
+9
-29
9 additions, 29 deletions
common/utils/T/local_tracer.c
with
40 additions
and
57 deletions
common/utils/T/T.c
+
31
−
26
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
);
}
}
This diff is collapsed.
Click to expand it.
common/utils/T/T_defs.h
+
0
−
2
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
...
...
This diff is collapsed.
Click to expand it.
common/utils/T/local_tracer.c
+
9
−
29
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
();
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment