Re: Will kernel thread run out of time slice?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 4/23/06, Mulyadi Santosa <mulyadi.santosa@xxxxxxxxx> wrote:
> 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
>

Hi Min-Hua,

Can you please pasteyour experimental code once again and the results
you are finding.

> >  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();
> >

See with CONFIG_PREEMPT on, your kernel should be preemtable that
means processor should be given to other process when timeslice
expires. But for this process should not hold any lock. As when
spinlocks are help by code, actually we disable the preemption till
the time we do not release spinlock. So code inbetween spin_lock() and
spin_unlock() is not preemptable.

Please so post your experimental code once again.

Gaurav


> >  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/
>
>


--
--
-Gaurav
Email: gauravd.chd@xxxxxxxxx
---------------------------------
Read my blog at: http://lkdp.blogspot.com/
---------------------------------

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/



[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux