summaryrefslogtreecommitdiffstats
path: root/contrib/amd/amd/sched.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/amd/amd/sched.c')
-rw-r--r--contrib/amd/amd/sched.c70
1 files changed, 37 insertions, 33 deletions
diff --git a/contrib/amd/amd/sched.c b/contrib/amd/amd/sched.c
index c32ef0f..8efe57a 100644
--- a/contrib/amd/amd/sched.c
+++ b/contrib/amd/amd/sched.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997-2004 Erez Zadok
+ * Copyright (c) 1997-2006 Erez Zadok
* Copyright (c) 1990 Jan-Simon Pendry
* Copyright (c) 1990 Imperial College of Science, Technology & Medicine
* Copyright (c) 1990 The Regents of the University of California.
@@ -36,9 +36,8 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * %W% (Berkeley) %G%
*
- * $Id: sched.c,v 1.4.2.5 2004/01/06 03:15:16 ezk Exp $
+ * File: am-utils/amd/sched.c
*
*/
@@ -56,12 +55,12 @@
typedef struct pjob pjob;
struct pjob {
- qelem hdr; /* Linked list */
- int pid; /* Process ID of job */
- cb_fun cb_fun; /* Callback function */
- voidp cb_closure; /* Closure for callback */
+ qelem hdr; /* Linked list */
+ int pid; /* Process ID of job */
+ cb_fun *cb_fun; /* Callback function */
+ opaque_t cb_arg; /* Argument for callback */
int w; /* everyone these days uses int, not a "union wait" */
- voidp wchan; /* Wait channel */
+ wchan_t wchan; /* Wait channel */
};
/* globals */
@@ -94,12 +93,12 @@ rem_que(qelem *elem)
static pjob *
-sched_job(cb_fun cf, voidp ca)
+sched_job(cb_fun *cf, opaque_t ca)
{
pjob *p = ALLOC(struct pjob);
p->cb_fun = cf;
- p->cb_closure = ca;
+ p->cb_arg = ca;
/*
* Now place on wait queue
@@ -115,7 +114,7 @@ sched_job(cb_fun cf, voidp ca)
* cf: Continuation function (ca is its arguments)
*/
void
-run_task(task_fun tf, voidp ta, cb_fun cf, voidp ca)
+run_task(task_fun *tf, opaque_t ta, cb_fun *cf, opaque_t ca)
{
pjob *p = sched_job(cf, ca);
#ifdef HAVE_SIGACTION
@@ -124,7 +123,7 @@ run_task(task_fun tf, voidp ta, cb_fun cf, voidp ca)
int mask;
#endif /* not HAVE_SIGACTION */
- p->wchan = (voidp) p;
+ p->wchan = (wchan_t) p;
#ifdef HAVE_SIGACTION
sigemptyset(&new); /* initialize signal set we wish to block */
@@ -143,7 +142,7 @@ run_task(task_fun tf, voidp ta, cb_fun cf, voidp ca)
return;
}
- /* child code runs here, parent have returned to caller */
+ /* child code runs here, parent has returned to caller */
exit((*tf) (ta));
/* firewall... */
@@ -155,19 +154,17 @@ run_task(task_fun tf, voidp ta, cb_fun cf, voidp ca)
* Schedule a task to be run when woken up
*/
void
-sched_task(cb_fun cf, voidp ca, voidp wchan)
+sched_task(cb_fun *cf, opaque_t ca, wchan_t wchan)
{
/*
* Allocate a new task
*/
pjob *p = sched_job(cf, ca);
-#ifdef DEBUG
- dlog("SLEEP on %#lx", (unsigned long) wchan);
-#endif /* DEBUG */
+ dlog("SLEEP on %p", wchan);
p->wchan = wchan;
p->pid = 0;
- memset((voidp) &p->w, 0, sizeof(p->w));
+ p->w = 0; /* was memset (when ->w was union) */
}
@@ -181,7 +178,7 @@ wakeupjob(pjob *p)
void
-wakeup(voidp wchan)
+wakeup(wchan_t wchan)
{
pjob *p, *p2;
@@ -189,7 +186,7 @@ wakeup(voidp wchan)
return;
/*
- * Can't user ITER() here because
+ * Can't use ITER() here because
* wakeupjob() juggles the list.
*/
for (p = AM_FIRST(pjob, &proc_wait_list);
@@ -203,9 +200,20 @@ wakeup(voidp wchan)
void
-wakeup_task(int rc, int term, voidp cl)
+wakeup_task(int rc, int term, wchan_t wchan)
{
- wakeup(cl);
+ wakeup(wchan);
+}
+
+
+wchan_t
+get_mntfs_wchan(mntfs *mf)
+{
+ if (mf &&
+ mf->mf_ops &&
+ mf->mf_ops->get_wchan)
+ return mf->mf_ops->get_wchan(mf);
+ return mf;
}
@@ -236,9 +244,9 @@ do_task_notify(void)
*/
if (p->cb_fun) {
/* these two trigraphs will ensure compatibility with strict POSIX.1 */
- (*p->cb_fun) (WIFEXITED(p->w) ? WEXITSTATUS(p->w) : 0,
- WIFSIGNALED(p->w) ? WTERMSIG(p->w) : 0,
- p->cb_closure);
+ p->cb_fun(WIFEXITED(p->w) ? WEXITSTATUS(p->w) : 0,
+ WIFSIGNALED(p->w) ? WTERMSIG(p->w) : 0,
+ p->cb_arg);
}
XFREE(p);
}
@@ -261,11 +269,9 @@ sigchld(int sig)
if (WIFSIGNALED(w))
plog(XLOG_ERROR, "Process %d exited with signal %d",
pid, WTERMSIG(w));
-#ifdef DEBUG
else
dlog("Process %d exited with status %d",
pid, WEXITSTATUS(w));
-#endif /* DEBUG */
for (p = AM_FIRST(pjob, &proc_wait_list);
p2 = NEXT(pjob, p), p != HEAD(pjob, &proc_wait_list);
@@ -277,18 +283,16 @@ sigchld(int sig)
}
} /* end of for loop */
-#ifdef DEBUG
- if (!p)
+ if (p == HEAD(pjob, &proc_wait_list))
dlog("can't locate task block for pid %d", pid);
-#endif /* DEBUG */
/*
* Must count down children inside the while loop, otherwise we won't
- * count them all, and NumChild (and later backoff) will be set
+ * count them all, and NumChildren (and later backoff) will be set
* incorrectly. SH/RUNIT 940519.
*/
- if (--NumChild < 0)
- NumChild = 0;
+ if (--NumChildren < 0)
+ NumChildren = 0;
} /* end of "while wait..." loop */
#ifdef REINSTALL_SIGNAL_HANDLER
OpenPOWER on IntegriCloud