On 06/15/2012 08:46 AM, Sven Barth wrote:

The Linux unit already contains Futex functions that directly call the kernel (since around two years already).

I did not check the RTL source code. But it needs to be noted that the term "call Futex" is rather unclear.

There is a Kernel function "FUTEX" that helps to implement a Futex ("Fast Userspace MUTEX") based Semaphore.

But the idea with FUTEX is in by far most cases _not_ to all this kernel function, but to handle the Semaphore completely in Userspace, if not taken. The userspace code related to Futex is very critical ASM stuff and not easy to do. (See "FUTEXES are tricky" by Ulrich Drepper http://people.redhat.com/drepper/futex.pdf ) So providing a wrapper for the Futex Kernel call does not help at all).

For C, the userspace code is done in the pthread library. (In fact, pthread_mutex_..() uses the Futex mechanism if the architecture in fact does provide the appropriate CPU instructions and the Kernel provides the related kernel call - which of course is for X86 / X86/64 and modern Linux - , otherwise it just uses the appropriate Kernel Space MUTEX call.).

What I meant is that the RTL should implement e.g. TCriticalSection (and whatever might be used to provide multi-thread libraries and/or language extensions) using the FUTEX mechanism without needing the pthread libc library. (Maybe this already is done.)

-Michael
_______________________________________________
fpc-devel maillist  -  [email protected]
http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply via email to