-#include <linux/config.h>
#include <linux/version.h>
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,17))
+#include <linux/config.h>
+#endif
#if defined(MODVERSIONS)
#include <linux/modversions.h>
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,40))
#include <linux/tqueue.h>
#else
- #include <linux/devfs_fs_kernel.h>
+ #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,17))
+ #include <linux/devfs_fs_kernel.h>
+ #endif
#endif
#include <linux/wait.h>
#include <linux/signal.h>
#include <linux/interrupt.h>
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27))
+ #include <asm/semaphore.h>
+#else
+ #include <linux/semaphore.h>
+#endif
-#include <asm/semaphore.h>
-#include <linux/smp_lock.h>
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,38))
+ #include <linux/smp_lock.h>
+#endif
#include "../include/kthread.h"
in the down operation below until the thread has reached
the up() operation.
*/
- init_MUTEX_LOCKED(&kthread->startstop_sem);
+ sema_init(&kthread->startstop_sem, 0);
/* store the function to be executed in the data passed to
the launcher */
will unlock it. As soon as we see the semaphore
unlocked, we know that the thread has exited.
*/
- init_MUTEX_LOCKED(&kthread->startstop_sem);
+ sema_init(&kthread->startstop_sem,0);
/* We need to do a memory barrier here to be sure that
- the flags are visible on all CPUs.
+ the flags are visible on all CPUs.
*/
mb();
kthread->terminate = 1;
/* We need to do a memory barrier here to be sure that
- the flags are visible on all CPUs.
+ the flags are visible on all CPUs.
*/
mb();
+#warning The local code for kernel thread support is not more needed for recent 2.6 kernels
+#warning and code should be modified to emulate same interface for older kernels
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20))
kill_proc(kthread->thread->pid, SIGKILL, 1);
+#else /* >= 2,6,20 */
+ send_sig(SIGKILL, kthread->thread, 1);
+#endif /* >= 2,6,20 */
/* block till thread terminated */
down(&kthread->startstop_sem);
/* now we are sure the thread is in zombie state. We
notify keventd to clean the process up.
*/
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20))
kill_proc(2, SIGCHLD, 1);
+#endif /* >= 2,6,20 */
}