Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
tsn-measures
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
nexedi
tsn-measures
Commits
7a42d58b
Commit
7a42d58b
authored
Oct 02, 2020
by
Joanne Hugé
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add interactive interval for client
parent
16f5c761
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
117 additions
and
9 deletions
+117
-9
packet-exchange/src/client.c
packet-exchange/src/client.c
+109
-3
packet-exchange/src/common.h
packet-exchange/src/common.h
+3
-0
packet-exchange/src/server.c
packet-exchange/src/server.c
+0
-3
software-pulse/src/software-pulse.c
software-pulse/src/software-pulse.c
+5
-3
No files found.
packet-exchange/src/client.c
View file @
7a42d58b
...
@@ -60,6 +60,11 @@ typedef struct main_param {
...
@@ -60,6 +60,11 @@ typedef struct main_param {
int
verbose
;
int
verbose
;
int
enable_tracing
;
int
enable_tracing
;
int
enable_graph
;
int
enable_graph
;
int
interval_input
;
int
transition_time
;
uint64_t
target_interval
;
}
main_param_t
;
}
main_param_t
;
// Static functions
// Static functions
...
@@ -113,10 +118,28 @@ static void help(char *argv[]) {
...
@@ -113,10 +118,28 @@ static void help(char *argv[]) {
" -v Verbose
\n
"
" -v Verbose
\n
"
" -T Enable tracing until deadline is missed
\n
"
" -T Enable tracing until deadline is missed
\n
"
" -S Enable tracing until threshold is reached
\n
"
" -S Enable tracing until threshold is reached
\n
"
" -U Interactive interval change
\n
"
"
\n
"
,
"
\n
"
,
argv
[
0
]);
argv
[
0
]);
}
}
static
void
*
print_thread
(
void
*
p
)
{
(
void
)
p
;
for
(;;)
{
if
(
thread_params
.
max_cycles
&&
nb_cycles
>=
((
unsigned
int
)
thread_params
.
max_cycles
))
break
;
printf
(
"Interval: %10"
PRIu64
" Target: %10"
PRIu64
"
\n
"
,
thread_params
.
interval
/
1000
,
main_params
.
target_interval
);
printf
(
"
\033
[%dA"
,
1
);
usleep
(
100000
);
}
pthread_exit
(
NULL
);
}
/*
/*
* Real-time thread:
* Real-time thread:
* - Sends packets at a regular intervall
* - Sends packets at a regular intervall
...
@@ -128,6 +151,13 @@ static void *packet_sending_thread(void *p) {
...
@@ -128,6 +151,13 @@ static void *packet_sending_thread(void *p) {
int
ret
;
int
ret
;
cpu_set_t
mask
;
cpu_set_t
mask
;
uint64_t
next_increment
=
0
;
uint64_t
end_t
=
0
;
uint64_t
cur_t
=
0
;
uint64_t
i_t
=
0
;
uint64_t
i_s
=
thread_params
.
interval
/
1000
;
uint64_t
i_c
=
thread_params
.
interval
/
1000
;
// Set thread CPU affinity
// Set thread CPU affinity
if
(
thread_params
.
affinity_cpu
!=
-
1
)
{
if
(
thread_params
.
affinity_cpu
!=
-
1
)
{
CPU_ZERO
(
&
mask
);
CPU_ZERO
(
&
mask
);
...
@@ -225,6 +255,65 @@ static void *packet_sending_thread(void *p) {
...
@@ -225,6 +255,65 @@ static void *packet_sending_thread(void *p) {
}
}
}
}
if
(
main_params
.
interval_input
&&
(
thread_params
.
interval
!=
(
main_params
.
target_interval
*
1000
)))
{
i_c
=
thread_params
.
interval
/
1000
;
// If target interval changed
if
(
i_t
!=
main_params
.
target_interval
)
{
i_t
=
main_params
.
target_interval
;
i_s
=
i_c
;
cur_t
=
0
;
next_increment
=
0
;
if
(
i_t
<
i_s
)
end_t
=
(
main_params
.
transition_time
*
USEC_PER_SEC
*
USEC_PER_SEC
*
(
i_c
-
i_t
))
/
(
MOTOR_STEPS
*
i_t
*
i_c
);
else
end_t
=
(
main_params
.
transition_time
*
USEC_PER_SEC
*
USEC_PER_SEC
*
(
i_t
-
i_c
))
/
(
MOTOR_STEPS
*
i_t
*
i_c
);
}
if
(
next_increment
)
{
if
(
cur_t
>
next_increment
)
{
i_c
+=
i_t
<
i_s
?
-
1
:
1
;
next_increment
=
0
;
}
}
else
{
uint64_t
next_i
=
i_t
<
i_s
?
i_c
-
1
:
i_c
+
1
;
// Compute time at which we will need to increment / decrement the interval
if
(
i_t
<
i_s
)
next_increment
=
(
end_t
*
i_t
*
(
i_s
-
next_i
))
/
((
i_s
-
i_t
)
*
next_i
);
else
next_increment
=
(
end_t
*
i_t
*
(
next_i
-
i_s
))
/
((
i_t
-
i_s
)
*
next_i
);
// If next increment time is before next interval
if
(
next_increment
<
cur_t
+
i_c
)
{
if
(
i_t
<
i_s
)
{
i_c
=
(
i_t
*
i_s
*
end_t
)
/
((
i_s
-
i_t
)
*
(
cur_t
+
i_c
)
+
end_t
*
i_t
);
i_c
=
i_c
<
i_t
?
i_t
:
i_c
;
}
else
{
i_c
=
(
i_t
*
i_s
*
end_t
)
/
(
end_t
*
i_t
-
(
i_t
-
i_s
)
*
(
cur_t
+
i_c
));
i_c
=
i_c
>
i_t
?
i_t
:
i_c
;
}
next_increment
=
0
;
}
}
cur_t
+=
i_c
;
if
(
i_c
<
50
)
{
fprintf
(
stderr
,
"Interval too small, exiting..
\n
"
);
exit
(
EXIT_FAILURE
);
}
if
(
i_c
>
USEC_PER_SEC
)
{
fprintf
(
stderr
,
"Interval too big, exiting..
\n
"
);
exit
(
EXIT_FAILURE
);
}
thread_params
.
interval
=
i_c
*
1000
;
}
previous
=
current
;
previous
=
current
;
}
}
...
@@ -243,7 +332,7 @@ invalid_ts:
...
@@ -243,7 +332,7 @@ invalid_ts:
* - Handles the IO and creates the real time thread
* - Handles the IO and creates the real time thread
*/
*/
int
main
(
int
argc
,
char
*
argv
[])
{
int
main
(
int
argc
,
char
*
argv
[])
{
pthread_t
thread
;
pthread_t
thread
,
print_pthread
;
struct
sched_param
param
;
struct
sched_param
param
;
pthread_attr_t
attr
;
pthread_attr_t
attr
;
...
@@ -261,6 +350,7 @@ int main(int argc, char *argv[]) {
...
@@ -261,6 +350,7 @@ int main(int argc, char *argv[]) {
main_params
.
verbose
=
0
;
main_params
.
verbose
=
0
;
main_params
.
enable_tracing
=
0
;
main_params
.
enable_tracing
=
0
;
main_params
.
enable_graph
=
0
;
main_params
.
enable_graph
=
0
;
main_params
.
interval_input
=
0
;
egress_params
.
packet_priority
=
3
;
egress_params
.
packet_priority
=
3
;
egress_params
.
tx_buffer_len
=
1024
;
egress_params
.
tx_buffer_len
=
1024
;
enable_etf
=
0
;
enable_etf
=
0
;
...
@@ -336,11 +426,23 @@ int main(int argc, char *argv[]) {
...
@@ -336,11 +426,23 @@ int main(int argc, char *argv[]) {
if
(
pthread_create
(
&
thread
,
&
attr
,
packet_sending_thread
,
NULL
))
if
(
pthread_create
(
&
thread
,
&
attr
,
packet_sending_thread
,
NULL
))
error
(
EXIT_FAILURE
,
errno
,
"Couldn't create packet sending thread"
);
error
(
EXIT_FAILURE
,
errno
,
"Couldn't create packet sending thread"
);
if
(
main_params
.
interval_input
)
{
// Create the print thread
if
(
pthread_create
(
&
print_pthread
,
NULL
,
print_thread
,
NULL
))
error
(
EXIT_FAILURE
,
errno
,
"Couldn't create print thread"
);
}
// Verbose loop
// Verbose loop
for
(;;)
{
for
(;;)
{
usleep
(
main_params
.
refresh_rate
);
usleep
(
main_params
.
refresh_rate
);
if
(
main_params
.
verbose
)
{
if
(
main_params
.
interval_input
)
{
uint64_t
user_input
;
scanf
(
"%"
PRIu64
,
&
user_input
);
if
(
user_input
)
main_params
.
target_interval
=
user_input
;
}
else
if
(
main_params
.
verbose
)
{
// RTT stats printing
// RTT stats printing
if
(
tsn_task
==
RTT_TASK
)
{
if
(
tsn_task
==
RTT_TASK
)
{
// N_CYCLES, RTT min / avg / max
// N_CYCLES, RTT min / avg / max
...
@@ -459,7 +561,7 @@ static void sighand(int sig_num) {
...
@@ -459,7 +561,7 @@ static void sighand(int sig_num) {
*/
*/
static
void
process_options
(
int
argc
,
char
*
argv
[])
{
static
void
process_options
(
int
argc
,
char
*
argv
[])
{
for
(;;)
{
for
(;;)
{
int
c
=
getopt
(
argc
,
argv
,
"a:bc:d:e:ghi:l:p:q:r:s:tvTS:"
);
int
c
=
getopt
(
argc
,
argv
,
"a:bc:d:e:ghi:l:p:q:r:s:tvTS:
U:
"
);
if
(
c
==
-
1
)
break
;
if
(
c
==
-
1
)
break
;
...
@@ -525,6 +627,10 @@ static void process_options(int argc, char *argv[]) {
...
@@ -525,6 +627,10 @@ static void process_options(int argc, char *argv[]) {
thread_params
.
enable_threshold_tracing
=
1
;
thread_params
.
enable_threshold_tracing
=
1
;
thread_params
.
threshold
=
atoi
(
optarg
);
thread_params
.
threshold
=
atoi
(
optarg
);
break
;
break
;
case
'U'
:
main_params
.
interval_input
=
1
;
main_params
.
transition_time
=
atoi
(
optarg
);
break
;
}
}
}
}
...
...
packet-exchange/src/common.h
View file @
7a42d58b
...
@@ -19,7 +19,10 @@
...
@@ -19,7 +19,10 @@
#include <linux/udp.h>
#include <linux/udp.h>
#endif
#endif
#define MOTOR_STEPS 20000
#define NSEC_PER_SEC UINT64_C(1000000000)
#define NSEC_PER_SEC UINT64_C(1000000000)
#define USEC_PER_SEC UINT64_C(1000000)
#define SERVER_PORT "50000"
#define SERVER_PORT "50000"
#define SERVER_PORT_INT 50000
#define SERVER_PORT_INT 50000
...
...
packet-exchange/src/server.c
View file @
7a42d58b
...
@@ -186,9 +186,6 @@ static void *tsn_thread(void *p) {
...
@@ -186,9 +186,6 @@ static void *tsn_thread(void *p) {
cpu_set_t
mask
;
cpu_set_t
mask
;
char
tracemark_message
[
128
];
char
tracemark_message
[
128
];
uint64_t
time_elapsed
;
uint64_t
next_interval
;
// Set thread CPU affinity
// Set thread CPU affinity
if
(
thread_params
.
affinity_cpu
)
{
if
(
thread_params
.
affinity_cpu
)
{
CPU_ZERO
(
&
mask
);
CPU_ZERO
(
&
mask
);
...
...
software-pulse/src/software-pulse.c
View file @
7a42d58b
...
@@ -307,9 +307,11 @@ int main(int argc, char *argv[]) {
...
@@ -307,9 +307,11 @@ int main(int argc, char *argv[]) {
if
(
pthread_create
(
&
thread
,
&
attr
,
pulse_thread
,
NULL
))
if
(
pthread_create
(
&
thread
,
&
attr
,
pulse_thread
,
NULL
))
error
(
EXIT_FAILURE
,
errno
,
"Couldn't create pulse thread"
);
error
(
EXIT_FAILURE
,
errno
,
"Couldn't create pulse thread"
);
if
(
main_params
.
interval_input
)
{
// Create the print thread
// Create the print thread
if
(
pthread_create
(
&
print_pthread
,
NULL
,
print_thread
,
NULL
))
if
(
pthread_create
(
&
print_pthread
,
NULL
,
print_thread
,
NULL
))
error
(
EXIT_FAILURE
,
errno
,
"Couldn't create print thread"
);
error
(
EXIT_FAILURE
,
errno
,
"Couldn't create print thread"
);
}
// Verbose loop
// Verbose loop
for
(;;)
{
for
(;;)
{
...
...
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