Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
proview
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
Esteban Blanc
proview
Commits
abaa3cdb
Commit
abaa3cdb
authored
Sep 23, 2008
by
claes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Changed control of loop to clock_nanosleep whith CLOCK_MONOTONIC
parent
10c1f093
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
17 deletions
+29
-17
src/lib/rt/src/rt_plc_thread.c
src/lib/rt/src/rt_plc_thread.c
+29
-17
No files found.
src/lib/rt/src/rt_plc_thread.c
View file @
abaa3cdb
/*
* Proview $Id: rt_plc_thread.c,v 1.1
3 2007-05-07 12:36:0
1 claes Exp $
* Proview $Id: rt_plc_thread.c,v 1.1
4 2008-09-23 07:20:5
1 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
...
...
@@ -28,6 +28,7 @@
#if defined(OS_LINUX)
# include <pwd.h>
# include <signal.h>
#endif
#include "pwr.h"
...
...
@@ -64,7 +65,6 @@
*/
#define USE_RT_TIMER 0
static
void
scan
(
plc_sThread
*
);
...
...
@@ -170,13 +170,13 @@ plc_thread (
pwrb_PlcThread_Zero
(
tp
);
time_Uptime
(
&
sts
,
&
tp
->
sync_time
,
NULL
);
clock_gettime
(
CLOCK_MONOTONIC
,
&
tp
->
sync_time
);
tp
->
ActualScanTime
=
tp
->
f_scan_time
;
while
(
!
tp
->
exit
)
while
(
!
tp
->
exit
)
{
scan
(
tp
);
}
#if 0 /*defined(OS_ELN)*/
if (wfp) {
/* We have exited the PLC loop. Clean up watchdog object */
...
...
@@ -201,15 +201,16 @@ scan (
plc_sProcess
*
pp
=
tp
->
pp
;
int
delay_action
=
0
;
time_Uptime
(
&
sts
,
&
tp
->
before_scan
,
NULL
);
// time_Uptime(&sts, &tp->before_scan, NULL);
clock_gettime
(
CLOCK_MONOTONIC
,
&
tp
->
before_scan
);
clock_gettime
(
CLOCK_REALTIME
,
&
tp
->
before_scan_abs
);
pp
->
Node
->
SystemTime
=
tp
->
before_scan_abs
;
if
(
tp
->
loops
>
0
)
{
if
(
sts
==
TIME__CLKCHANGE
)
{
/*
if (sts == TIME__CLKCHANGE) {
time_Dadd(&tp->before_scan, &tp->one_before_scan, &tp->scan_time);
}
time_
Dsub
(
&
tp
->
delta_scan
,
&
tp
->
before_scan
,
&
tp
->
one_before_scan
);
}
*/
time_
Adiff
(
&
tp
->
delta_scan
,
&
tp
->
before_scan
,
&
tp
->
one_before_scan
);
time_DToFloat
(
&
tp
->
ActualScanTime
,
&
tp
->
delta_scan
);
if
(
tp
->
ActualScanTime
<
MIN_SCANTIME
)
tp
->
ActualScanTime
=
MIN_SCANTIME
;
...
...
@@ -255,10 +256,10 @@ scan (
if
(
tp
->
first_scan
)
tp
->
first_scan
=
0
;
time_Uptime
(
&
sts
,
&
tp
->
after_scan
,
NULL
);
if
(
sts
==
TIME__CLKCHANGE
)
{
clock_gettime
(
CLOCK_MONOTONIC
,
&
tp
->
after_scan
);
/*
if (sts == TIME__CLKCHANGE) {
tp->after_scan = tp->before_scan;
}
}
*/
clock_gettime
(
CLOCK_REALTIME
,
&
tp
->
after_scan_abs
);
if
(
tp
->
log
)
pwrb_PlcThread_Exec
(
tp
);
...
...
@@ -267,8 +268,8 @@ scan (
pwr_tDeltaTime
delta
;
plc_timerhandler
(
tp
);
time_
D
add
(
NULL
,
&
tp
->
sync_time
,
&
tp
->
scan_time
);
time_
Dsub
(
&
delta
,
&
tp
->
sync_time
,
&
tp
->
after_scan
);
time_
A
add
(
NULL
,
&
tp
->
sync_time
,
&
tp
->
scan_time
);
time_
Adiff
(
&
delta
,
&
tp
->
sync_time
,
&
tp
->
after_scan
);
if
(
time_Dcomp
(
&
delta
,
NULL
)
>
0
)
{
pwr_tStatus
sts
;
int
phase
;
...
...
@@ -276,7 +277,7 @@ scan (
if
(
tp
->
csup_lh
!=
NULL
)
{
pwr_tTime
now
;
clock_gettime
(
CLOCK_REALTIME
,
&
now
);
delay_action
=
csup_Exec
(
&
sts
,
tp
->
csup_lh
,
&
tp
->
sync_time
,
&
tp
->
after_scan
,
&
now
);
delay_action
=
csup_Exec
(
&
sts
,
tp
->
csup_lh
,
(
pwr_tDeltaTime
*
)
&
tp
->
sync_time
,
(
pwr_tDeltaTime
*
)
&
tp
->
after_scan
,
&
now
);
if
(
delay_action
==
2
)
{
pp
->
IOHandler
->
IOReadWriteFlag
=
FALSE
;
errh_SetStatus
(
PLC__IOSTALLED
);
...
...
@@ -287,7 +288,18 @@ scan (
sem_wait
(
&
tp
->
ScanSem
);
phase
=
0
;
#else
phase
=
(
int
)
que_Get
(
&
sts
,
&
tp
->
q_in
,
&
delta
,
NULL
);
/* REMARK
* que_Get makes use of pthread_cond_timedwait.
* At this point it is not possible to set the clock-attribute of a condition variable.
* It should be set with pthread_condattr_setclock() to CLOCK_MONOTONIC, default
* is always CLOCK_REALTIME which might change. Instead we use clock_nanosleep()
* and don't have a controlled stop, in most cases we are sleeping anyway.
* The controlled stop is only needed for warm restart.
* END REMARK
*/
// phase = (int)que_Get(&sts, &tp->q_in, &delta, NULL);
clock_nanosleep
(
CLOCK_MONOTONIC
,
TIMER_ABSTIME
,
&
tp
->
sync_time
,
NULL
);
#endif
if
(
phase
>
0
)
{
tp
->
exit
=
TRUE
;
...
...
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