Re: Infinite Loop in Kernel

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

 



On Mon, Apr 13, 2009 at 9:04 PM, Bill Jones <bfjones77@xxxxxxxxx> wrote:
> I created some code in the kernel that loops until some condition becomes
> true, i.e.
> while(!condition) { //do nothing}
>
> Now, in userspace, I created a bunch of threads using pthreads, some of
> which will change that condition to be true (by making a system call that
> will change its value in the kernel). However, when I run this code, my
> entire computer freezes up and continues to loop to infinity.
>
> This does not fit my understanding of how userspace->kernel threads and the
> scheduler works (I am using 2.6.28 kernel). I was under the impression that
> when I created a userspace thread using pthreads, the kernel would
> implicitly create a kernel thread for each of these.

Not kernel threads precisely.

> Now, the scheduler will
> eventually context switch out the kernel thread when its time quanta runs
> out, so there should never be the possibility for this loop to sit on the
> CPU forever and not allow anything else to run.

You put the process in infinite loop, it will sit there hogging the CPU.
As Mulyadi has correctly pointed out, if your kernel is non-pre
emptive you will see an almost hung system.
If it is pre emptive system you may still see some interactivity but
still you ll see repurcussions.

Can you post your code for others to analyse?
>
> What part of my reasoning above is flawed?
>
>



-- 
Pradeep

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at 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