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
promise
OpenXG-RAN
Commits
cec3f0ae
Commit
cec3f0ae
authored
May 23, 2019
by
Wang Tsu-Han
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adding assertion to lock and adding timedwait with other realtime threading handel
parent
296560f4
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
176 additions
and
215 deletions
+176
-215
cmake_targets/CMakeLists.txt
cmake_targets/CMakeLists.txt
+1
-1
openair1/PHY/defs_common.h
openair1/PHY/defs_common.h
+46
-60
targets/RT/USER/lte-enb.c
targets/RT/USER/lte-enb.c
+129
-154
No files found.
cmake_targets/CMakeLists.txt
View file @
cec3f0ae
...
...
@@ -21,7 +21,7 @@
# Author: laurent THOMAS, Lionel GAUTHIER
cmake_minimum_required
(
VERSION
3.0
)
cmake_minimum_required
(
VERSION
2.8
)
#############################################
# Base directories, compatible with legacy OAI building
...
...
openair1/PHY/defs_common.h
View file @
cec3f0ae
...
...
@@ -51,6 +51,7 @@
#include <sys/sysinfo.h>
#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
...
...
@@ -60,6 +61,8 @@
#include "msc.h"
#include <common/utils/LOG/log.h>
#include "assertions.h"
//#include <complex.h>
...
...
@@ -1035,14 +1038,15 @@ typedef uint8_t(encoder_if_t)(uint8_t *input,
static
inline
void
wait_sync
(
char
*
thread_name
)
{
int
rc
;
printf
(
"waiting for sync (%s,%d/%p,%p,%p)
\n
"
,
thread_name
,
sync_var
,
&
sync_var
,
&
sync_cond
,
&
sync_mutex
);
pthread_mutex_lock
(
&
sync_mutex
);
AssertFatal
((
rc
=
pthread_mutex_lock
(
&
sync_mutex
))
==
0
,
"sync mutex lock error"
);
while
(
sync_var
<
0
)
pthread_cond_wait
(
&
sync_cond
,
&
sync_mutex
);
pthread_mutex_unlock
(
&
sync_mutex
);
AssertFatal
((
rc
=
pthread_mutex_unlock
(
&
sync_mutex
))
==
0
,
"sync mutex unlock error"
);
printf
(
"got sync (%s)
\n
"
,
thread_name
);
/*
...
...
@@ -1056,37 +1060,20 @@ static inline int wakeup_thread(pthread_mutex_t *mutex,pthread_cond_t *cond,int
int
rc
;
int
sleep_cnt
=
0
;
if
((
rc
=
pthread_mutex_lock
(
mutex
))
!=
0
)
{
LOG_E
(
PHY
,
"wakeup_thread(): error locking mutex for %s (%d %s, %p)
\n
"
,
name
,
rc
,
strerror
(
rc
),
(
void
*
)
mutex
);
exit_fun
(
"nothing to add"
);
return
(
-
1
);
}
AssertFatal
((
rc
=
pthread_mutex_lock
(
mutex
))
==
0
,
"wakeup_thread(): error locking mutex for %s (%d %s, %p)
\n
"
,
name
,
rc
,
strerror
(
rc
),
(
void
*
)
mutex
);
while
(
*
instance_cnt
==
0
)
{
if
((
rc
=
pthread_mutex_unlock
(
mutex
))
!=
0
)
{
LOG_E
(
PHY
,
"wakeup_thread(): error unlocking mutex for %s (%d %s, %p)
\n
"
,
name
,
rc
,
strerror
(
rc
),
(
void
*
)
mutex
);
exit_fun
(
"nothing to add"
);
return
(
-
1
);
}
AssertFatal
((
rc
=
pthread_mutex_unlock
(
mutex
))
==
0
,
"wakeup_thread(): error unlocking mutex for %s (%d %s, %p)
\n
"
,
name
,
rc
,
strerror
(
rc
),
(
void
*
)
mutex
);
sleep_cnt
++
;
if
(
sleep_cnt
>
sleep_cnt_max
)
return
(
-
1
);
usleep
(
sleeptime
);
if
((
rc
=
pthread_mutex_lock
(
mutex
))
!=
0
)
{
LOG_E
(
PHY
,
"wakeup_thread(): error locking mutex for %s (%d %s, %p)
\n
"
,
name
,
rc
,
strerror
(
rc
),
(
void
*
)
mutex
);
exit_fun
(
"nothing to add"
);
return
(
-
1
);
}
AssertFatal
((
rc
=
pthread_mutex_lock
(
mutex
))
==
0
,
"wakeup_thread(): error locking mutex for %s (%d %s, %p)
\n
"
,
name
,
rc
,
strerror
(
rc
),
(
void
*
)
mutex
);
}
*
instance_cnt
=
*
instance_cnt
+
1
;
if
((
rc
=
pthread_mutex_unlock
(
mutex
))
!=
0
)
{
LOG_E
(
PHY
,
"wakeup_thread(): error locking mutex for %s (%d %s, %p)
\n
"
,
name
,
rc
,
strerror
(
rc
),
(
void
*
)
mutex
);
exit_fun
(
"nothing to add"
);
return
(
-
1
);
}
AssertFatal
((
rc
=
pthread_mutex_unlock
(
mutex
))
==
0
,
"wakeup_thread(): error unlocking mutex for %s (%d %s, %p)
\n
"
,
name
,
rc
,
strerror
(
rc
),
(
void
*
)
mutex
);
// the thread can now be woken up
if
(
pthread_cond_signal
(
cond
)
!=
0
)
{
...
...
@@ -1095,41 +1082,50 @@ static inline int wakeup_thread(pthread_mutex_t *mutex,pthread_cond_t *cond,int
return
(
-
1
);
}
pthread_mutex_unlock
(
mutex
);
AssertFatal
((
rc
=
pthread_mutex_unlock
(
mutex
))
==
0
,
"wakeup_thread(): error unlocking mutex for %s (%d %s, %p)
\n
"
,
name
,
rc
,
strerror
(
rc
),
(
void
*
)
mutex
);
return
(
0
);
}
static
inline
int
wait_on_condition
(
pthread_mutex_t
*
mutex
,
pthread_cond_t
*
cond
,
int
*
instance_cnt
,
char
*
name
)
{
static
inline
int
timedwait_on_condition
(
pthread_mutex_t
*
mutex
,
pthread_cond_t
*
cond
,
int
*
instance_cnt
,
char
*
name
,
uint32_t
time_ns
)
{
int
rc
;
if
((
rc
=
pthread_mutex_lock
(
mutex
))
!=
0
)
{
LOG_E
(
PHY
,
"[SCHED][eNB] wait_on_condition(): error locking mutex for %s (%d %s, %p)
\n
"
,
name
,
rc
,
strerror
(
rc
),
(
void
*
)
mutex
);
exit_fun
(
"nothing to add"
);
return
(
-
1
);
int
waitret
=
0
;
struct
timespec
now
,
abstime
;
AssertFatal
((
rc
=
pthread_mutex_lock
(
mutex
))
==
0
,
"[SCHED][eNB] timedwait_on_condition(): error locking mutex for %s (%d %s, %p)
\n
"
,
name
,
rc
,
strerror
(
rc
),
(
void
*
)
mutex
);
clock_gettime
(
CLOCK_REALTIME
,
&
now
);
while
(
*
instance_cnt
<
0
)
{
// most of the time the thread is waiting here
// proc->instance_cnt_rxtx is -1
abstime
.
tv_sec
=
now
.
tv_sec
;
abstime
.
tv_nsec
=
now
.
tv_nsec
+
time_ns
;
if
((
waitret
=
pthread_cond_timedwait
(
cond
,
mutex
,
&
abstime
))
==
ETIMEDOUT
)
break
;
// this unlocks mutex_rxtx while waiting and then locks it again
}
AssertFatal
((
rc
=
pthread_mutex_unlock
(
mutex
))
==
0
,
"[SCHED][eNB] timedwait_on_condition(): error unlocking mutex return %d for %s
\n
"
,
rc
,
name
);
return
(
0
);
}
static
inline
int
wait_on_condition
(
pthread_mutex_t
*
mutex
,
pthread_cond_t
*
cond
,
int
*
instance_cnt
,
char
*
name
)
{
int
rc
;
AssertFatal
((
rc
=
pthread_mutex_lock
(
mutex
))
==
0
,
"[SCHED][eNB] wait_on_condition(): error locking mutex for %s (%d %s, %p)
\n
"
,
name
,
rc
,
strerror
(
rc
),
(
void
*
)
mutex
);
while
(
*
instance_cnt
<
0
)
{
// most of the time the thread is waiting here
// proc->instance_cnt_rxtx is -1
pthread_cond_wait
(
cond
,
mutex
);
// this unlocks mutex_rxtx while waiting and then locks it again
}
if
(
pthread_mutex_unlock
(
mutex
)
!=
0
)
{
LOG_E
(
PHY
,
"[SCHED][eNB] error unlocking mutex for %s
\n
"
,
name
);
exit_fun
(
"nothing to add"
);
return
(
-
1
);
}
AssertFatal
((
rc
=
pthread_mutex_unlock
(
mutex
))
==
0
,
"[SCHED][eNB] wait_on_condition(): error unlocking mutex return %d for %s
\n
"
,
rc
,
name
);
return
(
0
);
}
static
inline
int
wait_on_busy_condition
(
pthread_mutex_t
*
mutex
,
pthread_cond_t
*
cond
,
int
*
instance_cnt
,
char
*
name
)
{
int
rc
;
if
((
rc
=
pthread_mutex_lock
(
mutex
))
!=
0
)
{
LOG_E
(
PHY
,
"[SCHED][eNB] wait_on_busy_condition(): error locking mutex for %s (%d %s, %p)
\n
"
,
name
,
rc
,
strerror
(
rc
),
(
void
*
)
mutex
);
exit_fun
(
"nothing to add"
);
return
(
-
1
);
}
AssertFatal
((
rc
=
pthread_mutex_lock
(
mutex
))
==
0
,
"[SCHED][eNB] wait_on_busy_condition(): error locking mutex for %s (%d %s, %p)
\n
"
,
name
,
rc
,
strerror
(
rc
),
(
void
*
)
mutex
);
while
(
*
instance_cnt
==
0
)
{
// most of the time the thread will skip this
...
...
@@ -1137,30 +1133,20 @@ static inline int wait_on_busy_condition(pthread_mutex_t *mutex,pthread_cond_t *
pthread_cond_wait
(
cond
,
mutex
);
// this unlocks mutex_rxtx while waiting and then locks it again
}
if
(
pthread_mutex_unlock
(
mutex
)
!=
0
)
{
LOG_E
(
PHY
,
"[SCHED][eNB] error unlocking mutex for %s
\n
"
,
name
);
exit_fun
(
"nothing to add"
);
return
(
-
1
);
}
AssertFatal
((
rc
=
pthread_mutex_unlock
(
mutex
))
==
0
,
"[SCHED][eNB] wait_on_busy_condition(): error unlocking mutex return %d for %s
\n
"
,
rc
,
name
);
return
(
0
);
}
static
inline
int
release_thread
(
pthread_mutex_t
*
mutex
,
int
*
instance_cnt
,
char
*
name
)
{
int
rc
;
if
((
rc
=
pthread_mutex_lock
(
mutex
))
!=
0
)
{
LOG_E
(
PHY
,
"[SCHED][eNB] release_thread(): error locking mutex for %s (%d %s, %p)
\n
"
,
name
,
rc
,
strerror
(
rc
),
(
void
*
)
mutex
);
exit_fun
(
"nothing to add"
);
return
(
-
1
);
}
AssertFatal
((
rc
=
pthread_mutex_lock
(
mutex
))
==
0
,
"[SCHED][eNB] release_thread(): error locking mutex for %s (%d %s, %p)
\n
"
,
name
,
rc
,
strerror
(
rc
),
(
void
*
)
mutex
);
*
instance_cnt
=*
instance_cnt
-
1
;
if
(
pthread_mutex_unlock
(
mutex
)
!=
0
)
{
LOG_E
(
PHY
,
"[SCHED][eNB] error unlocking mutex for %s
\n
"
,
name
);
exit_fun
(
"nothing to add"
);
return
(
-
1
);
}
AssertFatal
((
rc
=
pthread_mutex_unlock
(
mutex
))
==
0
,
"[SCHED][eNB] release_thread(): error unlocking mutex return %d for %s
\n
"
,
rc
,
name
);
return
(
0
);
}
...
...
targets/RT/USER/lte-enb.c
View file @
cec3f0ae
This diff is collapsed.
Click to expand it.
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