Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 31 Aug 2002 19:37:36 -0700 (PDT)
From:      Jonathan Mini <mini@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 16879 for review
Message-ID:  <200209010237.g812bant074815@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://people.freebsd.org/~peter/p4db/chv.cgi?CH=16879

Change 16879 by mini@mini_stylus on 2002/08/31 19:37:11

	Make UCF_CLEARSTATE clear itself, but not UCF_SWAPPED.

Affected files ...

.. //depot/projects/kse/lib/libc/i386/gen/getcontext.S#6 edit
.. //depot/projects/kse/sys/kern/kern_thread.c#96 edit
.. //depot/projects/kse/sys/sys/ucontext.h#6 edit

Differences ...

==== //depot/projects/kse/lib/libc/i386/gen/getcontext.S#6 (text+ko) ====

@@ -40,13 +40,14 @@
 #define	MC_FP_REGS_OFFSET	96	/* offset to FP regs from mcontext */
 #define	MC_FP_CW_OFFSET		96	/* offset to FP control word */
 #define	MC_OWNEDFP_OFFSET	88	/* offset to mc_ownedfp from mcontext */
-#define UCF_SKIPSIGMASK 0x00000001      /* Don't set/restore signal mask. */
-#define UCF_OBEYBUSY    0x00000002      /* Respect uc_busy marker. */
-#define UCF_CLEARSTATE  0x00000004      /* Clear UCF_STATE in setcontext. */
-#define UCF_SWAPPED     0x00000100      /* Used by swapcontext(3). */
-#define UCF_CRITICAL    0x00000200      /* In a critical section. */
-#define UCF_STATE       0x0000ff00      /* State-related flags. */
-#define UCF_OPTIONS     0x000000ff      /* Behaviour-related flags. */
+#define	UCF_SKIPSIGMASK	0x00000001	/* Don't set/restore signal mask. */
+#define	UCF_OBEYBUSY	0x00000002	/* Respect uc_busy marker. */
+#define	UCF_SWAPPED	0x00000080	/* Used by swapcontext(3). */
+#define	UCF_CRITICAL	0x00000200	/* In a critical section. */
+#define	UCF_CLEARSTATE	0x00000400	/* Clear UCF_STATE in setcontext. */
+#define	UCF_STATE	0x0000ff00	/* State-related flags. */
+#define	UCF_OPTIONS	0x000000ff	/* Behaviour-related flags. */
+ 
  
 
 /*
@@ -106,7 +107,7 @@
 	pushl	40(%edx)		/* %edx on stack  */
 	testl $UCF_CLEARSTATE, MC_FLAGS_OFFSET(%edx)	/* clear flag state? */
 	jz 6f
-	andl	$UCF_OPTIONS, MX_FLAGS_OFFSET(%edx)
+	andl	$UCF_OPTIONS, MC_FLAGS_OFFSET(%edx)
 6:	testl $UCF_OBEYBUSY, MC_FLAGS_OFFSET(%edx)	/* set uc_busy? */
 	jz 7f
 	movl	$1, MC_BUSY_OFFSET(%edx)	/* set uc_busy */

==== //depot/projects/kse/sys/kern/kern_thread.c#96 (text+ko) ====

@@ -503,13 +503,16 @@
 	int discard, error;
 	struct thread_mailbox *tmp;
 
+	printf("consider - ");
 	/*
 	 * If we are in a critical section, return to this thread.
 	 */
 	tmp = (struct thread_mailbox *)fuword(&ke->ke_mailbox->km_curthread);
 	if ((tmp != NULL) &&
-	    (fuword(&tmp->tm_context.uc_flags) & UCF_CRITICAL))
+	    (fuword(&tmp->tm_context.uc_flags) & UCF_CRITICAL)) {
+		printf("CRITICAL - ");
 		return (0);
+	}
 
 	/*
 	 * Save the thread's context, and link it
@@ -522,8 +525,10 @@
 		 * Failing to do the KSE operation just defaults
 		 * back to synchonous operation, so just return from
 		 * the syscall.
-		 */
+		 */{
+		printf("error - ");
 		return (error);
+		 }
 
 	/*
 	 * Decide whether to perfom an upcall now.
@@ -545,9 +550,10 @@
 		 * What is OUR priority?  The priority of the highest
 		 * sycall waiting to be returned?
 		 * For now, just let another KSE run (easiest).
-		 */
+		 */ {
+		printf("runq - ");
 		discard = 1;
-
+		 }
 	/* Make sure the KSE's UTS context is free for use. */
 	if (fuword(&ke->ke_mailbox->km_context.uc_busy) != 0)
 		/*
@@ -555,8 +561,9 @@
 		 * means the UTS is currently running, so switch to it
 		 * instead of performing another upcall (abandon this
 		 * thread).
-		 */
-		discard = 1;
+		 */ {
+		printf("busy - ");
+		discard = 1; }
 
 	/* Discard thread or mark for upcall. */
 	if (discard) {
@@ -572,6 +579,7 @@
 		 * the next upcall to any KSE in this KSEG.
 		 *
 		 */
+		printf("discard\n");
 		PROC_LOCK(p);
 		mtx_lock_spin(&sched_lock);
 		thread_exit(); /* Abandon current thread. */
@@ -606,17 +614,22 @@
 	int error;
 	ucontext_t uc;
 
+	printf("thread_userret - ");
 	/*
 	 * Ensure that we have a spare thread available.
 	 */
-	if (ke->ke_tdspare == NULL)
+	if (ke->ke_tdspare == NULL) {
+		printf("thread_alloc - ");
 		ke->ke_tdspare = thread_alloc();
+	}
 
 	/*
 	 * Bound threads need no additional work.
 	 */
-	if ((td->td_flags & TDF_UNBOUND) == 0)
+	if ((td->td_flags & TDF_UNBOUND) == 0) {
+		printf("bound\n");
 		return (0);
+	}
 	error = 0;
 
 	/*
@@ -639,6 +652,7 @@
 		 */
 		CTR3(KTR_PROC, "userret: upcall thread %p (pid %d, %s)",
 		    td, p->p_pid, p->p_comm);
+		printf("upcall - ");
 
 		/*
 		 * Fetch the current UTS context from userland.
@@ -683,6 +697,7 @@
 	 * we are committing to go to user space as as this KSE here.
 	 */
 	td->td_flags &= ~TDF_UNBOUND;	/* Bind to this user thread. */
+	printf("binding\n");
 	return (error);
 }
 

==== //depot/projects/kse/sys/sys/ucontext.h#6 (text+ko) ====

@@ -51,9 +51,9 @@
 	int		uc_flags;
 #define	UCF_SKIPSIGMASK	0x00000001	/* Don't set/restore signal mask. */
 #define	UCF_OBEYBUSY	0x00000002	/* Respect uc_busy marker. */
-#define	UCF_CLEARSTATE	0x00000004	/* Clear UCF_STATE in setcontext. */
-#define	UCF_SWAPPED	0x00000100	/* Used by swapcontext(3). */
+#define	UCF_SWAPPED	0x00000080	/* Used by swapcontext(3). */
 #define	UCF_CRITICAL	0x00000200	/* In a critical section. */
+#define	UCF_CLEARSTATE	0x00000400	/* Clear UCF_STATE in setcontext. */
 #define	UCF_STATE	0x0000ff00	/* State-related flags. */
 #define	UCF_OPTIONS	0x000000ff	/* Behaviour-related flags. */
 	int		__spare__[4];

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?200209010237.g812bant074815>