2 * This file is part of the Palacios Virtual Machine Monitor developed
3 * by the V3VEE Project with funding from the United States National
4 * Science Foundation and the Department of Energy.
6 * The V3VEE Project is a joint project between Northwestern University
7 * and the University of New Mexico. You can find out more at
10 * Copyright (c) 2008, Jack Lange <jarusl@cs.northwestern.edu>
11 * Copyright (c) 2008, The V3VEE Project <http://www.v3vee.org>
12 * All rights reserved.
14 * Author: Jack Lange <jarusl@cs.northwestern.edu>
16 * This is free software. You are permitted to use,
17 * redistribute, and modify it as specified in the file "V3VEE_LICENSE".
20 #include <palacios/vmm_queue.h>
22 void v3_init_queue(struct v3_queue * queue) {
23 queue->num_entries = 0;
24 INIT_LIST_HEAD(&(queue->entries));
25 v3_lock_init(&queue->lock);
28 struct v3_queue * v3_create_queue() {
29 struct v3_queue * tmp_queue = V3_Malloc(sizeof(struct v3_queue));
30 v3_init_queue(tmp_queue);
34 void v3_enqueue(struct v3_queue * queue, addr_t entry) {
35 struct v3_queue_entry * q_entry = V3_Malloc(sizeof(struct v3_queue_entry));
36 unsigned int flags = 0;
38 flags = v3_lock_irqsave(queue->lock);
39 q_entry->entry = entry;
40 list_add_tail(&(q_entry->entry_list), &(queue->entries));
42 v3_unlock_irqrestore(queue->lock, flags);
46 addr_t v3_dequeue(struct v3_queue * queue) {
48 unsigned int flags = 0;
50 flags = v3_lock_irqsave(queue->lock);
51 if (!list_empty(&(queue->entries))) {
52 struct list_head * q_entry = queue->entries.next;
53 struct v3_queue_entry * tmp_entry = list_entry(q_entry, struct v3_queue_entry, entry_list);
55 entry_val = tmp_entry->entry;
59 v3_unlock_irqrestore(queue->lock, flags);