Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Mac OS] Thread Mutexes non-recursive? #228

Open
GWRon opened this issue Mar 24, 2022 · 0 comments
Open

[Mac OS] Thread Mutexes non-recursive? #228

GWRon opened this issue Mar 24, 2022 · 0 comments

Comments

@GWRon
Copy link
Contributor

GWRon commented Mar 24, 2022

While looking in the sources I also saw this in blitz.mod/blitz_thread.c:

blitz.mod/blitz_thread.c defines different types for mutexes along linux, mac, haiku ...
#if __linux
#define MUTEX_RECURSIVE 1
#elif __APPLE__
#define MUTEX_RECURSIVE 2
#elif __SWITCH__
#define MUTEX_RECURSIVE 1
#elif __HAIKU__
#define MUTEX_RECURSIVE 3
#endif

which is used as param for pthread_mutexattr_settype : https://linux.die.net/man/3/pthread_mutexattr_settype

The enum is defined this way:

/* Mutex types.  */
enum
{
  PTHREAD_MUTEX_TIMED_NP,
  PTHREAD_MUTEX_RECURSIVE_NP,
  PTHREAD_MUTEX_ERRORCHECK_NP,
  PTHREAD_MUTEX_ADAPTIVE_NP

So for Mac OS it uses ERRORCHECK while Linux uses RECURSIVE.

Does it mean that on Mac OS you cant recursively lock the same Mutex (from the same thread)?
@HurryStarfish am not sure if it was you on Discord but somone told me that one should be able to do recursive mutex locks in BlitzMax ... so I am now asking if this really is the case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant