PERFORCE change 42666 for review

John Baldwin jhb at FreeBSD.org
Mon Nov 17 07:55:05 PST 2003


http://perforce.freebsd.org/chv.cgi?CH=42666

Change 42666 by jhb at jhb_laptop on 2003/11/17 07:54:49

	Move schedcpu() off into is own kthread to work around locking
	problems with calling this from softclock.

Affected files ...

.. //depot/projects/smpng/sys/kern/sched_4bsd.c#18 edit

Differences ...

==== //depot/projects/smpng/sys/kern/sched_4bsd.c#18 (text+ko) ====

@@ -80,11 +80,11 @@
 static int	sched_quantum;	/* Roundrobin scheduling quantum in ticks. */
 #define	SCHED_QUANTUM	(hz / 10)	/* Default sched quantum */
 
-static struct callout schedcpu_callout;
 static struct callout roundrobin_callout;
 
 static void	roundrobin(void *arg);
 static void	schedcpu(void *arg);
+static void	schedcpu_thread(void *dummy);
 static void	sched_setup(void *dummy);
 static void	maybe_resched(struct thread *td);
 static void	updatepri(struct ksegrp *kg);
@@ -348,7 +348,20 @@
 		mtx_unlock_spin(&sched_lock);
 	} /* end of process loop */
 	sx_sunlock(&allproc_lock);
-	callout_reset(&schedcpu_callout, hz, schedcpu, NULL);
+}
+
+/*
+ * Main loop for a kthread that executes schedcpu once a second.
+ */
+static void
+schedcpu_thread(void *dummy)
+{
+	int nowake;
+
+	for (;;) {
+		schedcpu();
+		tsleep(&nowake, curthread->td_priority, "-", hz);
+	}
 }
 
 /*
@@ -407,12 +420,13 @@
 		sched_quantum = SCHED_QUANTUM;
 	hogticks = 2 * sched_quantum;
 
-	callout_init(&schedcpu_callout, CALLOUT_MPSAFE);
 	callout_init(&roundrobin_callout, 0);
 
 	/* Kick off timeout driven events by calling first time. */
 	roundrobin(NULL);
-	schedcpu(NULL);
+
+	/* Kick off schedcpu kernel process. */
+	kthread_create(schedcpu_thread, NULL, NULL, 0, 0, "schedcpu");
 }
 
 /* External interfaces start here */


More information about the p4-projects mailing list