Hi,
1) changing to msleep_interruptible() did not change the situation.
2) What is strange is that I *do* see the printk messages
of kernel_init/kernel_exit, but I do not see the printk messages
in the thread function, thread_function() (also before the first
mslee()/msleep_interruptible() ).
And they are the same printk level; I also tried with
 printk(KERN_ERR..
in the thread_function(), but it did not help.

Any ideas what can be the problem ?

I will really appreciate if somebody will try to create a kernel
thread and add printk inside the kernel method and look if
it does print anything,

Rgs,
Kevin



On Tue, Feb 19, 2013 at 1:38 PM, Srivatsa S. Bhat
<srivatsa.b...@linux.vnet.ibm.com> wrote:
> On 02/19/2013 05:02 PM, Kevin Wilson wrote:
>> Hi,
>>
>> Thanks about the info about ps.
>> This raises two new questions:
>> 1)  The following code is a very basic kernel module (based on my
>> previous code, removing somethings).
>> I do not understand something:
>> I call
>>   /* sleep for a millisecond */
>>     msleep(1);
>>     printk("calling do_exit\n");
>>     msleep(60000);
>>
>> In my understanding, after 1 millisecond, it should have been
>> available to the scheduler, and after returning to the line after
>> msleep(1), it should print "calling do_exit". However,
>> I see no such log message. Any ideas why ? can something be
>> added to enable this ?
>>
>
> Are you sure your settings related to logging are fine? IOW, is this
> the only print you are not seeing, or are you not seeing *any*
> printk messages?
>
>> 2)How can I create a kernel thread so that it will be in
>> TASK_INTERRUPTIBLE state ? there must be a way,
>> since I see many kernel threads where ps shows "S" in the
>> status coumn.
>>
>
> Try using msleep_interruptible().
>
> Regards,
> Srivatsa S. Bhat
>
>>
>> struct task_struct *task;
>>
>> int thread_function(void *data)
>> {
>>     int exit_sig = SIGKILL;
>>
>>     printk("in %s\n",__func__);
>>     /* sleep for a millisecond */
>>     msleep(1);
>>     printk("calling do_exit\n");
>>     msleep(60000);
>>     do_exit(exit_sig);
>>
>>     return 0;
>> }
>>
>> static int kernel_init(void)
>>     {
>>     printk("in kernel_init\n");
>>     task = kthread_create(thread_function,NULL,"MY_KERNEL_THREAD");
>>     return 0;
>> }
>>
>> static void kernel_exit(void)
>>     {
>>     printk("in kernel_exit\n");
>>     kthread_stop(task);
>>     }
>>
>>
>> module_init(kernel_init);
>> module_exit(kernel_exit);
>>
>>
>> rgs
>> Kevin
>>
>

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

Reply via email to