#include <stdarg.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/sched.h>
#include <linux/tty.h>
#include <linux/kthread.h>
#include <linux/kmod.h>
#include <stdarg.h>
int print_string(char *fmt, ...)
{
struct tty_struct *current_tty = current->signal->tty;
char buf[200] = {0};
va_list va_str;
va_start(va_str,fmt);
vsprintf(buf,fmt,va_str);
va_end(va_str);
current_tty->ops->write(current_tty,buf,strlen(buf));
current_tty->ops->write(current_tty,"/012/015",2);
}
int
thread3 (int i)
{
printk ("this is thread 3/n");
print_string ("string this is thread 3/n");
return 1;
}
int
thread2 (int i)
{
kernel_thread (thread3, 4, 0);
printk ("this is thread 2/n");
print_string ("string this is thread 2/n");
}
int
thread1 (int i)
{
kernel_thread (thread2, 4, 0);
printk ("this is thread 1/n");
print_string ("string this is thread 1/n");
}
static int mod_int()
{
int i = 0;
kernel_thread(thread1,4,0);
printk("module insert/n");
return 0;
}
void mod_exit()
{
printk("module exit/n");
}
module_init(mod_int);
module_exit(mod_exit);