Hi... > I found that the kernel is preemptible and context switch happened. Hm..ok... > but printk() always print wrong msg, > ex > this is thread 1, loop 1 > this is thread 1, loop 2 > this is thread 2, loop 2000 "loop"? you print "loop"? I didn't see it in your code..CMIIW > I don't know if printk has a buffer and will overflow in this situation. > I used spinlock for this: > > spin_lock(); > printk("this is process %d\n",current->pid); > spin_unlock(); > > and everything looks fine. hm, strange...what is the relation between printk(), pid and spin lock.... let's do it a bit different, how about this? pid_t mypid; mypid = current->pid; printk("this is process %d\n",mypid); does it work? > without spin lock, something goes wrong, It looks someone disable > interrupt and I tried to enable interrupt but it didn't work. again....very strange. Your kernel thread PID should be static, right? regards Mulyadi -- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/