Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
OpenXG-RAN
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
alex037yang
OpenXG-RAN
Commits
129d4833
Commit
129d4833
authored
Mar 07, 2019
by
laurent
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
more fixes in mutext
parent
5e47fa4d
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
228 additions
and
270 deletions
+228
-270
targets/ARCH/rfsimulator/simulator.c
targets/ARCH/rfsimulator/simulator.c
+2
-2
targets/RT/USER/lte-ue.c
targets/RT/USER/lte-ue.c
+226
-268
No files found.
targets/ARCH/rfsimulator/simulator.c
View file @
129d4833
/*
Author: Laurent THOMAS, Open Cells for Nokia
copyleft: OpenAirInterface Software Alliance and it's licence
...
...
@@ -326,7 +325,6 @@ bool flushInput(rfsimulator_state_t *t) {
return
nfds
>
0
;
}
int
rfsimulator_read
(
openair0_device
*
device
,
openair0_timestamp
*
ptimestamp
,
void
**
samplesVoid
,
int
nsamps
,
int
nbAnt
)
{
if
(
nbAnt
!=
1
)
{
LOG_E
(
HW
,
"rfsimulator: only 1 antenna tested
\n
"
);
exit
(
1
);
}
...
...
@@ -413,6 +411,7 @@ int rfsimulator_read(openair0_device *device, openair0_timestamp *ptimestamp, vo
return
nsamps
;
}
int
rfsimulator_request
(
openair0_device
*
device
,
void
*
msg
,
ssize_t
msg_len
)
{
abort
();
return
0
;
...
...
@@ -442,6 +441,7 @@ int rfsimulator_set_gains(openair0_device *device, openair0_config_t *openair0_c
__attribute__
((
__visibility__
(
"default"
)))
int
device_init
(
openair0_device
*
device
,
openair0_config_t
*
openair0_cfg
)
{
//set_log(HW,OAILOG_DEBUG);
//set_log(PHY,OAILOG_DEBUG);
rfsimulator_state_t
*
rfsimulator
=
(
rfsimulator_state_t
*
)
calloc
(
sizeof
(
rfsimulator_state_t
),
1
);
if
((
rfsimulator
->
ip
=
getenv
(
"RFSIMULATOR"
))
==
NULL
)
{
...
...
targets/RT/USER/lte-ue.c
View file @
129d4833
...
...
@@ -544,7 +544,7 @@ static void *UE_thread_synch(void *arg)
while
(
UE
->
proc
.
instance_cnt_synch
<
0
)
// the thread waits here most of the time
pthread_cond_wait
(
&
UE
->
proc
.
cond_synch
,
&
UE
->
proc
.
mutex_synch
);
AssertFatal
(
0
==
pthread_mutex_unlock
(
&
UE
->
proc
.
mutex_synch
),
""
);
LOG_I
(
PHY
,
"Starting a sync process
\n
"
);
switch
(
sync_mode
)
{
case
pss
:
...
...
@@ -647,9 +647,7 @@ static void *UE_thread_synch(void *arg)
UE
->
UE_scan_carrier
=
0
;
}
else
{
AssertFatal
(
0
==
pthread_mutex_lock
(
&
UE
->
proc
.
mutex_synch
),
""
);
UE
->
is_synchronized
=
1
;
AssertFatal
(
0
==
pthread_mutex_unlock
(
&
UE
->
proc
.
mutex_synch
),
""
);
if
(
UE
->
mode
==
rx_dump_frame
)
{
FILE
*
fd
;
...
...
@@ -667,10 +665,7 @@ static void *UE_thread_synch(void *arg)
exit
(
0
);
}
}
else
{
AssertFatal
(
0
==
pthread_mutex_lock
(
&
UE
->
proc
.
mutex_synch
),
""
);
UE
->
is_synchronized
=
0
;
AssertFatal
(
0
==
pthread_mutex_unlock
(
&
UE
->
proc
.
mutex_synch
),
""
);
}
}
}
...
...
@@ -719,7 +714,6 @@ static void *UE_thread_synch(void *arg)
break
;
}
AssertFatal
(
0
==
pthread_mutex_lock
(
&
UE
->
proc
.
mutex_synch
),
""
);
// indicate readiness
UE
->
proc
.
instance_cnt_synch
--
;
AssertFatal
(
0
==
pthread_mutex_unlock
(
&
UE
->
proc
.
mutex_synch
),
""
);
...
...
@@ -773,18 +767,10 @@ static void *UE_thread_rxn_txnp4(void *arg) {
threadname
);
while
(
!
oai_exit
)
{
if
(
pthread_mutex_lock
(
&
proc
->
mutex_rxtx
)
!=
0
)
{
LOG_E
(
PHY
,
"[SCHED][UE] error locking mutex for UE RXTX
\n
"
);
exit_fun
(
"nothing to add"
);
}
while
(
proc
->
instance_cnt_rxtx
<
0
)
{
AssertFatal
(
pthread_mutex_lock
(
&
proc
->
mutex_rxtx
)
==
0
,
"[SCHED][UE] error locking mutex for UE RXTX
\n
"
);
while
(
proc
->
instance_cnt_rxtx
<
0
)
// most of the time, the thread is waiting here
pthread_cond_wait
(
&
proc
->
cond_rxtx
,
&
proc
->
mutex_rxtx
);
}
if
(
pthread_mutex_unlock
(
&
proc
->
mutex_rxtx
)
!=
0
)
{
LOG_E
(
PHY
,
"[SCHED][UE] error unlocking mutex for UE RXn_TXnp4
\n
"
);
exit_fun
(
"nothing to add"
);
}
initRefTimes
(
t2
);
initRefTimes
(
t3
);
...
...
@@ -858,18 +844,8 @@ static void *UE_thread_rxn_txnp4(void *arg) {
phy_procedures_UE_S_TX
(
UE
,
0
,
0
);
updateTimes
(
current
,
&
t3
,
10000
,
"Delay to process sub-frame (case 3)"
);
if
(
pthread_mutex_lock
(
&
proc
->
mutex_rxtx
)
!=
0
)
{
LOG_E
(
PHY
,
"[SCHED][UE] error locking mutex for UE RXTX
\n
"
);
exit_fun
(
"noting to add"
);
}
proc
->
instance_cnt_rxtx
--
;
#if BASIC_SIMULATOR
if
(
pthread_cond_signal
(
&
proc
->
cond_rxtx
)
!=
0
)
abort
();
#endif
if
(
pthread_mutex_unlock
(
&
proc
->
mutex_rxtx
)
!=
0
)
{
LOG_E
(
PHY
,
"[SCHED][UE] error unlocking mutex for UE RXTX
\n
"
);
exit_fun
(
"noting to add"
);
}
AssertFatal
(
pthread_mutex_unlock
(
&
proc
->
mutex_rxtx
)
==
0
,
"[SCHED][UE] error unlocking mutex for UE RXTX
\n
"
);
}
// thread finished
...
...
@@ -1557,35 +1533,26 @@ void *UE_thread(void *arg) {
oai_exit
=
1
;
}
UE_rxtx_proc_t
*
proc
=
UE
->
proc
.
proc_rxtx
;
while
(
!
oai_exit
)
{
#if BASIC_SIMULATOR
while
(
!
(
UE
->
proc
.
instance_cnt_synch
<
0
))
{
printf
(
"ue sync not ready
\n
"
);
usleep
(
500
*
1000
);
}
#endif
AssertFatal
(
0
==
pthread_mutex_lock
(
&
UE
->
proc
.
mutex_synch
),
""
);
int
instance_cnt_synch
=
UE
->
proc
.
instance_cnt_synch
;
int
is_synchronized
=
UE
->
is_synchronized
;
AssertFatal
(
0
==
pthread_mutex_unlock
(
&
UE
->
proc
.
mutex_synch
),
""
);
if
(
is_synchronized
==
0
)
{
if
(
instance_cnt_synch
<
0
)
{
// we can invoke the synch
// grab 10 ms of signal and wakeup synch thread
if
(
pthread_mutex_trylock
(
&
UE
->
proc
.
mutex_synch
)
!=
0
)
{
// a sync detection is running
// grab 10 ms of signal into dummy buffer to wait result of sync detection
if
(
UE
->
mode
!=
loop_through_memory
)
{
void
*
dummy_tx
[
UE
->
frame_parms
.
nb_antennas_tx
];
for
(
int
i
=
0
;
i
<
UE
->
frame_parms
.
nb_antennas_tx
;
i
++
)
dummy_tx
[
i
]
=
malloc16_clear
(
UE
->
frame_parms
.
samples_per_tti
*
4
);
for
(
int
x
=
0
;
x
<
10
;
x
++
)
{
void
*
dummy_rx
[
UE
->
frame_parms
.
nb_antennas_rx
];
for
(
int
i
=
0
;
i
<
UE
->
frame_parms
.
nb_antennas_rx
;
i
++
)
rxp
[
i
]
=
((
void
*
)
&
UE
->
common_vars
.
rxdata
[
i
][
0
])
+
4
*
x
*
UE
->
frame_parms
.
samples_per_tti
;
AssertFatal
(
UE
->
frame_parms
.
samples_per_tti
==
dummy_rx
[
i
]
=
malloc16
(
UE
->
frame_parms
.
samples_per_tti
*
4
);
for
(
int
sf
=
0
;
sf
<
10
;
sf
++
)
{
// printf("Reading dummy sf %d\n",sf);
UE
->
rfdevice
.
trx_read_func
(
&
UE
->
rfdevice
,
&
timestamp
,
rxp
,
dummy_rx
,
UE
->
frame_parms
.
samples_per_tti
,
UE
->
frame_parms
.
nb_antennas_rx
),
""
);
UE
->
frame_parms
.
nb_antennas_rx
);
AssertFatal
(
UE
->
frame_parms
.
samples_per_tti
==
UE
->
rfdevice
.
trx_write_func
(
&
UE
->
rfdevice
,
timestamp
+
(
2
*
UE
->
frame_parms
.
samples_per_tti
)
-
...
...
@@ -1597,27 +1564,28 @@ void *UE_thread(void *arg) {
}
for
(
int
i
=
0
;
i
<
UE
->
frame_parms
.
nb_antennas_tx
;
i
++
)
free
(
dummy_tx
[
i
]);
for
(
int
i
=
0
;
i
<
UE
->
frame_parms
.
nb_antennas_rx
;
i
++
)
free
(
dummy_rx
[
i
]);
}
AssertFatal
(
0
==
pthread_mutex_lock
(
&
UE
->
proc
.
mutex_synch
),
""
);
AssertFatal
(
0
==
++
UE
->
proc
.
instance_cnt_synch
,
"[SCHED][UE] UE sync thread busy!!
\n
"
)
;
AssertFatal
(
0
==
pthread_cond_signal
(
&
UE
->
proc
.
cond_synch
),
""
);
AssertFatal
(
0
==
pthread_mutex_unlock
(
&
UE
->
proc
.
mutex_synch
),
""
);
}
else
{
// grab 10 ms of signal
into dummy buffer to wait result of sync detection
usleep
(
1000
);
// relax time when I/Q acquisition is not realtime (simulators)
continue
;
}
if
(
UE
->
is_synchronized
==
0
)
{
// grab 10 ms of signal
and wakeup synch thread
if
(
UE
->
mode
!=
loop_through_memory
)
{
void
*
dummy_tx
[
UE
->
frame_parms
.
nb_antennas_tx
];
for
(
int
i
=
0
;
i
<
UE
->
frame_parms
.
nb_antennas_tx
;
i
++
)
dummy_tx
[
i
]
=
malloc16_clear
(
UE
->
frame_parms
.
samples_per_tti
*
4
);
void
*
dummy_rx
[
UE
->
frame_parms
.
nb_antennas_rx
];
for
(
int
x
=
0
;
x
<
10
;
x
++
)
{
for
(
int
i
=
0
;
i
<
UE
->
frame_parms
.
nb_antennas_rx
;
i
++
)
dummy_rx
[
i
]
=
malloc16
(
UE
->
frame_parms
.
samples_per_tti
*
4
);
for
(
int
sf
=
0
;
sf
<
10
;
sf
++
)
{
// printf("Reading dummy sf %d\n",sf);
rxp
[
i
]
=
((
void
*
)
&
UE
->
common_vars
.
rxdata
[
i
][
0
])
+
4
*
x
*
UE
->
frame_parms
.
samples_per_tti
;
AssertFatal
(
UE
->
frame_parms
.
samples_per_tti
==
UE
->
rfdevice
.
trx_read_func
(
&
UE
->
rfdevice
,
&
timestamp
,
dummy_rx
,
rxp
,
UE
->
frame_parms
.
samples_per_tti
,
UE
->
frame_parms
.
nb_antennas_rx
);
UE
->
frame_parms
.
nb_antennas_rx
),
""
);
AssertFatal
(
UE
->
frame_parms
.
samples_per_tti
==
UE
->
rfdevice
.
trx_write_func
(
&
UE
->
rfdevice
,
timestamp
+
(
2
*
UE
->
frame_parms
.
samples_per_tti
)
-
...
...
@@ -1626,18 +1594,20 @@ void *UE_thread(void *arg) {
UE
->
frame_parms
.
samples_per_tti
,
UE
->
frame_parms
.
nb_antennas_tx
,
1
),
""
);
usleep
(
900
);
// this sleep improves in the case of simulated RF and doesn't harm with true radio
}
for
(
int
i
=
0
;
i
<
UE
->
frame_parms
.
nb_antennas_tx
;
i
++
)
free
(
dummy_tx
[
i
]);
for
(
int
i
=
0
;
i
<
UE
->
frame_parms
.
nb_antennas_rx
;
i
++
)
free
(
dummy_rx
[
i
]);
}
}
UE
->
proc
.
instance_cnt_synch
=
0
;
AssertFatal
(
0
==
pthread_cond_signal
(
&
UE
->
proc
.
cond_synch
),
""
);
AssertFatal
(
0
==
pthread_mutex_unlock
(
&
UE
->
proc
.
mutex_synch
),
""
);
continue
;
}
// UE->is_synchronized==0
else
{
// UE is synchronized
AssertFatal
(
0
==
pthread_mutex_unlock
(
&
UE
->
proc
.
mutex_synch
),
""
);
// A specific processing for first sub-frame after synchro
if
(
start_rx_stream
==
0
)
{
start_rx_stream
=
1
;
if
(
UE
->
mode
!=
loop_through_memory
)
{
...
...
@@ -1685,32 +1655,33 @@ void *UE_thread(void *arg) {
}
//UE->mode != loop_through_memory
else
rt_sleep_ns
(
1000
*
1000
);
continue
;
}
}
else
{
sub_frame
++
;
sub_frame
%=
10
;
UE_rxtx_proc_t
*
proc
=
&
UE
->
proc
.
proc_rxtx
[
thread_idx
];
// update thread index for received subframe
UE
->
current_thread_id
[
sub_frame
]
=
thread_idx
;
#if BASIC_SIMULATOR
{
int
t
;
for
(
t
=
0
;
t
<
2
;
t
++
)
{
UE_rxtx_proc_t
*
proc
=
&
UE
->
proc
.
proc_rxtx
[
t
];
// Normale subframe processing
sub_frame
=
(
sub_frame
+
1
)
%
10
;
//Force wait in simulation because odd and even subframe processing threads seems to haverace conditions
AssertFatal
(
proc
,
""
);
if
(
getenv
(
"RFSIMULATOR"
))
{
bool
ok
;
do
{
pthread_mutex_lock
(
&
proc
->
mutex_rxtx
);
while
(
proc
->
instance_cnt_rxtx
>=
0
)
pthread_cond_wait
(
&
proc
->
cond_rxtx
,
&
proc
->
mutex_rxtx
)
;
ok
=
proc
->
instance_cnt_rxtx
==-
1
;
pthread_mutex_unlock
(
&
proc
->
mutex_rxtx
);
}
while
(
!
ok
);
}
}
#if BASIC_SIMULATOR
pthread_mutex_lock
(
&
proc
->
mutex_rxtx
);
pthread_mutex_unlock
(
&
proc
->
mutex_rxtx
);
#endif
LOG_D
(
PHY
,
"Process Subframe %d thread Idx %d
\n
"
,
sub_frame
,
UE
->
current_thread_id
[
sub_frame
]);
proc
=
&
UE
->
proc
.
proc_rxtx
[
thread_idx
];
// update thread index for received subframe
UE
->
current_thread_id
[
sub_frame
]
=
thread_idx
;
thread_idx
++
;
if
(
thread_idx
>=
RX_NB_TH
)
thread_idx
=
0
;
LOG_D
(
PHY
,
"Process Subframe %d thread Idx %d
\n
"
,
sub_frame
,
UE
->
current_thread_id
[
sub_frame
]);
thread_idx
=
(
thread_idx
+
1
)
%
RX_NB_TH
;
if
(
UE
->
mode
!=
loop_through_memory
)
{
for
(
i
=
0
;
i
<
UE
->
frame_parms
.
nb_antennas_rx
;
i
++
)
rxp
[
i
]
=
(
void
*
)
&
UE
->
common_vars
.
rxdata
[
i
][
UE
->
frame_parms
.
ofdm_symbol_size
+
...
...
@@ -1731,9 +1702,6 @@ void *UE_thread(void *arg) {
// compute TO compensation that should be applied for this frame
if
(
UE
->
no_timing_correction
==
0
)
{
if
(
getenv
(
"RFSIMULATOR"
)
!=
NULL
&&
UE
->
rx_offset
)
{
LOG_W
(
HW
,
"in simu, rx_offset is not null: %d
\n
"
,
UE
->
rx_offset
);
}
if
(
UE
->
rx_offset
<
5
*
UE
->
frame_parms
.
samples_per_tti
&&
UE
->
rx_offset
>
0
)
UE
->
rx_offset_diff
=
-
1
;
...
...
@@ -1742,7 +1710,12 @@ void *UE_thread(void *arg) {
UE
->
rx_offset_diff
=
1
;
}
LOG_D
(
PHY
,
"AbsSubframe %d.%d SET rx_off_diff to %d rx_offset %d
\n
"
,
proc
->
frame_rx
,
sub_frame
,
UE
->
rx_offset_diff
,
UE
->
rx_offset
);
LOG_D
(
PHY
,
"AbsSubframe %d.%d SET rx_off_diff to %d rx_offset %d
\n
"
,
proc
->
frame_rx
,
sub_frame
,
UE
->
rx_offset_diff
,
UE
->
rx_offset
);
if
(
getenv
(
"RFSIMULATOR"
)
!=
NULL
&&
UE
->
rx_offset
)
{
LOG_W
(
HW
,
"in simu, rx_offset is not null: %d
\n
"
,
UE
->
rx_offset
);
//UE->rx_offset_diff=0;
}
readBlockSize
=
UE
->
frame_parms
.
samples_per_tti
-
UE
->
frame_parms
.
ofdm_symbol_size
-
UE
->
frame_parms
.
nb_prefix_samples0
-
...
...
@@ -1784,7 +1757,11 @@ void *UE_thread(void *arg) {
}
pickTime
(
gotIQs
);
// operate on thread sf mod 2
AssertFatal
(
pthread_mutex_lock
(
&
proc
->
mutex_rxtx
)
==
0
,
""
);
if
(
pthread_mutex_trylock
(
&
proc
->
mutex_rxtx
)
!=
0
)
{
LOG_E
(
PHY
,
"Real time issue in subframes processing, skipping subframe %d
\n
"
,
proc
->
subframe_rx
);
continue
;
}
if
(
sub_frame
==
0
)
{
//UE->proc.proc_rxtx[0].frame_rx++;
//UE->proc.proc_rxtx[1].frame_rx++;
...
...
@@ -1804,23 +1781,7 @@ void *UE_thread(void *arg) {
(
4
*
UE
->
frame_parms
.
samples_per_tti
)
-
UE
->
frame_parms
.
ofdm_symbol_size
-
UE
->
frame_parms
.
nb_prefix_samples0
;
proc
->
instance_cnt_rxtx
++
;
LOG_D
(
PHY
,
"[SCHED][UE %d] UE RX instance_cnt_rxtx %d subframe %d !!
\n
"
,
UE
->
Mod_id
,
proc
->
instance_cnt_rxtx
,
proc
->
subframe_rx
);
if
(
proc
->
instance_cnt_rxtx
!=
0
)
{
if
(
getenv
(
"RFSIMULATOR"
)
!=
NULL
)
{
do
{
AssertFatal
(
pthread_mutex_unlock
(
&
proc
->
mutex_rxtx
)
==
0
,
""
);
usleep
(
100
);
AssertFatal
(
pthread_mutex_lock
(
&
proc
->
mutex_rxtx
)
==
0
,
""
);
}
while
(
proc
->
instance_cnt_rxtx
>=
0
);
}
else
LOG_E
(
PHY
,
"[SCHED][UE %d] UE RX thread busy (IC %d)!!
\n
"
,
UE
->
Mod_id
,
proc
->
instance_cnt_rxtx
);
if
(
proc
->
instance_cnt_rxtx
>
2
)
exit_fun
(
"instance_cnt_rxtx > 2"
);
}
proc
->
instance_cnt_rxtx
=
0
;
AssertFatal
(
pthread_cond_signal
(
&
proc
->
cond_rxtx
)
==
0
,
""
);
AssertFatal
(
pthread_mutex_unlock
(
&
proc
->
mutex_rxtx
)
==
0
,
""
);
initRefTimes
(
t1
);
...
...
@@ -1832,10 +1793,7 @@ void *UE_thread(void *arg) {
printf
(
"Processing subframe %d"
,
proc
->
subframe_rx
);
getchar
();
}
}
// start_rx_stream==1
}
// UE->is_synchronized==1
}
// while !oai_exit
}
return
NULL
;
}
...
...
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