Commit c45f5cb2 authored by Filippos Giannakos's avatar Filippos Giannakos

xseg: Replace flag-based segment lock with an xlock

parent afcbeeac
......@@ -34,6 +34,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <sys/time.h>
#include <xseg/version.h>
#include <xseg/util.h>
#include <xseg/xlock.h>
#include <xseg/xq.h>
#include <xseg/xobj.h>
#include <xseg/xhash.h>
......@@ -269,6 +270,7 @@ struct xseg_shared {
char (*peer_types)[XSEG_TNAMESIZE]; /* alignment? */
xptr *peer_type_data;
uint32_t nr_peer_types;
struct xlock segment_lock;
};
struct xseg_private {
......
......@@ -41,16 +41,12 @@ static int xseg_join_ref;
static void __lock_segment(struct xseg *xseg)
{
volatile uint64_t *flags;
flags = &xseg->shared->flags;
while (__sync_fetch_and_or(flags, XSEG_F_LOCK));
xlock_acquire(&xseg->shared->segment_lock);
}
static void __unlock_segment(struct xseg *xseg)
{
volatile uint64_t *flags;
flags = &xseg->shared->flags;
__sync_fetch_and_and(flags, ~XSEG_F_LOCK);
xlock_release(&xseg->shared->segment_lock);
}
static struct xseg_type *__find_type(const char *name, long *index)
......@@ -660,6 +656,7 @@ static long initialize_segment(struct xseg *xseg, struct xseg_config *cfg)
shared = (struct xseg_shared *) mem;
shared->flags = 0;
shared->nr_peer_types = 0;
xlock_release(&shared->segment_lock);
xseg->shared = (struct xseg_shared *) XPTR_MAKE(mem, segment);
mem = xheap_allocate(heap, page_size);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment