Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
etherlabmaster
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue 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
ICS Control System Infrastructure
etherlabmaster
Commits
8154426b
Commit
8154426b
authored
16 years ago
by
Florian Pose
Browse files
Options
Downloads
Patches
Plain Diff
Fixed race concerning thread signaling when master thread had no
opportunity to run, but shall be killed immediately.
parent
7df378bf
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
master/master.c
+8
-1
8 additions, 1 deletion
master/master.c
master/master.h
+7
-0
7 additions, 0 deletions
master/master.h
with
15 additions
and
1 deletion
master/master.c
+
8
−
1
View file @
8154426b
...
@@ -313,6 +313,7 @@ int ec_master_thread_start(
...
@@ -313,6 +313,7 @@ int ec_master_thread_start(
int
(
*
thread_func
)(
ec_master_t
*
)
/**< thread function to start */
int
(
*
thread_func
)(
ec_master_t
*
)
/**< thread function to start */
)
)
{
{
init_completion
(
&
master
->
thread_can_terminate
);
init_completion
(
&
master
->
thread_exit
);
init_completion
(
&
master
->
thread_exit
);
EC_INFO
(
"Starting master thread.
\n
"
);
EC_INFO
(
"Starting master thread.
\n
"
);
...
@@ -341,11 +342,15 @@ void ec_master_thread_stop(
...
@@ -341,11 +342,15 @@ void ec_master_thread_stop(
if
(
master
->
debug_level
)
if
(
master
->
debug_level
)
EC_DBG
(
"Stopping master thread.
\n
"
);
EC_DBG
(
"Stopping master thread.
\n
"
);
// wait until thread is ready to receive the SIGTERM
wait_for_completion
(
&
master
->
thread_can_terminate
);
kill_proc
(
master
->
thread_id
,
SIGTERM
,
1
);
kill_proc
(
master
->
thread_id
,
SIGTERM
,
1
);
wait_for_completion
(
&
master
->
thread_exit
);
wait_for_completion
(
&
master
->
thread_exit
);
EC_INFO
(
"Master thread exited.
\n
"
);
EC_INFO
(
"Master thread exited.
\n
"
);
if
(
master
->
fsm_datagram
.
state
!=
EC_DATAGRAM_SENT
)
return
;
if
(
master
->
fsm_datagram
.
state
!=
EC_DATAGRAM_SENT
)
return
;
// wait for FSM datagram
// wait for FSM datagram
sleep_jiffies
=
max
(
HZ
/
100
,
1
);
// 10 ms, at least 1 jiffy
sleep_jiffies
=
max
(
HZ
/
100
,
1
);
// 10 ms, at least 1 jiffy
...
@@ -822,6 +827,7 @@ static int ec_master_idle_thread(ec_master_t *master)
...
@@ -822,6 +827,7 @@ static int ec_master_idle_thread(ec_master_t *master)
{
{
daemonize
(
"EtherCAT-IDLE"
);
daemonize
(
"EtherCAT-IDLE"
);
allow_signal
(
SIGTERM
);
allow_signal
(
SIGTERM
);
complete
(
&
master
->
thread_can_terminate
);
while
(
!
signal_pending
(
current
))
{
while
(
!
signal_pending
(
current
))
{
ec_datagram_output_stats
(
&
master
->
fsm_datagram
);
ec_datagram_output_stats
(
&
master
->
fsm_datagram
);
...
@@ -869,6 +875,7 @@ static int ec_master_operation_thread(ec_master_t *master)
...
@@ -869,6 +875,7 @@ static int ec_master_operation_thread(ec_master_t *master)
{
{
daemonize
(
"EtherCAT-OP"
);
daemonize
(
"EtherCAT-OP"
);
allow_signal
(
SIGTERM
);
allow_signal
(
SIGTERM
);
complete
(
&
master
->
thread_can_terminate
);
while
(
!
signal_pending
(
current
))
{
while
(
!
signal_pending
(
current
))
{
ec_datagram_output_stats
(
&
master
->
fsm_datagram
);
ec_datagram_output_stats
(
&
master
->
fsm_datagram
);
...
...
This diff is collapsed.
Click to expand it.
master/master.h
+
7
−
0
View file @
8154426b
...
@@ -135,6 +135,13 @@ struct ec_master {
...
@@ -135,6 +135,13 @@ struct ec_master {
call to ecrt_master_receive(). */
call to ecrt_master_receive(). */
int
thread_id
;
/**< Master thread PID. */
int
thread_id
;
/**< Master thread PID. */
struct
completion
thread_can_terminate
;
/**< Thread termination completion
object. When stopping the
thread, it must be assured, that
it 'hears' a SIGTERM, therefore
the allow_singal() function must
have been called.
*/
struct
completion
thread_exit
;
/**< Thread completion object. */
struct
completion
thread_exit
;
/**< Thread completion object. */
#ifdef EC_EOE
#ifdef EC_EOE
...
...
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