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.


Add lock to vmm_queue
Lei Xia [Mon, 15 Feb 2010 05:49:01 +0000 (23:49 -0600)]
palacios/include/palacios/vmm_queue.h
palacios/src/palacios/vmm_queue.c

index a4994f5..e88329f 100644 (file)
@@ -25,7 +25,7 @@
 
 #include <palacios/vmm.h>
 #include <palacios/vmm_list.h>
-
+#include <palacios/vmm_lock.h>
 
 
 /* IMPORTANT:
@@ -43,9 +43,7 @@ struct queue_entry {
 struct gen_queue {
     uint_t num_entries;
     struct list_head entries;
-
-    // We really need to implement this....
-    // void * lock;
+    v3_lock_t lock;
 };
 
 
index 2e1f72f..b06ff73 100644 (file)
@@ -22,9 +22,9 @@
 void v3_init_queue(struct gen_queue * queue) {
     queue->num_entries = 0;
     INIT_LIST_HEAD(&(queue->entries));
+    v3_lock_init(&queue->lock);
 }
 
-
 struct gen_queue * v3_create_queue() {
     struct gen_queue * tmp_queue = V3_Malloc(sizeof(struct gen_queue));
     v3_init_queue(tmp_queue);
@@ -34,15 +34,18 @@ struct gen_queue * v3_create_queue() {
 void v3_enqueue(struct gen_queue * queue, addr_t entry) {
     struct queue_entry * q_entry = V3_Malloc(sizeof(struct queue_entry));
 
+    v3_lock(queue->lock);
     q_entry->entry = entry;
     list_add_tail(&(q_entry->entry_list), &(queue->entries));
     queue->num_entries++;
+    v3_unlock(queue->lock);
 }
 
 
 addr_t v3_dequeue(struct gen_queue * queue) {
     addr_t entry_val = 0;
 
+    v3_lock(queue->lock);
     if (!list_empty(&(queue->entries))) {
        struct list_head * q_entry = queue->entries.next;
        struct queue_entry * tmp_entry = list_entry(q_entry, struct queue_entry, entry_list);
@@ -51,6 +54,7 @@ addr_t v3_dequeue(struct gen_queue * queue) {
        list_del(q_entry);
        V3_Free(tmp_entry);
     }
+    v3_unlock(queue->lock);
 
     return entry_val;
 }