Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 09 Jun 2015 16:04:40 -0700
From:      "Russell L. Carter" <rcarter@pinyon.org>
To:        freebsd-hackers@freebsd.org
Subject:   umtx_lock and friends
Message-ID:  <55777108.5020206@pinyon.org>

next in thread | raw e-mail | index | archive | help
Hi,

I'm investigating what the most lightweight inter-process mutex
technique on FreeBSD and have been looking at the
infrastructure in /usr/include/sys/umtx.h

However, my simple test program fails to link:

#include <stdio.h>
#include <sys/types.h>
#include <machine/atomic.h>
#include <errno.h>
#include <sys/umtx.h>

int main(int, char **)
{
     printf("Testing...");
     struct umtx m;
     umtx_init(&m);
     u_long id=5;
     umtx_lock(&m, id);
     umtx_unlock(&m, id);
     printf("Test done.");
     return 0;
}

produces the following:

tester.cpp:(.text+0x36): undefined reference to `_umtx_lock(umtx*)'
tester.cpp:(.text+0x5f): undefined reference to `_umtx_unlock(umtx*)'

I've tried linking against a variety of suspects in /usr/lib but
no luck.

go-lang uses _umtx_op but they make the syscall directly via asm,
it seems.

I can build an inter-process mutex over semaphores but the umtx
stuff looks perfect if I can get it to work.

Thanks,
Russell



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?55777108.5020206>