Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 1 Sep 2002 01:21:08 -0700 (PDT)
From:      Jonathan Mini <mini@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 16894 for review
Message-ID:  <200209010821.g818L8Xa034277@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
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 <sys/types.h>
@@ -39,6 +39,16 @@
 #include <sysexits.h>
 #include <unistd.h>
 
+#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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200209010821.g818L8Xa034277>