patch-2.3.27 linux/arch/sparc/kernel/process.c

Next file: linux/arch/sparc/kernel/sparc_ksyms.c
Previous file: linux/arch/ppc/mm/init.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.3.26/linux/arch/sparc/kernel/process.c linux/arch/sparc/kernel/process.c
@@ -702,3 +702,37 @@
 			   "g1", "g2", "g3", "o0", "o1", "memory", "cc");
 	return retval;
 }
+
+/*
+ * These bracket the sleeping functions..
+ */
+extern void scheduling_functions_start_here(void);
+extern void scheduling_functions_end_here(void);
+#define first_sched	((unsigned long) scheduling_functions_start_here)
+#define last_sched	((unsigned long) scheduling_functions_end_here)
+
+unsigned long get_wchan(struct task_struct *p)
+{
+	unsigned long pc, fp, bias = 0;
+	unsigned long task_base = (unsigned long) p;
+	struct reg_window *rw;
+	int count = 0;
+	if (!p || p == current || p->state == TASK_RUNNING)
+		return 0;
+
+	fp = p->thread.ksp + bias;
+	do {
+		/* Bogus frame pointer? */
+		if (fp < (task_base + sizeof(struct task_struct)) ||
+		    fp >= (task_base + (2 * PAGE_SIZE)))
+			break;
+		rw = (struct reg_window *) fp;
+		pc = rw->ins[7];
+		if (pc < first_sched || pc >= last_sched)
+			return pc;
+		fp = rw->ins[6] + bias;
+	} while (++count < 16);
+	return 0;
+}
+#undef last_sched
+#undef first_sched

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)