[commtech] CSQ use memcpy in dequeue for fairness
Paper about CSQ uses memcpy in enqueue and dequeue. Although it is not possible to use memcpy in enqueue because of current API, it is possible to use memcpy in dequeue, hence this commit.
This commit is contained in:
parent
7db514a706
commit
5eb7fb50c7
|
@ -1,5 +1,6 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
@ -89,21 +90,16 @@ void *recv_one_data(void)
|
||||||
|
|
||||||
ssize_t recv_some_data(void **buf, size_t count)
|
ssize_t recv_some_data(void **buf, size_t count)
|
||||||
{
|
{
|
||||||
int i, n;
|
int n;
|
||||||
|
|
||||||
n = 0;
|
n = 0;
|
||||||
// If all slots are empty, spin
|
// If all slots are empty, spin
|
||||||
while (comm->queue[ctrl.head].flag)
|
while (comm->queue[ctrl.head].flag)
|
||||||
{
|
{
|
||||||
// Dequeue a chunk of data items
|
// Dequeue a chunk of data items
|
||||||
for (i = 0; i < SUB_SLOTS; i++)
|
memcpy(buf, (const void *)
|
||||||
{
|
comm->queue[ctrl.head].chunk,
|
||||||
/*
|
SUB_SLOTS * sizeof(*buf));
|
||||||
* The behaviour of this is not documented but we know
|
|
||||||
* the values inside buf won't change during this affectation
|
|
||||||
*/
|
|
||||||
*buf++ = comm->queue[ctrl.head].chunk[i];
|
|
||||||
}
|
|
||||||
n += SUB_SLOTS;
|
n += SUB_SLOTS;
|
||||||
comm->queue[ctrl.head].flag = 0;
|
comm->queue[ctrl.head].flag = 0;
|
||||||
ctrl.head = (ctrl.head + 1) % SLOTS;
|
ctrl.head = (ctrl.head + 1) % SLOTS;
|
||||||
|
|
Loading…
Reference in New Issue