1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-07-28 00:21:52 +03:00

New API to set default thread attributes

This patch introduces two new convenience functions to set the default
thread attributes used for creating threads.  This allows a programmer
to set the default thread attributes just once in a process and then
run pthread_create without additional attributes.
This commit is contained in:
Siddhesh Poyarekar
2013-06-15 12:24:15 +05:30
parent 601eb33deb
commit 61dd6208fb
49 changed files with 817 additions and 13 deletions

View File

@ -358,7 +358,14 @@ allocate_stack (const struct pthread_attr *attr, struct pthread **pdp,
/* Get the stack size from the attribute if it is set. Otherwise we
use the default we determined at start time. */
size = attr->stacksize ?: __default_pthread_attr.stacksize;
if (attr->stacksize != 0)
size = attr->stacksize;
else
{
lll_lock (__default_pthread_attr_lock, LLL_PRIVATE);
size = __default_pthread_attr.stacksize;
lll_unlock (__default_pthread_attr_lock, LLL_PRIVATE);
}
/* Get memory for the stack. */
if (__builtin_expect (attr->flags & ATTR_FLAG_STACKADDR, 0))
@ -919,8 +926,9 @@ __reclaim_stacks (void)
in_flight_stack = 0;
/* Initialize the lock. */
/* Initialize locks. */
stack_cache_lock = LLL_LOCK_INITIALIZER;
__default_pthread_attr_lock = LLL_LOCK_INITIALIZER;
}