PERFORCE change 142883 for review

Weongyo Jeong weongyo at FreeBSD.org
Wed Jun 4 12:10:01 UTC 2008


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

Change 142883 by weongyo at weongyo_ws on 2008/06/04 12:09:43

	Implement KeGetCurrentThread() and KeSetPriorityThread().

Affected files ...

.. //depot/projects/ndisusb/sys/compat/ndis/ntoskrnl_var.h#3 edit
.. //depot/projects/ndisusb/sys/compat/ndis/subr_ntoskrnl.c#3 edit

Differences ...

==== //depot/projects/ndisusb/sys/compat/ndis/ntoskrnl_var.h#3 (text+ko) ====

@@ -534,6 +534,11 @@
 
 #define WAITKEY_VALID		0x8000
 
+/* kthread priority  */
+#define LOW_PRIORITY		0
+#define LOW_REALTIME_PRIORITY	16
+#define HIGH_PRIORITY		31
+
 struct thread_context {
 	void			*tc_thrctx;
 	void			*tc_thrfunc;

==== //depot/projects/ndisusb/sys/compat/ndis/subr_ntoskrnl.c#3 (text+ko) ====

@@ -249,6 +249,7 @@
 static void DbgBreakPoint(void);
 static void KeBugCheckEx(uint32_t, u_long, u_long, u_long, u_long);
 static int32_t KeDelayExecutionThread(uint8_t, uint8_t, int64_t *);
+static int32_t KeSetPriorityThread(struct thread *, int32_t);
 static void dummy(void);
 
 static struct mtx ntoskrnl_dispatchlock;
@@ -4284,6 +4285,40 @@
 	return ticks * ((10000000 + hz - 1) / hz);
 }
 
+static struct thread *
+KeGetCurrentThread(void)
+{
+
+	return curthread;
+}
+
+static int32_t
+KeSetPriorityThread(td, pri)
+	struct thread	*td;
+	int32_t		pri;
+{
+	int32_t old;
+
+	if (td == NULL)
+		return LOW_REALTIME_PRIORITY;
+
+	if (td->td_priority <= PRI_MIN_KERN)
+		old = HIGH_PRIORITY;
+	else if (td->td_priority >= PRI_MAX_KERN)
+		old = LOW_PRIORITY;
+	else
+		old = LOW_REALTIME_PRIORITY;
+
+	if (pri == HIGH_PRIORITY)
+		sched_prio(td, PRI_MIN_KERN);
+	if (pri == LOW_REALTIME_PRIORITY)
+		sched_prio(td, PRI_MIN_KERN + (PRI_MAX_KERN - PRI_MIN_KERN) / 2);
+	if (pri == LOW_PRIORITY)
+		sched_prio(td, PRI_MAX_KERN);
+
+	return old;
+}
+
 static void
 dummy()
 {
@@ -4468,6 +4503,8 @@
 	IMPORT_CFUNC(KeTickCount, 0),
 	IMPORT_SFUNC(KeDelayExecutionThread, 3),
 	IMPORT_SFUNC(KeQueryInterruptTime, 0),
+	IMPORT_SFUNC(KeGetCurrentThread, 0),
+	IMPORT_SFUNC(KeSetPriorityThread, 2),
 
 	/*
 	 * This last entry is a catch-all for any function we haven't


More information about the p4-projects mailing list