Commit ccf9e28a authored by 张雪芹's avatar 张雪芹
Browse files

add oscourse shiyan3 task1 pid

parent ce77658a
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -3,18 +3,19 @@
#include <linux/kthread.h> 
#include <linux/delay.h> 

static struct task_struct *thr = NULL;
static int demo_thr(void *data)
{
    while(!kthread_should_stop())
    {
         printk(KERN_ALERT"Name:Stu No.\n");
		 printk(KERN_ALERT"New thread is  running!\n");
         printk(KERN_ALERT"pid is  %d\n",thr->pid);
         msleep(9000);      
     }
    return 0;
}

static struct task_struct *thr = NULL;
static int __init kthread_init(void)
{
 
@@ -23,7 +24,7 @@ static int __init kthread_init(void)
    thr = kthread_run(demo_thr,NULL,"kthread-demo");
    if(!thr)
    {
         printk(KERN_ALERT"kthread_run fail\n");
         printk(KERN_ERR"kthread_run fail\n");
         return -1;
    }
	return 0;