Skip to content

Commit 89d2401

Browse files
committed
Remove conditional variable
1 parent 6458b71 commit 89d2401

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

virtio-snd.c

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -274,8 +274,6 @@ typedef struct {
274274
static vsnd_stream_sel_t v;
275275

276276
static pthread_mutex_t virtio_snd_mutex = PTHREAD_MUTEX_INITIALIZER;
277-
static pthread_cond_t virtio_snd_cond = PTHREAD_COND_INITIALIZER;
278-
static uint8_t is_txing;
279277

280278
/* Forward declaration */
281279
static void virtio_snd_cb(struct CNFADriver *dev,
@@ -700,13 +698,6 @@ static int virtio_snd_tx_desc_handler(virtio_snd_state_t *vsnd,
700698
/* Start of critical section */
701699
pthread_mutex_lock(&virtio_snd_mutex);
702700

703-
/* Wait until the TX queue event is ready. */
704-
while (is_txing <= 0)
705-
pthread_cond_wait(&virtio_snd_cond, &virtio_snd_mutex);
706-
707-
/* Consume event count */
708-
is_txing--;
709-
710701
/* TODO: clarify the usage of the last descriptor. */
711702
/* virtio-snd TX uses arbitrary number of virtqueue descriptors.
712703
* The first descritor descriptor contains:
@@ -799,6 +790,8 @@ static int virtio_snd_tx_desc_handler(virtio_snd_state_t *vsnd,
799790
/* End of critical seciont. */
800791
pthread_mutex_unlock(&virtio_snd_mutex);
801792

793+
sleep(1);
794+
802795
return 0;
803796
}
804797

@@ -859,6 +852,8 @@ static void virtio_queue_notify_handler(
859852
ram[vq_used_addr + 1] = len; /* virtq_used_elem.len (le32) */
860853
queue->last_avail++;
861854
new_used++;
855+
856+
printf("last_avail %d new_avail %d\n", queue->last_avail, new_avail);
862857
}
863858

864859
/* Check le32 len field of struct virtq_used_elem on the spec */
@@ -982,8 +977,6 @@ static bool virtio_snd_reg_write(virtio_snd_state_t *vsnd,
982977
break;
983978
case VSND_QUEUE_TX:
984979
fprintf(stderr, "TX start\n");
985-
is_txing++;
986-
pthread_cond_signal(&virtio_snd_cond);
987980
virtio_queue_notify_handler(vsnd, value,
988981
virtio_snd_tx_desc_handler);
989982
fprintf(stderr, "TX end\n");

0 commit comments

Comments
 (0)