On Mon, Apr 13, 2009 at 08:34:37AM -0700, Bill Jones wrote:
> I created some code in the kernel that loops until some condition becomes
> true, i.e.
> while(!condition) { //do nothing}
Congratulations, you just hung your kernel :)
> 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.
That's because you are not allowing the kernel to do anything while in
that loop. Only if you have a multi-processor machine do you have a
chance to do this.
> 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. 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.
>
> What part of my reasoning above is flawed?
Kernel threads need to give up the processor in order for other stuff to
be run.
good luck,
greg k-h
--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to [email protected]
Please read the FAQ at http://kernelnewbies.org/FAQ