Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
P
PPSi
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
50
Issues
50
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
PPSi
Commits
14583c20
Commit
14583c20
authored
Feb 11, 2015
by
Adam Wujek
💬
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
arch-wrs: add locking on writes to ppsi shemem
Signed-off-by:
Adam Wujek
<
adam.wujek@cern.ch
>
parent
d39a15b9
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
4 deletions
+21
-4
wrs-startup.c
arch-wrs/wrs-startup.c
+8
-3
wr-servo.c
proto-ext-whiterabbit/wr-servo.c
+13
-1
No files found.
arch-wrs/wrs-startup.c
View file @
14583c20
...
...
@@ -58,7 +58,7 @@ struct minipc_ch *hal_ch;
struct
minipc_ch
*
ppsi_ch
;
struct
hal_port_state
*
hal_ports
;
int
hal_nports
;
struct
wrs_shm_head
*
ppsi_head
;
/*
* we need to call calloc, to reset all stuff that used to be static,
* but we'd better have a simple prototype, compatilble with wrs_shm_alloc()
...
...
@@ -80,7 +80,7 @@ int main(int argc, char **argv)
unsigned
long
seed
;
struct
timex
t
;
int
i
,
hal_retries
;
struct
wrs_shm_head
*
hal_head
,
*
ppsi_head
;
struct
wrs_shm_head
*
hal_head
;
struct
hal_shmem_header
*
h
;
void
*
(
*
alloc_fn
)(
void
*
headptr
,
size_t
size
)
=
local_malloc
;
...
...
@@ -139,7 +139,8 @@ int main(int argc, char **argv)
}
wrs_init_ipcserver
(
ppsi_ch
);
ppsi_head
=
wrs_shm_get
(
wrs_shm_ptp
,
"ppsi"
,
WRS_SHM_WRITE
);
ppsi_head
=
wrs_shm_get
(
wrs_shm_ptp
,
"ppsi"
,
WRS_SHM_WRITE
|
WRS_SHM_LOCKED
);
if
(
!
ppsi_head
)
{
fprintf
(
stderr
,
"Fatal: could not create shmem: %s
\n
"
,
strerror
(
errno
));
...
...
@@ -241,6 +242,10 @@ int main(int argc, char **argv)
seed
=
atoi
(
getenv
(
"PPSI_DROP_SEED"
));
ppsi_drop_init
(
ppg
,
seed
);
/* release lock from wrs_shm_get */
if
(
BUILT_WITH_WHITERABBIT
)
wrs_shm_write
(
ppsi_head
,
WRS_SHM_WRITE_END
);
wrs_main_loop
(
ppg
);
return
0
;
/* never reached */
}
proto-ext-whiterabbit/wr-servo.c
View file @
14583c20
#include <ppsi/ppsi.h>
#include "wr-api.h"
#include <libwr/shmem.h>
#define WR_SERVO_NONE 0
#define WR_SYNC_NSEC 1
...
...
@@ -26,6 +27,7 @@ static const char *servo_name[] = {
ptpdexp_sync_state_t
cur_servo_state
;
/* Exported with mini-rpc */
static
int
tracking_enabled
=
1
;
/* FIXME: why? */
extern
struct
wrs_shm_head
*
ppsi_head
;
void
wr_servo_enable_tracking
(
int
enable
)
{
...
...
@@ -149,7 +151,8 @@ int wr_servo_init(struct pp_instance *ppi)
struct
wr_dsport
*
wrp
=
WR_DSPOR
(
ppi
);
struct
wr_servo_state_t
*
s
=
&
((
struct
wr_data_t
*
)
ppi
->
ext_data
)
->
servo_state
;
/* shmem lock */
wrs_shm_write
(
ppsi_head
,
WRS_SHM_WRITE_BEGIN
);
/* Determine the alpha coefficient */
if
(
wrp
->
ops
->
read_calib_data
(
ppi
,
0
,
0
,
&
s
->
fiber_fix_alpha
,
&
s
->
clock_period_ps
)
!=
WR_HW_CALIB_OK
)
...
...
@@ -190,6 +193,9 @@ int wr_servo_init(struct pp_instance *ppi)
s
->
update_count
=
0
;
got_sync
=
0
;
/* shmem unlock */
wrs_shm_write
(
ppsi_head
,
WRS_SHM_WRITE_END
);
return
0
;
}
...
...
@@ -257,6 +263,10 @@ int wr_servo_update(struct pp_instance *ppi)
s
->
t3
.
correct
,
s
->
t4
.
correct
);
return
0
;
}
/* shmem lock */
wrs_shm_write
(
ppsi_head
,
WRS_SHM_WRITE_BEGIN
);
errcount
=
0
;
cur_servo_state
.
update_count
++
;
...
...
@@ -411,5 +421,7 @@ int wr_servo_update(struct pp_instance *ppi)
break
;
}
/* shmem unlock */
wrs_shm_write
(
ppsi_head
,
WRS_SHM_WRITE_END
);
return
0
;
}
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