Futex alternatives.

185 views
Skip to first unread message

Pascal

unread,
Jul 13, 2018, 4:55:25 PM7/13/18
to Darwi...@lists.apple.com, Dmitry A. Kazakov
Hello,

In a library code source coming from Linux, I've got the following error on macOS 10.13:
simple_components/os/linux/synchronization_linux.c:29:10: fatal error: linux/futex.h: No such file or directory
#include <linux/futex.h>

I can't found any futex.h in /usr/include.

Is there macOS or Darwin alternatives to Futex?

Thanks, Pascal.
http://blady.pagesperso-orange.fr


_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (Darwi...@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/darwin-dev/darwin-dev-garchive-73044%40googlegroups.com

This email sent to darwin-dev-g...@googlegroups.com

Richard Schmitt

unread,
Jul 14, 2018, 9:01:34 AM7/14/18
to Pascal, Darwi...@lists.apple.com, Dmitry A. Kazakov
Yes and no. 

futex is a user-mode implementation of a mutex (i.e. locking).  Darwin doesn’t have a futex but it’s got ways to provide the locking.  It would require you to modify the original source though (or you can provide your own wrappers to the futex calls for Darwin).  


Rich

On Jul 13, 2018, at 3:55 PM, Pascal <sur.p...@wanadoo.fr> wrote:

Hello,

In a library code source coming from Linux, I've got the following error on macOS 10.13:
simple_components/os/linux/synchronization_linux.c:29:10: fatal error: linux/futex.h: No such file or directory
#include <linux/futex.h>

I can't found any futex.h in /usr/include.

Is there macOS or Darwin alternatives to Futex?

Thanks, Pascal.
http://blady.pagesperso-orange.fr


_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list      (Darwi...@lists.apple.com)
Help/Unsubscribe/Update your Subscription:

Jens Alfke

unread,
Jul 16, 2018, 12:43:30 PM7/16/18
to Richard Schmitt, Darwi...@lists.apple.com, Pascal, Dmitry A. Kazakov


On Jul 14, 2018, at 6:01 AM, Richard Schmitt <rsch...@bluepeach.com> wrote:

futex is a user-mode implementation of a mutex (i.e. locking).  Darwin doesn’t have a futex but it’s got ways to provide the locking. 

From the blog post you linked to, it sounds like Darwin’s pthread_mutex is essentially a futex, i.e. it doesn’t enter the kernel unless there’s contention:

In MacOS 10.6.6, a lock implementation is provided using the POSIX Threads API. It’s a lightweight mutex which doesn’t enter the kernel unless there’s contention.

—Jens

Reply all
Reply to author
Forward
0 new messages