Palacios Public Git Repository

To checkout Palacios execute

  git clone http://v3vee.org/palacios/palacios.web/palacios.git
This will give you the master branch. You probably want the devel branch or one of the release branches. To switch to the devel branch, simply execute
  cd palacios
  git checkout --track -b devel origin/devel
The other branches are similar.


cd06790de68721178040cd31529828f3726f6dc9
[palacios.releases.git] / palacios / src / palacios / vmm_queue.c
1 /* (c) 2008, Jack Lange <jarusl@cs.northwestern.edu> */
2 /* (c) 2008, The V3VEE Project <http://www.v3vee.org> */
3
4
5 #include <palacios/vmm_queue.h>
6
7
8
9 void v3_init_queue(struct gen_queue * queue) {
10   queue->num_entries = 0;
11   INIT_LIST_HEAD(&(queue->entries));
12 }
13
14
15 struct gen_queue * v3_create_queue() {
16   struct gen_queue * tmp_queue = V3_Malloc(sizeof(struct gen_queue));
17   v3_init_queue(tmp_queue);
18   return tmp_queue;
19 }
20
21 void v3_enqueue(struct gen_queue * queue, addr_t entry) {
22   struct queue_entry * q_entry = V3_Malloc(sizeof(struct queue_entry));
23
24   q_entry->entry = entry;
25   list_add_tail(&(q_entry->entry_list), &(queue->entries));
26   queue->num_entries++;
27 }
28
29
30 addr_t v3_dequeue(struct gen_queue * queue) {
31   addr_t entry_val = 0;
32
33   if (!list_empty(&(queue->entries))) {
34     struct list_head * q_entry = queue->entries.next;
35     struct queue_entry * tmp_entry = list_entry(q_entry, struct queue_entry, entry_list);
36
37     entry_val = tmp_entry->entry;
38     list_del(q_entry);
39     V3_Free(tmp_entry);
40   }
41
42   return entry_val;
43 }