diff --git a/en_US.ISO8859-1/htdocs/news/status/report-2016-01-2016-03.xml b/en_US.ISO8859-1/htdocs/news/status/report-2016-01-2016-03.xml index d3d0671726..1c3aebd607 100644 --- a/en_US.ISO8859-1/htdocs/news/status/report-2016-01-2016-03.xml +++ b/en_US.ISO8859-1/htdocs/news/status/report-2016-01-2016-03.xml @@ -748,4 +748,89 @@ + + + Process-Shared locks for libthr + + + + + Konstantin + Belousov + + + kib@FreeBSD.org + + + + +

POSIX specifies several kinds of pthread locks, for this + report the private and process-shared variants are considered. + Private locks can be used only by the threads of the same + process, which share the address space. Process-shared locks + can be used by threads from any process, assuming the process + can map the lock memory into its address space.

+ +

Our libthr, the library implementing the POSIX threads and + locking operations, uses a pointer as the internal + representation behind a lock. The pointer contains the + address of the actual structure carrying the lock. This has + unfortunate consequences for implementing the + PTHREAD_PROCESS_SHARED attribute for locks, since + really only the pointer is shared when the lock is mapped into + distinct address spaces.

+ +

A common opinion was that we have no choice but to break the + libthr Application Binary Interface (ABI) by changing the lock + types to be the actual lock structures (and padding for future + ABI extension). This is very painful for users, as our + previous experience with non-versioned libc and libc_r + shown.

+ +

Instead, I proposed and implemented a scheme where + process-shared locks can be implemented without breaking the + ABI. The lock memory is used as a key into the system-global + hash of the shared memory objects (off-pages), which carry the + real lock structures.

+ +

New umtx operations to create or look up the shared object, + by the memory key, were added. Libthr is modified to lookup + the object and use it for shared locks, instead of using + malloc() as for private locks.

+ +

The pointer value in the user-visible lock type contains a + canary for shared locks. Libthr detects the canary and + switches into the shared-lock mode.

+ +

The proposal of inlining the lock structures, besides the + drawbacks of breaking ABI, has its merits. Most important, + the inlining avoids the need of indirection. Another + important advantage over the off-page page approach is that no + off-page object needs to be maintained, and the lifecycle of + the shared lock naturally finishes with the destruction of the + shared memory, without explicit cleanup. Right now, off-pages + hook into vm object termination to avoid leakage, but long + liviness of the vnode vm object prolonges the off-page + existence for shared locks backed by files, however unlikely + they may be.

+ +

Libthr with inlined locks become informally known as libthr2 + project, since the library name better be changed instead of + only bumping the library version. The rtld should ensure that + libthr and libthr2 do not become simultaneously loaded into a + single address space.

+ + + The FreeBSD Foundation + + + +

Implement robust mutexes.

+
+ + +

Evaluate and implement libthr2.

+
+
+