class.c revision aaad92d017a1c5dd74caf325dbb299e629edc748
/*
* 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 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <sys/sysmacros.h>
#include <sys/schedctl.h>
static int getcidbyname_locked(char *, id_t *);
/*
* Allocate a cid given a class name if one is not already allocated.
* Returns 0 if the cid was already exists or if the allocation of a new
* cid was successful. Nonzero return indicates error.
*/
int
{
/*
* If the clname doesn't already have a cid, allocate one.
*/
/*
* Allocate a class entry and a lock for it.
*/
break;
return (ENOSPC);
}
}
/*
* At this point, *cidp will contain the index into the class
* array for the given class name.
*/
return (0);
}
int
{
int rv = 0;
/* Check if class name is "", ".", ".." or "`" */
return (EINVAL);
if (LOADABLE_SCHED(clp)) {
if (!SCHED_INSTALLED(clp)) {
return (EINVAL);
/* did we really load a scheduling class? */
if (!SCHED_INSTALLED(clp))
}
}
return (rv);
}
/*
* Get class ID given class name.
*/
int
{
int retval;
/*
* If it returns zero, it's loaded & locked
* or we found a statically installed scheduler
* module.
* If it returns EINVAL, modload() failed when
* it tried to load the module.
*/
/* last guy out of scheduler_load frees the storage */
}
}
return (retval);
}
static int
{
return (EINVAL);
return (0);
}
}
return (EINVAL);
}
/*
* Lookup a module by name.
*/
int
{
int retval;
return (retval);
}
/*
* Get the scheduling parameters of the thread pointed to by
* tp into the buffer pointed to by parmsp.
*/
void
{
}
/*
* Check the validity of the scheduling parameters in the buffer
* pointed to by parmsp.
* Note that the format of the parameters may be changed by class
* specific code which we call.
*/
int
{
return (EINVAL);
/*
* Call the class specific routine to validate class
* specific parameters.
* The input parameters are either in a pcparms structure (PC_SETPARMS)
* or in a variable parameter structure (PC_SETXPARMS). In the
* 'PC_SETPARMS' case vaparmsp is a NULL pointer and a CL_PARMSIN()
* routine gets the parameter. Otherwise vaparmsp points to a variable
* parameter structure and a CL_VAPARMSIN() routine gets the parameter.
*/
else
parmsp->pc_clparms));
}
/*
* Call the class specific code to do the required processing
* before the scheduling parameters are copied out to the user.
* Note that the format of the parameters may be changed by the
* class specific code.
*/
int
{
vaparmsp));
}
/*
* Set the scheduling parameters of the thread pointed to by
* targtp to those specified in the pcparms structure pointed
* to by parmsp. If reqtp is non-NULL it points to the thread
* that initiated the request for the parameter change and indicates
* that our caller wants us to verify that the requesting thread
* has the appropriate permissions.
*/
int
{
int error;
/*
* Check basic permissions.
*/
return (EPERM);
}
} else {
}
/*
* Target thread must change to new class.
*/
/*
* Purpose: allow scheduling class to veto moves
* to other classes. All the classes, except FSS,
* do nothing except returning 0.
*/
if (error) {
/*
* Not allowed to leave the class, so return error.
*/
return (error);
} else {
/*
* Pre-allocate scheduling class data.
*/
return (error);
} else {
if (error) {
return (error);
}
}
}
} else {
/*
* Not changing class
*/
if (error)
return (error);
}
return (0);
}
/*
* Copy all selected class parameters to the user.
* The parameters are specified by a key.
*/
int
{
char *clname;
switch (vaparmsp->pc_vaparmscnt) {
case 0:
return (0);
case 1:
break;
default:
return (EINVAL);
}
return (EINVAL);
return (EFAULT);
return (0);
}