Add puffs_cc_schedule() which marks a pcc runnable and will pass

execution to it when in the main loop the next time.
This commit is contained in:
pooka 2007-10-21 19:25:58 +00:00
parent 0e9691e3e3
commit 753b7cae6e
5 changed files with 38 additions and 8 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: callcontext.c,v 1.9 2007/10/21 14:28:05 pooka Exp $ */
/* $NetBSD: callcontext.c,v 1.10 2007/10/21 19:25:58 pooka Exp $ */
/*
* Copyright (c) 2006 Antti Kantee. All Rights Reserved.
@ -27,7 +27,7 @@
#include <sys/cdefs.h>
#if !defined(lint)
__RCSID("$NetBSD: callcontext.c,v 1.9 2007/10/21 14:28:05 pooka Exp $");
__RCSID("$NetBSD: callcontext.c,v 1.10 2007/10/21 19:25:58 pooka Exp $");
#endif /* !lint */
#include <sys/types.h>
@ -84,6 +84,15 @@ puffs_goto(struct puffs_cc *loanpcc)
swapcontext(&loanpcc->pcc_uc_ret, &loanpcc->pcc_uc);
}
void
puffs_cc_schedule(struct puffs_cc *pcc)
{
struct puffs_usermount *pu = pcc->pcc_pu;
assert(pu->pu_state & PU_INLOOP);
TAILQ_INSERT_TAIL(&pu->pu_sched, pcc, entries);
}
struct puffs_usermount *
puffs_cc_getusermount(struct puffs_cc *pcc)
{

View File

@ -1,4 +1,4 @@
/* $NetBSD: puffs.c,v 1.66 2007/10/11 19:41:15 pooka Exp $ */
/* $NetBSD: puffs.c,v 1.67 2007/10/21 19:25:58 pooka Exp $ */
/*
* Copyright (c) 2005, 2006, 2007 Antti Kantee. All Rights Reserved.
@ -31,7 +31,7 @@
#include <sys/cdefs.h>
#if !defined(lint)
__RCSID("$NetBSD: puffs.c,v 1.66 2007/10/11 19:41:15 pooka Exp $");
__RCSID("$NetBSD: puffs.c,v 1.67 2007/10/21 19:25:58 pooka Exp $");
#endif /* !lint */
#include <sys/param.h>
@ -416,6 +416,7 @@ _puffs_init(int develv, struct puffs_ops *pops, const char *mntfromname,
LIST_INIT(&pu->pu_pnodelst);
LIST_INIT(&pu->pu_framectrl.fb_ios);
LIST_INIT(&pu->pu_ccnukelst);
TAILQ_INIT(&pu->pu_sched);
/* defaults for some user-settable translation functions */
pu->pu_cmap = NULL; /* identity translation */
@ -474,6 +475,7 @@ puffs_mainloop(struct puffs_usermount *pu, int flags)
struct puffs_putreq *ppr = NULL;
struct puffs_framectrl *pfctrl = &pu->pu_framectrl;
struct puffs_fctrl_io *fio;
struct puffs_cc *pcc;
struct kevent *curev, *newevs;
size_t nchanges;
int puffsfd, sverrno;
@ -634,6 +636,14 @@ puffs_mainloop(struct puffs_usermount *pu, int flags)
puffs_framev_notify(fio, what);
}
/*
* Schedule continuations.
*/
while ((pcc = TAILQ_FIRST(&pu->pu_sched)) != NULL) {
TAILQ_REMOVE(&pu->pu_sched, pcc, entries);
puffs_goto(pcc);
}
/*
* Really free fd's now that we don't have references
* to them.

View File

@ -1,4 +1,4 @@
/* $NetBSD: puffs.h,v 1.88 2007/10/21 14:28:05 pooka Exp $ */
/* $NetBSD: puffs.h,v 1.89 2007/10/21 19:25:58 pooka Exp $ */
/*
* Copyright (c) 2005, 2006, 2007 Antti Kantee. All Rights Reserved.
@ -572,6 +572,7 @@ int puffs_req_handle(struct puffs_getreq *,
void puffs_cc_yield(struct puffs_cc *);
void puffs_cc_continue(struct puffs_cc *);
void puffs_cc_schedule(struct puffs_cc *);
struct puffs_usermount *puffs_cc_getusermount(struct puffs_cc *);
void *puffs_cc_getspecific(struct puffs_cc *);
int puffs_cc_getcaller(struct puffs_cc *,pid_t *,lwpid_t *);

View File

@ -1,4 +1,4 @@
.\" $NetBSD: puffs_cc.3,v 1.6 2007/05/06 13:56:16 pooka Exp $
.\" $NetBSD: puffs_cc.3,v 1.7 2007/10/21 19:25:58 pooka Exp $
.\"
.\" Copyright (c) 2007 Antti Kantee. All rights reserved.
.\"
@ -23,7 +23,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.Dd April 19, 2007
.Dd October 21, 2007
.Dt PUFFS_CC 3
.Os
.Sh NAME
@ -41,6 +41,8 @@
.Fn puffs_cc_yield "struct puffs_cc *pcc"
.Ft void
.Fn puffs_cc_continue "struct puffs_cc *pcc"
.Ft void
.Fn puffs_cc_schedule "struct puffs_cc *pcc"
.Ft int
.Fn puffs_docc "struct puffs_cc *pcc" "struct puffs_putreq *ppr"
.Sh DESCRIPTION
@ -89,6 +91,13 @@ Will suspend current execution and return control to where it was
before before calling
.Fn puffs_cc_yield .
This is rarely called directly.
.It Fn puffs_cc_schedule "pcc"
Schedule a continuation.
As opposed to
.Fn puffs_cc_continue
this call returns immediately.
.Fa pcc
will be scheduled sometime in the future.
.It Fn puffs_docc "pcc" "ppr"
Continues request suspended with
.Fn puffs_cc_yield .

View File

@ -1,4 +1,4 @@
/* $NetBSD: puffs_priv.h,v 1.24 2007/10/21 14:28:05 pooka Exp $ */
/* $NetBSD: puffs_priv.h,v 1.25 2007/10/21 19:25:58 pooka Exp $ */
/*
* Copyright (c) 2006 Antti Kantee. All Rights Reserved.
@ -111,6 +111,7 @@ struct puffs_usermount {
LIST_HEAD(, puffs_node) pu_pnodelst;
LIST_HEAD(, puffs_cc) pu_ccnukelst;
TAILQ_HEAD(, puffs_cc) pu_sched;
struct puffs_node *(*pu_cmap)(void *);