From owner-freebsd-hackers@FreeBSD.ORG Tue Jun 9 23:13:55 2015 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 1DDF9D3B for ; Tue, 9 Jun 2015 23:13:55 +0000 (UTC) (envelope-from rcarter@pinyon.org) Received: from quine.pinyon.org (quine.pinyon.org [65.101.5.249]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id EEB8C13B6 for ; Tue, 9 Jun 2015 23:13:54 +0000 (UTC) (envelope-from rcarter@pinyon.org) Received: by quine.pinyon.org (Postfix, from userid 122) id 35A9E1602CD; Tue, 9 Jun 2015 16:04:43 -0700 (MST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on quine.pinyon.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00 autolearn=ham autolearn_force=no version=3.4.0 Received: from feyerabend.n1.pinyon.org (feyerabend.n1.pinyon.org [10.0.10.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by quine.pinyon.org (Postfix) with ESMTPSA id 94976160166 for ; Tue, 9 Jun 2015 16:04:40 -0700 (MST) Message-ID: <55777108.5020206@pinyon.org> Date: Tue, 09 Jun 2015 16:04:40 -0700 From: "Russell L. Carter" User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: freebsd-hackers@freebsd.org Subject: umtx_lock and friends Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 09 Jun 2015 23:13:55 -0000 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 #include #include #include #include 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