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) 2015, Peter Dinda <pdinda@northwestern.edu>
11 * Copyright (c) 2015, The V3VEE Project <http://www.v3vee.org>
12 * All rights reserved.
14 * Author: Peter Dinda <pdinda@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 #ifndef __VMM_SUBSET_H__
21 #define __VMM_SUBSET_H__
25 #include <palacios/vmm_types.h>
29 typedef struct v3_counting_barrier {
30 // number of threads that must arrive at the barrier
31 // note that this can only be set when there is no barreir in progress
35 } v3_counting_barrier_t;
38 static inline void v3_init_counting_barrier(v3_counting_barrier_t *b, uint64_t size)
40 b->size=size; b->count[0]=b->count[1]=0; b->cur=0;
43 static inline void v3_counting_barrier(volatile v3_counting_barrier_t *b)
46 volatile uint64_t *curp = &(b->cur);
48 volatile uint64_t *countp = &(b->count[mycur]);
50 old = __sync_fetch_and_add(countp,1);
52 if (old==(b->size-1)) {
53 // I'm the last to the party
57 // k1om compiler does not know what "volatile" means
58 // hence this hand-coding.
60 __asm__ __volatile__( "movq %1, %0" : "=r"(old) : "m"(*countp) : );