Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 28 Sep 2001 00:24:13 -0700
From:      Julian Elischer <julian@elischer.org>
To:        arch@freebsd.org
Subject:   Re: KSE next steps...
Message-ID:  <3BB4259D.4AF78B4@elischer.org>
References:  <3BB410B3.A2527C09@elischer.org>

next in thread | previous in thread | raw e-mail | index | archive | help

> c) define the user interface so that userland code can start to be planned.
Here are some ideas..
these are up for discussion....

/* embed this in the Userland thread info */
struct kt_context {
	struct kt_context *ktc_next_completed;
	mcontext_t	ktc_ctx;
	void 		*ktc_UTS_private;
	unsigned int	ktc_return_info;
};

/* Need one of these per KSE. */
struct ks_mailbox {
	struct kt_context *ksm_curthread;
	struct kt_context *ksm_completed;	/* runnable threads */
	unsigned int	ksm_upcall_reason;
	/* probably some info for delivering signals */
}

possible syscalls....

int new_kse(struct ks_mailbox *mbox, int new_group); /* add a new KSE */
				/* maybe in a new kse group */

int yield_kse(struct timespec *sleeptime); /* don't come back till */
				/* time passed or work to do. */

int wake_kse(struct ks_mailbox *mbx);	/* if we specify a yielded KSE *
				/* both will return. NULL wakes any. */

void exit_kse();		/* Will not return, but */
				/* writes completion code in mailbox. */

int abort_thread(struct kt_context *ktc); /* if we find a thread in */ 
				/* this process that has this ktc, */
				/* then if it is sleeping, abort the syscall */
				/* if it is running, let it continue but set */
				/* flag so that if it tries to sleep, it aborts */
				/* instead */

maybe reversing the sycall names...
kse_new(), kse_yield(), kse_wake(), kse_exit(), thread_abort()

how to start a KSE....

do a setjmp()
Allocate a small stack.
put the jump buf address on it..
temporarily switch to that stack. 
call a function that allocates the mailbox on that stack,
fill in fields needed.
call kse_new() with a pointer to the mailbox.
return to the old stack by doing the longjmp();
new KSE will also return from the kse_new(); so the small stack
must never be rewound... until after that thread calls kse_exit().
All upcalls will also return there...

kernel gets address of ktc from the mailbox. If the thread is 
suspended, it will zero that field..


-- 
+------------------------------------+       ______ _  __
|   __--_|\  Julian Elischer         |       \     U \/ / hard at work in 
|  /       \ julian@elischer.org     +------>x   USA    \ a very strange
| (   OZ    )                                \___   ___ | country !
+- X_.---._/    presently in San Francisco       \_/   \\
          v

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-arch" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3BB4259D.4AF78B4>