Re: Will kernel thread run out of time slice?

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

 



Hi...

Don't forget to CC to kernelnewbies too.... Our discussion will be 
archieved, so someone else can learn something from this in the future.

> BTW, my kernel is linux-2.4.18 with preempt patch, and these code
> runs on an ARM board.

Hm...ARM. OK, just FYI, I know nothing about ARM, all I say previously 
and now are based on x86 32 bit, so some assumptions might be wrong.

> like this:
>     532 spinlock_t my_lock = SPIN_LOCK_UNLOCKED;
>     533
>     534 void dummy_loop()
>     535 {
>     536         pid_t mypid = current->pid;
>     537         unsigned long long i;
>     538         for (i = 0; i < 1000; i++) {
>     539                 spin_lock(&my_lock);
>     540                 printk("thread %d, loop: %u "
>     541                                 ,mypid,i);
>     542                 printk("jiffies: %u, time slice: %d\n"
>     543                                 ,jiffies,current->counter);
>     544                 spin_unlock(&my_lock);
>     545         }
>     546                 printk("this is thread %d, total:
> %u\n",current->pid,i);
>     547         for (;;);
>     548 }

Hm..very strange. Somehow, if we grab spin lock, pid is printed 
consistently. And you said, you patch your kernel with preempt patch. 
This made me suspect....could this be a bug inside that preempt patch?

> I print loop number and I expect to see it prints
>
>     139 thread 11, loop: 21 jiffies: 113, time slice: 2
>     140 thread 11, loop: 22 jiffies: 113, time slice: 2
>     141 thread 11, loop: 23 jiffies: 113, time slice: 2
>     142 thread 11, loop: 24 jiffies: 114, time slice: 1
>     143 thread 11, loop: 25 jiffies: 114, time slice: 1
>     144 thread 10, loop: 20 jiffies: 115, time slice: 6
>     145 thread 10, loop: 21 jiffies: 115, time slice: 6
>     146 thread 10, loop: 22 jiffies: 116, time slice: 5

What? "loop" goes to 25 and then goes back to 20? How come? BTW, how 
many kernel thread did you make? 1? 2? More? Can you paste your entire 
code please? This guessing game isn't effective at all.


regards,

Mulyadi


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