Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
OpenXG UE
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
OpenXG
OpenXG UE
Commits
e39a04a0
Commit
e39a04a0
authored
Oct 24, 2020
by
Michael Cook
Committed by
Michael Cook
Oct 24, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
unqueue_matching: Add max_depth argument
Look only at the last `max_depth` items on the queue, at most.
parent
82cdb652
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
52 additions
and
14 deletions
+52
-14
openair2/PHY_INTERFACE/phy_stub_UE.c
openair2/PHY_INTERFACE/phy_stub_UE.c
+8
-2
openair2/PHY_INTERFACE/queue.c
openair2/PHY_INTERFACE/queue.c
+7
-1
openair2/PHY_INTERFACE/queue.h
openair2/PHY_INTERFACE/queue.h
+3
-2
openair2/PHY_INTERFACE/queue_test.c
openair2/PHY_INTERFACE/queue_test.c
+34
-9
No files found.
openair2/PHY_INTERFACE/phy_stub_UE.c
View file @
e39a04a0
...
...
@@ -1084,8 +1084,14 @@ int memcpy_dl_config_req(L1_rxtx_proc_t *proc,
req
->
sfn_sf
>>
4
,
req
->
sfn_sf
&
15
);
return
0
;
}
dlsch_pdu_indicies_t
wanted
=
{
num_dlsch_pdu_indicies
,
dlsch_pdu_indicies
};
nfapi_tx_req_pdu_list_t
*
matched
=
unqueue_matching
(
&
tx_req_pdu_queue
,
match_dl_config_req
,
&
wanted
);
dlsch_pdu_indicies_t
wanted
=
{
num_dlsch_pdu_indicies
,
dlsch_pdu_indicies
,
};
nfapi_tx_req_pdu_list_t
*
matched
=
unqueue_matching
(
&
tx_req_pdu_queue
,
/*max_depth=*/
2
,
match_dl_config_req
,
&
wanted
);
if
(
!
matched
)
{
LOG_W
(
MAC
,
"Could not unqueue_matching
\n
"
);
...
...
openair2/PHY_INTERFACE/queue.c
View file @
e39a04a0
...
...
@@ -113,7 +113,7 @@ void *unqueue(queue_t *q)
return
item
;
}
void
*
unqueue_matching
(
queue_t
*
q
,
queue_matcher_t
*
matcher
,
void
*
wanted
)
void
*
unqueue_matching
(
queue_t
*
q
,
size_t
max_depth
,
queue_matcher_t
*
matcher
,
void
*
wanted
)
{
if
(
pthread_mutex_lock
(
&
q
->
mutex
)
!=
0
)
{
...
...
@@ -125,6 +125,12 @@ void *unqueue_matching(queue_t *q, queue_matcher_t *matcher, void *wanted)
size_t
endi
=
q
->
write_index
;
for
(
size_t
i
=
0
;
i
<
q
->
num_items
;
i
++
)
{
if
(
max_depth
==
0
)
{
break
;
}
--
max_depth
;
endi
=
(
endi
+
MAX_QUEUE_SIZE
-
1
)
%
MAX_QUEUE_SIZE
;
void
*
candidate
=
q
->
items
[
endi
];
if
(
matcher
(
wanted
,
candidate
))
...
...
openair2/PHY_INTERFACE/queue.h
View file @
e39a04a0
...
...
@@ -55,7 +55,8 @@ void *unqueue(queue_t *q);
typedef
bool
queue_matcher_t
(
void
*
wanted
,
void
*
candidate
);
/* Unqueue the most recently queued item for w
at
ch `matcher(wanted, candidate)`
/* Unqueue the most recently queued item for w
hi
ch `matcher(wanted, candidate)`
returns true where `candidate` is an item currently on the queue.
Look only at the last `max_depth` items on the queue, at most.
Returns the candidate item, or NULL if none matches */
void
*
unqueue_matching
(
queue_t
*
q
,
queue_matcher_t
*
matcher
,
void
*
wanted
);
void
*
unqueue_matching
(
queue_t
*
q
,
size_t
max_depth
,
queue_matcher_t
*
matcher
,
void
*
wanted
);
openair2/PHY_INTERFACE/queue_test.c
View file @
e39a04a0
...
...
@@ -128,7 +128,7 @@ int main(void)
init_queue
(
&
queue
);
// empty queue
p
=
unqueue_matching
(
&
queue
,
matcher
,
&
thing1
);
p
=
unqueue_matching
(
&
queue
,
MAX_QUEUE_SIZE
,
matcher
,
&
thing1
);
EQUAL
(
p
,
NULL
);
EQUAL
(
queue
.
num_items
,
0
);
...
...
@@ -136,14 +136,39 @@ int main(void)
if
(
!
put_queue
(
&
queue
,
&
thing1
))
FAIL
;
EQUAL
(
queue
.
num_items
,
1
);
p
=
unqueue_matching
(
&
queue
,
matcher
,
&
thing2
);
p
=
unqueue_matching
(
&
queue
,
MAX_QUEUE_SIZE
,
matcher
,
&
thing2
);
EQUAL
(
p
,
NULL
);
EQUAL
(
queue
.
num_items
,
1
);
p
=
unqueue_matching
(
&
queue
,
matcher
,
&
thing1
);
p
=
unqueue_matching
(
&
queue
,
/*max_queue=*/
0
,
matcher
,
&
thing1
);
EQUAL
(
p
,
NULL
);
EQUAL
(
queue
.
num_items
,
1
);
p
=
unqueue_matching
(
&
queue
,
/*max_queue=*/
1
,
matcher
,
&
thing1
);
EQUAL
(
p
,
&
thing1
);
EQUAL
(
queue
.
num_items
,
0
);
// more max_queue values
for
(
int
i
=
0
;
i
<
MAX_QUEUE_SIZE
;
++
i
)
{
if
(
!
put_queue
(
&
queue
,
&
things
[
i
]))
{
FAIL
;
}
}
p
=
unqueue_matching
(
&
queue
,
/*max_queue=*/
0
,
matcher
,
&
things
[
MAX_QUEUE_SIZE
-
1
]);
EQUAL
(
p
,
NULL
);
p
=
unqueue_matching
(
&
queue
,
/*max_queue=*/
1
,
matcher
,
&
things
[
MAX_QUEUE_SIZE
-
1
]);
EQUAL
(
p
,
&
things
[
MAX_QUEUE_SIZE
-
1
]);
EQUAL
(
queue
.
num_items
,
MAX_QUEUE_SIZE
-
1
);
p
=
unqueue_matching
(
&
queue
,
/*max_queue=*/
MAX_QUEUE_SIZE
-
2
,
matcher
,
&
things
[
0
]);
EQUAL
(
p
,
NULL
);
p
=
unqueue_matching
(
&
queue
,
/*max_queue=*/
MAX_QUEUE_SIZE
-
1
,
matcher
,
&
things
[
0
]);
EQUAL
(
p
,
&
things
[
0
]);
EQUAL
(
queue
.
num_items
,
MAX_QUEUE_SIZE
-
2
);
// fill the queue then remove every other item
init_queue
(
&
queue
);
for
(
int
i
=
0
;
i
<
MAX_QUEUE_SIZE
;
++
i
)
{
if
(
!
put_queue
(
&
queue
,
&
things
[
i
]))
...
...
@@ -151,15 +176,15 @@ int main(void)
FAIL
;
}
}
p
=
unqueue_matching
(
&
queue
,
matcher
,
&
thing1
);
p
=
unqueue_matching
(
&
queue
,
MAX_QUEUE_SIZE
,
matcher
,
&
thing1
);
EQUAL
(
p
,
NULL
);
for
(
int
i
=
MAX_QUEUE_SIZE
-
1
;
i
>=
0
;
i
-=
2
)
{
p
=
unqueue_matching
(
&
queue
,
matcher
,
&
things
[
i
]);
p
=
unqueue_matching
(
&
queue
,
MAX_QUEUE_SIZE
,
matcher
,
&
things
[
i
]);
EQUAL
(
p
,
&
things
[
i
]);
}
EQUAL
(
queue
.
num_items
,
MAX_QUEUE_SIZE
/
2
);
p
=
unqueue_matching
(
&
queue
,
matcher
,
&
thing1
);
p
=
unqueue_matching
(
&
queue
,
MAX_QUEUE_SIZE
,
matcher
,
&
thing1
);
EQUAL
(
p
,
NULL
);
for
(
int
i
=
0
;
i
<
MAX_QUEUE_SIZE
;
i
+=
2
)
{
...
...
@@ -176,15 +201,15 @@ int main(void)
FAIL
;
}
}
p
=
unqueue_matching
(
&
queue
,
matcher
,
&
thing1
);
p
=
unqueue_matching
(
&
queue
,
MAX_QUEUE_SIZE
,
matcher
,
&
thing1
);
EQUAL
(
p
,
NULL
);
for
(
int
i
=
0
;
i
<
MAX_QUEUE_SIZE
;
i
+=
3
)
{
p
=
unqueue_matching
(
&
queue
,
matcher
,
&
things
[
i
]);
p
=
unqueue_matching
(
&
queue
,
MAX_QUEUE_SIZE
,
matcher
,
&
things
[
i
]);
EQUAL
(
p
,
&
things
[
i
]);
}
EQUAL
(
queue
.
num_items
,
MAX_QUEUE_SIZE
*
2
/
3
);
p
=
unqueue_matching
(
&
queue
,
matcher
,
&
thing1
);
p
=
unqueue_matching
(
&
queue
,
MAX_QUEUE_SIZE
,
matcher
,
&
thing1
);
EQUAL
(
p
,
NULL
);
for
(
int
i
=
0
;
i
<
MAX_QUEUE_SIZE
;
++
i
)
{
...
...
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