2001-03-15  Ulrich Drepper  <drepper@redhat.com>

	* Versions [libpthread] (GLIBC_2.2.3): Add pthread_getattr_np.
	* attr.c: Implement pthread_getattr_np.
	* sysdeps/pthread/pthread.h: Add prototype for pthread_getattr_np.
	* internals.h (struct _pthread_descr_struct): Add p_inheritsched.
	* manager.c (pthread_handle_create): Initialize p_inheritsched.

	* sysdeps/unix/sysv/linux/s390/pt-initfini.c: Use 0x07 padding for
This commit is contained in:
Ulrich Drepper 2001-03-15 21:13:12 +00:00
parent 821a6bb436
commit 3bf927cbce
6 changed files with 62 additions and 1 deletions

View File

@ -1,3 +1,11 @@
2001-03-15 Ulrich Drepper <drepper@redhat.com>
* Versions [libpthread] (GLIBC_2.2.3): Add pthread_getattr_np.
* attr.c: Implement pthread_getattr_np.
* sysdeps/pthread/pthread.h: Add prototype for pthread_getattr_np.
* internals.h (struct _pthread_descr_struct): Add p_inheritsched.
* manager.c (pthread_handle_create): Initialize p_inheritsched.
2001-03-09 Martin Schwidefsky <schwidefsky@de.ibm.com>
* sysdeps/unix/sysv/linux/s390/pt-initfini.c: Use 0x07 padding for

View File

@ -152,4 +152,8 @@ libpthread {
# Extensions.
pthread_yield;
}
GLIBC_2.2.3 {
# Extensions.
pthread_getattr_np;
}
}

View File

@ -267,3 +267,45 @@ int __pthread_attr_getstack (const pthread_attr_t *attr, void **stackaddr,
return 0;
}
weak_alias (__pthread_attr_getstack, pthread_attr_getstack)
int pthread_getattr_np (pthread_t thread, pthread_attr_t *attr)
{
pthread_handle handle = thread_handle (thread);
pthread_descr descr;
char *guardaddr;
if (handle == NULL)
return ENOENT;
descr = handle->h_descr;
attr->__detachstate = (descr->p_detached
? PTHREAD_CREATE_DETACHED
: PTHREAD_CREATE_JOINABLE);
attr->__schedpolicy = __sched_getscheduler (descr->p_pid);
if (attr->__schedpolicy == -1)
return errno;
if (__sched_getparam (descr->p_pid,
(struct sched_param *) &attr->__schedparam) != 0)
return errno;
guardaddr = descr->p_guardaddr;
attr->__inheritsched = descr->p_inheritsched;
attr->__scope = PTHREAD_SCOPE_SYSTEM;
attr->__stacksize = (char *)(descr + 1) - guardaddr - descr->p_guardsize;
attr->__guardsize = descr->p_guardsize;
attr->__stackaddr_set = descr->p_userstack;
#ifdef NEED_SEPARATE_REGISTER_STACK
guardaddr -= attr->__stacksize;
attr->__stacksize *= 2;
/* XXX This is awkward. The guard pages are in the middle of the
two stacks. We must count the guard size in the stack size since
otherwise the range of the stack area cannot be computed. */
attr->__stacksize += attr->guardsize;
#endif
attr->__stackaddr = guardaddr;
return 0;
}

View File

@ -178,6 +178,7 @@ struct _pthread_descr_struct {
int p_untracked_readlock_count; /* Readlocks not tracked by list */
struct __res_state *p_resp; /* Pointer to resolver state */
struct __res_state p_res; /* per-thread resolver state */
int p_inheritsched; /* copied from the thread attribute */
/* New elements must be added at the end. */
} __attribute__ ((aligned(32))); /* We need to align the structure so that
doubles are aligned properly. This is 8

View File

@ -512,6 +512,7 @@ static int pthread_handle_create(pthread_t *thread, const pthread_attr_t *attr,
new_thread->p_guardsize = guardsize;
new_thread->p_header.data.self = new_thread;
new_thread->p_nr = sseg;
new_thread->p_inheritsched = attr ? attr->__inheritsched : 0;
/* Initialize the thread handle */
__pthread_init_lock(&__pthread_handles[sseg].h_lock);
__pthread_handles[sseg].h_descr = new_thread;

View File

@ -289,6 +289,11 @@ extern int pthread_attr_getstacksize (__const pthread_attr_t *__restrict
__attr, size_t *__restrict __stacksize)
__THROW;
#ifdef __USE_GNU
/* Get thread attributes corresponding to the already running thread TH. */
extern int pthread_getattr_np (pthread_t __th, pthread_attr_t *__attr) __THROW;
#endif
/* Functions for scheduling control. */
/* Set the scheduling parameters for TARGET_THREAD according to POLICY