/*
* 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 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <sys/sysmacros.h>
/*
* The callb mechanism provides generic event scheduling/echoing.
* A callb function is registered and called on behalf of the event.
*/
typedef struct callb {
} callb_t;
/*
* callb c_flag bitmap definitions
*/
/*
* Basic structure for a callb table.
* All callbs are organized into different class groups described
* by ct_class array.
* The callbs within a class are single-linked and normally run by a
* serial execution.
*/
typedef struct callb_table {
void *, int, char *, kthread_id_t);
&callb_safe_mutex, CALLB_CPR_ALWAYS_SAFE, 0, 0, 0 };
/*
* Init all callb tables in the system.
*/
void
{
}
/*
* callout_add() is called to register func() be called later.
*/
static callb_id_t
{
}
#ifdef DEBUG
"too long -- truncated to %d chars",
name, CB_MAXNAME);
#endif
/*
* Insert the new callb at the head of its class list.
*/
return ((callb_id_t)cp);
}
/*
* The default function to add an entry to the callback table. Since
* it uses curthread as the thread identifier to store in the table,
* it should be used for the normal case of a thread which is calling
* to add ITSELF to the table.
*/
{
}
/*
* A special version of callb_add() above for use by threads which
* might be adding an entry to the table on behalf of some other
* thread (for example, one which is constructed but not yet running).
* In this version the thread id is an argument.
*/
{
}
/*
* callout_delete() is called to remove an entry identified by id
* that was originally placed there by a call to callout_add().
* return -1 if fail to delete a callb entry otherwise return 0.
*/
int
{
for (;;) {
#ifdef DEBUG
(void *)me);
return (-1);
}
#endif /* DEBUG */
/*
* It is not allowed to delete a callb in the middle of
* executing otherwise, the callb_execute() will be confused.
*/
break;
}
/* relink the class list */
/* clean up myself and return the free callb to the head of freelist */
return (0);
}
/*
* class: indicates to execute all callbs in the same class;
* code: optional argument for the callb functions.
* return: = 0: success
* != 0: ptr to string supplied when callback was registered
*/
void *
{
/*
* cont if the callb is deleted while we're sleeping
*/
continue;
#ifdef CALLB_DEBUG
printf("callb_execute: name=%s func=%p arg=%p\n",
#endif /* CALLB_DEBUG */
/* If callback function fails, pass back client's name */
}
return (ret);
}
/*
* callers make sure no recursive entries to this func.
* dp->cc_lockp is registered by callb_add to protect callb_cpr_t structure.
*
* When calling to stop a kernel thread (code == CB_CODE_CPR_CHKPT) we
* use a cv_timedwait() in case the kernel thread is blocked.
*
* Note that this is a generic callback handler for daemon CPR and
* should NOT be changed to accommodate any specific requirement in a daemon.
* Individual daemons that require changes to the handler shall write
* callback routines in their own daemon modules.
*/
{
switch (code) {
case CB_CODE_CPR_CHKPT:
#ifdef CPR_NOT_THREAD_SAFE
/* cv_timedwait() returns -1 if it times out. */
TR_CLOCK_TICK)) == -1)
break;
#endif
break;
case CB_CODE_CPR_RESUME:
break;
}
return (ret != -1);
}
/*
* The generic callback function associated with kernel threads which
* are always considered safe.
*/
/* ARGSUSED */
{
return (B_TRUE);
}
/*
* Prevent additions to callback table.
*/
void
callb_lock_table(void)
{
}
/*
* Allow additions to callback table.
*/
void
callb_unlock_table(void)
{
}
/*
* Return a boolean value indicating whether a particular kernel thread is
* stopped in accordance with the cpr callback protocol. If returning
* false, also return a pointer to the thread name via the 2nd argument.
*/
{
;
if (ret_val) {
/*
* We found the thread in the callback table and have
* provisionally set the return value to true. Now
* see if it is marked "safe" and is sleeping or stopped.
*/
int retry;
break;
}
}
} else {
ret_val =
}
} else {
/*
* Thread not found in callback table. Make the best
* attempt to identify the thread in the error message.
*/
&offset);
}
return (ret_val);
}