Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libpthread Add a new internal function, pthread__sched_s...
details: https://anonhg.NetBSD.org/src/rev/bc7980c9abe2
branches: trunk
changeset: 542506:bc7980c9abe2
user: nathanw <nathanw%NetBSD.org@localhost>
date: Fri Jan 31 04:58:57 2003 +0000
description:
Add a new internal function, pthread__sched_sleepers(), which iterates
over a sleep queue and puts everything on the run queue. This permits
the iteration to be inside the acquisition of the run queue spinlock,
avoiding repetitive acquire/release cycles.
diffstat:
lib/libpthread/pthread_int.h | 3 ++-
lib/libpthread/pthread_run.c | 22 +++++++++++++++++++++-
2 files changed, 23 insertions(+), 2 deletions(-)
diffs (53 lines):
diff -r fb20b0bc6f4d -r bc7980c9abe2 lib/libpthread/pthread_int.h
--- a/lib/libpthread/pthread_int.h Fri Jan 31 04:55:52 2003 +0000
+++ b/lib/libpthread/pthread_int.h Fri Jan 31 04:58:57 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pthread_int.h,v 1.4 2003/01/25 00:43:38 nathanw Exp $ */
+/* $NetBSD: pthread_int.h,v 1.5 2003/01/31 04:58:57 nathanw Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -216,6 +216,7 @@
void pthread__block(pthread_t self, pthread_spin_t* queuelock);
/* Put a thread back on the run queue */
void pthread__sched(pthread_t self, pthread_t thread);
+void pthread__sched_sleepers(pthread_t self, struct pthread_queue_t *threadq);
void pthread__sched_idle(pthread_t self, pthread_t thread);
void pthread__sched_idle2(pthread_t self);
diff -r fb20b0bc6f4d -r bc7980c9abe2 lib/libpthread/pthread_run.c
--- a/lib/libpthread/pthread_run.c Fri Jan 31 04:55:52 2003 +0000
+++ b/lib/libpthread/pthread_run.c Fri Jan 31 04:58:57 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pthread_run.c,v 1.4 2003/01/30 01:00:58 nathanw Exp $ */
+/* $NetBSD: pthread_run.c,v 1.5 2003/01/31 04:58:57 nathanw Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -143,6 +143,26 @@
pthread_spinunlock(self, &pthread__runqueue_lock);
}
+/* Put a bunch of sleeping threads on the run queue */
+void
+pthread__sched_sleepers(pthread_t self, struct pthread_queue_t *threadq)
+{
+ pthread_t thread;
+
+ pthread_spinlock(self, &pthread__runqueue_lock);
+ PTQ_FOREACH(thread, threadq, pt_sleep) {
+ SDPRINTF(("(sched_sleepers %p) scheduling %p\n", self, thread);
+ thread->pt_state = PT_STATE_RUNNABLE;
+ assert (thread->pt_type == PT_THREAD_NORMAL);
+ assert (thread->pt_spinlocks == 0);
+#ifdef PTHREAD__DEBUG
+ thread->rescheds++;
+#endif
+ PTQ_INSERT_TAIL(&pthread__runqueue, thread, pt_runq);
+ }
+ pthread_spinunlock(self, &pthread__runqueue_lock);
+}
+
/* Make a thread a candidate idle thread. */
void
Home |
Main Index |
Thread Index |
Old Index