Esempio n. 1
0
//Runs all the commands in the queue
void wait_queue() {
    //printf("wait_queue\n");
    //implement some type of blocking mechanism that runs all commands
    while (MKQ->running != NULL && MKQ->q != NULL) {
        qcommand_t *last = MKQ->running;
        while (last->next)
            last = last->next;
        waitpid(last->pid, NULL, 0);
        kick_queue();
    }
    
}
Esempio n. 2
0
//Adds a command to the queue
int add_command(qcommand_t *to_q) {
    if (to_q == NULL || MKQ == NULL) // return if either are null
        return 1;
        
    if (MKQ->q == NULL) {// if the q is null
        to_q->next = NULL;
        MKQ->q = to_q; // make to_q the head
    } else { //else
        qcommand_t *itr; //add it to the end of the q
        for (itr = MKQ->q; itr != NULL; itr = itr->next)
            if (itr->next == NULL)
                itr->next= to_q;
    }
    kick_queue();
    return 0;
}
Esempio n. 3
0
int
virtio_to_queue(struct virtio_device *dev, int qidx, struct vumap_phys *bufs,
	size_t num, void *data)
{
	u16_t free_first;
	int left;
	struct virtio_queue *q = &dev->queues[qidx];
	struct vring *vring = &q->vring;

	assert(0 <= qidx && qidx <= dev->num_queues);

	if (!data)
		panic("%s: NULL data received queue %d", dev->name, qidx);

	free_first = q->free_head;

	left = (int)q->free_num - (int)num;

	if (left < dev->threads)
		set_indirect_descriptors(dev, q, bufs, num);
	else
		set_direct_descriptors(q, bufs, num);

	/* Next index for host is old free_head */
	vring->avail->ring[vring->avail->idx % q->num] = free_first;

	/* Provided by the caller to identify this slot */
	q->data[free_first] = data;

	/* Make sure the host sees the new descriptors */
	__insn_barrier();

	/* advance last idx */
	vring->avail->idx += 1;

	/* Make sure the host sees the avail->idx */
	__insn_barrier();

	/* kick it! */
	kick_queue(dev, qidx);
	return 0;
}