From owner-freebsd-arch Fri Sep 28 0:44:18 2001 Delivered-To: freebsd-arch@freebsd.org Received: from InterJet.elischer.org (c421509-a.pinol1.sfba.home.com [24.7.86.9]) by hub.freebsd.org (Postfix) with ESMTP id 598A637B408 for ; Fri, 28 Sep 2001 00:44:13 -0700 (PDT) Received: from elischer.org (InterJet.elischer.org [192.168.1.1]) by InterJet.elischer.org (8.9.1a/8.9.1) with ESMTP id BAA69319 for ; Fri, 28 Sep 2001 01:20:37 -0700 (PDT) Message-ID: <3BB4259D.4AF78B4@elischer.org> Date: Fri, 28 Sep 2001 00:24:13 -0700 From: Julian Elischer X-Mailer: Mozilla 4.7 [en] (X11; U; FreeBSD 5.0-CURRENT i386) X-Accept-Language: en, hu MIME-Version: 1.0 To: arch@freebsd.org Subject: Re: KSE next steps... References: <3BB410B3.A2527C09@elischer.org> Content-Type: text/plain; charset=iso-8859-2 Content-Transfer-Encoding: 7bit Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG > 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