pthread.c revision 9acbbeaf2a1ffe5c14b244867d427714fab43c5c
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include "lint.h"
#include "thr_uberdata.h"
/*
* pthread_once related data
* This structure is exported as pthread_once_t in pthread.h.
* We export only the size of this structure. so check
* pthread_once_t in pthread.h before making a change here.
*/
typedef struct __once {
union {
} oflag;
} __once_t;
/*
* pthread_create: creates a thread in the current process.
* calls common _thrp_create() after copying the attributes.
*/
int
void * (*start_routine)(void *), void *arg)
{
long flag;
int policy;
int error;
int mapped = 0;
int mappedpri;
int rt = 0;
return (EINVAL);
} else {
if (policy == SCHED_OTHER) {
if (priority < THREAD_MIN_PRIORITY ||
return (EINVAL);
mapped = 1;
}
return (EINVAL);
if (_private_geteuid() == 0)
rt = 1;
} else {
return (EINVAL);
}
}
if (error == 0) {
int prio_err;
if (mapped) {
}
return (prio_err);
if (thread)
(void) _thr_continue(tid);
}
/* posix version expects EAGAIN for lack of memory */
return (error);
}
/*
* pthread_once: calls given function only once.
* it synchronizes via mutex in pthread_once_t structure
*/
int
{
return (EINVAL);
(*init_routine)();
}
}
return (0);
}
/*
* pthread_equal: equates two thread ids.
*/
int
{
}
/*
* pthread_getschedparam: gets the sched parameters in a struct.
*/
int
{
int error = 0;
else {
if (ulwp->ul_pri_mapped)
else
}
return (error);
}
/*
* Besides the obvious arguments, the inheritflag needs to be explained:
* If set to PRIO_SET or PRIO_SET_PRIO, it does the normal, expected work
* of setting thread's assigned scheduling parameters and policy.
* If set to PRIO_INHERIT, it sets the thread's effective priority values
* (t_epri, t_empappedpri), and does not update the assigned priority values
* (t_pri, t_mappedpri). If set to PRIO_DISINHERIT, it clears the thread's
* effective priority values, and reverts the thread, if necessary, back
* to the assigned priority values.
*/
int
{
int error = 0;
int prio;
int opolicy;
int mappedprio;
int mapped = 0;
return (EINVAL);
return (ESRCH);
}
if (inheritflag == PRIO_DISINHERIT) {
ulwp->ul_emappedpri = 0;
}
if (policy == SCHED_OTHER) {
/*
* Set thread's policy to OTHER
*/
goto out;
}
mapped = 1;
mappedprio = prio;
prio <= THREAD_MAX_PRIORITY);
}
/*
*/
goto out;
}
if (inheritflag != PRIO_DISINHERIT) {
if (inheritflag == PRIO_INHERIT)
else
if (mapped) {
*mappedprip = mappedprio;
} else {
ulwp->ul_pri_mapped = 0;
*mappedprip = 0;
}
}
if (inheritflag == PRIO_INHERIT)
else
else {
int prio_err;
if (_private_geteuid() == 0 &&
goto out;
}
if (inheritflag == PRIO_INHERIT)
else
}
} else {
}
out:
return (error);
}
/*
* pthread_setschedparam: sets the sched parameters for a thread.
*/
int
{
}