thr_attr_setschedparam.c revision 71581
133965Sjdp/* 2104834Sobrien * Copyright (c) 1998 Daniel Eischen <eischen@vigrid.com>. 333965Sjdp * All rights reserved. 433965Sjdp * 533965Sjdp * Redistribution and use in source and binary forms, with or without 633965Sjdp * modification, are permitted provided that the following conditions 733965Sjdp * are met: 833965Sjdp * 1. Redistributions of source code must retain the above copyright 933965Sjdp * notice, this list of conditions and the following disclaimer. 1033965Sjdp * 2. Redistributions in binary form must reproduce the above copyright 1133965Sjdp * notice, this list of conditions and the following disclaimer in the 1233965Sjdp * documentation and/or other materials provided with the distribution. 1333965Sjdp * 3. All advertising materials mentioning features or use of this software 1433965Sjdp * must display the following acknowledgement: 1533965Sjdp * This product includes software developed by Daniel Eischen. 1633965Sjdp * 4. Neither the name of the author nor the names of any co-contributors 17218822Sdim * may be used to endorse or promote products derived from this software 1833965Sjdp * without specific prior written permission. 1933965Sjdp * 2033965Sjdp * THIS SOFTWARE IS PROVIDED BY DANIEL EISCHEN AND CONTRIBUTORS ``AS IS'' AND 2133965Sjdp * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2233965Sjdp * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2333965Sjdp * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 2433965Sjdp * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2589857Sobrien * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2689857Sobrien * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2789857Sobrien * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2889857Sobrien * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2989857Sobrien * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3089857Sobrien * SUCH DAMAGE. 3189857Sobrien * 3289857Sobrien * $FreeBSD: head/lib/libkse/thread/thr_attr_setschedparam.c 71581 2001-01-24 13:03:38Z deischen $ 3389857Sobrien */ 3489857Sobrien#include <errno.h> 3589857Sobrien#include <pthread.h> 3689857Sobrien#include "pthread_private.h" 3789857Sobrien 3889857Sobrien#pragma weak pthread_attr_setschedparam=_pthread_attr_setschedparam 3989857Sobrien 4077298Sobrienint 4177298Sobrien_pthread_attr_setschedparam(pthread_attr_t *attr, const struct sched_param *param) 4233965Sjdp{ 43218822Sdim int ret = 0; 4433965Sjdp 4533965Sjdp if ((attr == NULL) || (*attr == NULL)) 4633965Sjdp ret = EINVAL; 4733965Sjdp else if (param == NULL) { 4833965Sjdp ret = ENOTSUP; 4933965Sjdp } else if ((param->sched_priority < PTHREAD_MIN_PRIORITY) || 50218822Sdim (param->sched_priority > PTHREAD_MAX_PRIORITY)) { 5133965Sjdp /* Return an unsupported value error. */ 5233965Sjdp ret = ENOTSUP; 5333965Sjdp } else 5433965Sjdp (*attr)->prio = param->sched_priority; 5533965Sjdp 5633965Sjdp return(ret); 5733965Sjdp} 5833965Sjdp