From owner-p4-projects Sun Sep 1 1:21:24 2002 Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id BACCA37B401; Sun, 1 Sep 2002 01:21:09 -0700 (PDT) Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 3C9AB37B400 for ; Sun, 1 Sep 2002 01:21:09 -0700 (PDT) Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id E24ED43E3B for ; Sun, 1 Sep 2002 01:21:08 -0700 (PDT) (envelope-from mini@freebsd.org) Received: from freefall.freebsd.org (perforce@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.4/8.12.4) with ESMTP id g818L8JU034287 for ; Sun, 1 Sep 2002 01:21:08 -0700 (PDT) (envelope-from mini@freebsd.org) Received: (from perforce@localhost) by freefall.freebsd.org (8.12.4/8.12.4/Submit) id g818L8Xa034277 for perforce@freebsd.org; Sun, 1 Sep 2002 01:21:08 -0700 (PDT) Date: Sun, 1 Sep 2002 01:21:08 -0700 (PDT) Message-Id: <200209010821.g818L8Xa034277@freefall.freebsd.org> X-Authentication-Warning: freefall.freebsd.org: perforce set sender to mini@freebsd.org using -f From: Jonathan Mini Subject: PERFORCE change 16894 for review To: Perforce Change Reviews Sender: owner-p4-projects@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG http://people.freebsd.org/~peter/p4db/chv.cgi?CH=16894 Change 16894 by mini@mini_stylus on 2002/09/01 01:20:50 - Remove myswapcontext(). Start using the one from libc again. - Add macros to wrap debugging output from the UTS, and disable the output. - Add a thread that continiously performs a trivial syscall. Affected files ... .. //depot/projects/kse/tools/KSE/uts/uts.c#4 edit Differences ... ==== //depot/projects/kse/tools/KSE/uts/uts.c#4 (text+ko) ==== @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $P4: //depot/projects/kse/tools/KSE/uts/uts.c#3 $ + * $P4: //depot/projects/kse/tools/KSE/uts/uts.c#4 $ */ #include @@ -39,6 +39,16 @@ #include #include +#ifdef TRACE_UTS +#define UPFMT(fmt...) pfmt(#fmt) +#define UPSTR(s) pstr(s) +#define UPCHAR(c) pchar(s) +#else +#define UPFMT(fmt...) /* Nothing. */ +#define UPSTR(s) /* Nothing. */ +#define UPCHAR(c) /* Nothing. */ +#endif + #define MAIN_STACK_SIZE (1024 * 1024) #define THREAD_STACK_SIZE (32 * 1024) @@ -56,9 +66,6 @@ static void thread_start(const void *func); static void uts(void); -static int myswapcontext(ucontext_t *oucp, const ucontext_t *ucp, - struct thread_mailbox *p); - void aaaa(void) { @@ -69,6 +76,12 @@ } } +void +spin(void) +{ + for (;;) sched_yield(); +} + /* * Test Userland Thread Scheduler (UTS) suite for KSE. */ @@ -77,14 +90,15 @@ { int i; - pfmt("ofs: %d\n", offsetof(ucontext_t, uc_flags) - offsetof(ucontext_t, uc_mcontext)); - //thread_start(aaaa); + thread_start(aaaa); + thread_start(spin); init_uts(); - for (i = 0;i < 5;i++) { - pfmt("main(): %d\n", i); - sleep(2); + for (i = 0;1;i++) { + progress++; + pchar('a' + (i % 26)); + sleep(5); } - pstr("** main() exiting **\n"); + pstr("\n** main() exiting **\n"); return (EX_OK); } @@ -261,9 +275,9 @@ struct thread_mailbox *tm, *p; int ret; - pstr("\n--uts() start--\n"); + UPSTR("\n--uts() start--\n"); for (;;) { - pfmt("km_curthread -> 0x%x\n", uts_mb.km_curthread); + UPFMT("km_curthread -> 0x%x\n", uts_mb.km_curthread); /* * Insert any processes back from being blocked @@ -271,30 +285,29 @@ */ p = uts_mb.km_completed; uts_mb.km_completed = NULL; - pfmt("km_completed -> 0x%x", p); + UPFMT("km_completed -> 0x%x", p); while ((tm = p) != NULL) { p = tm->tm_next; - pfmt(" 0x%x", p); + UPFMT(" 0x%x", p); runq_insert(tm); } - pchar('\n'); + UPCHAR('\n'); /* * Pull a process off the run queue. */ p = runq_remove(); if (p != NULL) { - pfmt("-- uts() scheduling 0x%x--\n", p); - pfmt("eip -> 0x%x progress -> %d\n", + UPFMT("\n-- uts() scheduling 0x%x--\n", p); + UPFMT("eip -> 0x%x progress -> %d\n", p->tm_context.uc_mcontext.mc_eip, progress); if ((p->tm_context.uc_flags & UCF_CRITICAL) == 0) p->tm_context.uc_flags |= UCF_CRITICAL | UCF_CLEARSTATE; uts_mb.km_curthread = p; - pstr("curthread set\n"); - ret = myswapcontext(&uts_mb.km_context, &p->tm_context, - p); - pfmt("\n-- uts() back from swapcontext() [%d] --\n", + UPSTR("curthread set\n"); + ret = swapcontext(&uts_mb.km_context, &p->tm_context); + UPFMT("\n-- uts() back from swapcontext() [%d] --\n", ret); if (ret) /* @@ -327,29 +340,3 @@ tm->tm_context.uc_flags = UCF_SKIPSIGMASK | UCF_OBEYBUSY; runq_insert(tm); } - -static int -myswapcontext(ucontext_t *oucp, const ucontext_t *ucp, struct thread_mailbox *p) -{ - int ret; - - pfmt("msctx(%x,%x,%x) - %d %d, %x %x, %x %x\n", oucp, ucp, p, - oucp->uc_mcontext.mc_len, ucp->uc_mcontext.mc_len, - oucp->uc_busy, ucp->uc_busy, - oucp->uc_flags, ucp->uc_flags); - if ((oucp == NULL) || - (oucp->uc_mcontext.mc_len != sizeof(mcontext_t)) || - (ucp == NULL) || - (ucp->uc_mcontext.mc_len != sizeof(mcontext_t))) { - pstr("msctx: EINVAL\n"); - return (-1); - } - oucp->uc_flags &= ~UCF_SWAPPED; - ret = getcontext(oucp); - if ((ret == 0) && !(oucp->uc_flags & UCF_SWAPPED)) { - oucp->uc_flags |= UCF_SWAPPED; - oucp->uc_busy = 0; - ret = setcontext(ucp); - } - return (ret); -} To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe p4-projects" in the body of the message