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.


initial simulation functionality
[palacios.git] / palacios / src / palacios / vmm_barrier.c
index f7b863d..f887a05 100644 (file)
@@ -41,28 +41,14 @@ int v3_deinit_barrier(struct v3_vm_info * vm_info) {
     return 0;
 }
 
-
-/* Barrier synchronization primitive
- *   -- This call will block until all the guest cores are waiting at a common synchronization point
- *      in a yield loop. The core will block at the sync point until the barrier is lowered.
- * 
- *   ARGUMENTS: 
- *       vm_info -- The VM for which the barrier is being activated
- *       local_core -- The core whose thread this function is being called from, or NULL 
- *                     if the calling thread is not associated with a VM's core context
- */
-
-int v3_raise_barrier(struct v3_vm_info * vm_info, struct guest_info * local_core) {
+int v3_raise_barrier_nowait(struct v3_vm_info * vm_info, struct guest_info * local_core) {
     struct v3_barrier * barrier = &(vm_info->barrier);
     addr_t flag;
     int acquired = 0;
-    int all_blocked = 0;
 
     int local_vcpu = -1;
     int i = 0;
 
-
-
     flag = v3_lock_irqsave(barrier->lock);
 
     if (barrier->active == 0) {
@@ -99,6 +85,14 @@ int v3_raise_barrier(struct v3_vm_info * vm_info, struct guest_info * local_core
        }
     }
 
+    return 0;
+}
+
+int v3_wait_for_barrier(struct v3_vm_info * vm_info, struct guest_info * local_core) {
+    struct v3_barrier * barrier = &(vm_info->barrier);
+    int all_blocked = 0;
+    int i = 0;
+
     // wait for barrier catch on all cores
     while (all_blocked == 0) {
        all_blocked = 1;
@@ -125,12 +119,35 @@ int v3_raise_barrier(struct v3_vm_info * vm_info, struct guest_info * local_core
        v3_yield(local_core);
     }
 
-
     return 0;
 }
 
 
 
+/* Barrier synchronization primitive
+ *   -- This call will block until all the guest cores are waiting at a common synchronization point
+ *      in a yield loop. The core will block at the sync point until the barrier is lowered.
+ * 
+ *   ARGUMENTS: 
+ *       vm_info -- The VM for which the barrier is being activated
+ *       local_core -- The core whose thread this function is being called from, or NULL 
+ *                     if the calling thread is not associated with a VM's core context
+ */
+
+int v3_raise_barrier(struct v3_vm_info * vm_info, struct guest_info * local_core) {
+    int ret = 0;
+
+    ret = v3_raise_barrier_nowait(vm_info, local_core);
+
+    if (ret != 0) {
+       return ret;
+    }
+
+    return v3_wait_for_barrier(vm_info, local_core);
+}
+
+
+
 /* Lowers a barrier that has already been raised
  *    guest cores will automatically resume execution 
  *    once this has been called