Re: How does cpu_idle() work?

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

 



hi all and thx Rik,

I can't understand exactly how cpu gets "stuck"...

I am wondering about what happens after the "hlt" instruction being
executed, do all registers still keep their values ? does program counter
stopped too ? or the power was shut just like I turn it off ? is there
anything running stealthily ?

the other question is, what is __builtin_constant_p()  called by test_bit()?
I can't even find it in the kernel codes.

here are the test_bit macro:

#define test_bit(nr,addr) \
(__builtin_constant_p(nr) ? \
 constant_test_bit((nr),(addr)) : \
 variable_test_bit((nr),(addr)))

thx a lot ~~



----- Original Message ----- 
From: "Rik van Riel" <riel@xxxxxxxxxxx>
To: "P.F. Tsai" <yeltek@xxxxxxxxx>
Cc: <kernelnewbies@xxxxxxxxxxxx>
Sent: Thursday, April 21, 2005 11:06 AM
Subject: Re: How does cpu_idle() work?


> On Tue, 19 Apr 2005, P.F. Tsai wrote:
>
> > 1, how does need_resched() work? I dont understand how the test_bit()
> > called inside is doing
>
> The bit can get set from interrupt context.  All test_bit() does
> is test if the bit is set.
>
> > 2, how does default_idle work? what does it do? what does halt mean?
>
> Halt basically tells the CPU to do nothing until something happens,
> eg. an interrupt.  This makes the CPU consume less power, yields the
> hyperthread's resources to the other thread, etc...
>
> > 3, if once the cpu goes into idle with the while(1)-loop, will it be
very
> > busy (100% cpu utility) with looping around ??
>
> Kind-of - if the cpu supports halt, it'll actually get "stuck"
> in that instruction until an interrupt happens.
>
> > thx for helping....
>
> Success with your homework ;)
>
> -- 
> "Debugging is twice as hard as writing the code in the first place.
> Therefore, if you write the code as cleverly as possible, you are,
> by definition, not smart enough to debug it." - Brian W. Kernighan


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