bootloader - the loops - warm processor

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
pcmattman
Member
Member
Posts: 2566
Joined: Sun Jan 14, 2007 9:15 pm
Libera.chat IRC: miselin
Location: Sydney, Australia (I come from a land down under!)
Contact:

Re: bootloader - the loops - warm processor

Post by pcmattman »

You don't reload CS. You can do that pretty easily by adding a jmp 0x8:somelabel after loading your GDT or other segment registers.
Merdini
Member
Member
Posts: 34
Joined: Fri May 04, 2007 10:11 pm
Location: Sweden, Gothenburg

Re: bootloader - the loops - warm processor

Post by Merdini »

I think i was reloading cs.

Code: Select all

$Main:
  cli
  xor ax, ax
  mov ds, ax
  lgdt [gdt]

  mov eax, cr0
  or eax, 1
  mov cr0, eax

  jmp 08h:$PMode_32Bits
;$$

bits 32
$PMode_32Bits:
  mov ax, 16
  mov ds, ax
  mov ss, ax
  mov esp, 090000h
;$$
pcmattman
Member
Member
Posts: 2566
Joined: Sun Jan 14, 2007 9:15 pm
Libera.chat IRC: miselin
Location: Sydney, Australia (I come from a land down under!)
Contact:

Re: bootloader - the loops - warm processor

Post by pcmattman »

Yes, I see now. That was not in your previous post, which I replied to.
Merdini
Member
Member
Posts: 34
Joined: Fri May 04, 2007 10:11 pm
Location: Sweden, Gothenburg

Re: bootloader - the loops - warm processor

Post by Merdini »

Sorry, forgot to type in the actual jump.

So i can't see why i cant execute HLT.
User avatar
Andr3w
Member
Member
Posts: 76
Joined: Tue Jun 09, 2009 4:09 am
Location: Somewhere

Re: bootloader - the loops - warm processor

Post by Andr3w »

Are you loading an actual GDT or a pointer?
Merdini
Member
Member
Posts: 34
Joined: Fri May 04, 2007 10:11 pm
Location: Sweden, Gothenburg

Re: bootloader - the loops - warm processor

Post by Merdini »

An actual GDT,

Code: Select all

gdts: dq 0
dw 0FFFFh
dw 0
db 0
db 10011010b
db 11001111b
db 0
dw 0FFFFh
dw 0
db 0
db 10010010b
db 11001111b
db 0
gdte:
gdt: dw gdte - gdts - 1
dd gdts
Merdini
Member
Member
Posts: 34
Joined: Fri May 04, 2007 10:11 pm
Location: Sweden, Gothenburg

Re: bootloader - the loops - warm processor

Post by Merdini »

I've tried MikeOS and DexOS, they both have that problem!

Even when idle, they use 100% of the CPU.
Seems to me that they didn't implement a "halting" state when no query is being executed so that the CPU can rest.
pcmattman
Member
Member
Posts: 2566
Joined: Sun Jan 14, 2007 9:15 pm
Libera.chat IRC: miselin
Location: Sydney, Australia (I come from a land down under!)
Contact:

Re: bootloader - the loops - warm processor

Post by pcmattman »

I would say Windows Server 2003 uses throttling and sleep states to reduce power consumption when idle (and therefore cool it down). Most hobby OS's don't do that.

I also think your gauge of "100% CPU" is flawed. Hot or not isn't how you determine CPU usage ;)
Merdini
Member
Member
Posts: 34
Joined: Fri May 04, 2007 10:11 pm
Location: Sweden, Gothenburg

Re: bootloader - the loops - warm processor

Post by Merdini »

Thanks for you reply, what do you mean that it's flawed?
The virtual machine process, Bochs and VPC uses 100% when im running my code or when i tried MikeOS and DexOS.
When im running a code in RMode and end the code with a simple loop with HLT, the virtual machine process only uses 0-2% (when idle).
I've tried running the OSes through real hardware and not via a virtual machine, and the processor gets really hot - the exact same way when running the codes or the OSes via a virtual machine.

Not everyone has a CPU without a fan and notices the amount of heat the OS is making the CPU produce.
pcmattman
Member
Member
Posts: 2566
Joined: Sun Jan 14, 2007 9:15 pm
Libera.chat IRC: miselin
Location: Sydney, Australia (I come from a land down under!)
Contact:

Re: bootloader - the loops - warm processor

Post by pcmattman »

If the virtual machine is running at 0-2% CPU usage, that proves that your method of determining that hlt isn't working is flawed (and that it is in fact working). Just because your processor gets hot doesn't mean that it's under a full load.

Like I said before, Windows Server will put the CPU into a sleep state, or throttle it, in order to reduce power consumption and therefore reduce heat. Your OS doesn't do that.
Merdini
Member
Member
Posts: 34
Joined: Fri May 04, 2007 10:11 pm
Location: Sweden, Gothenburg

Re: bootloader - the loops - warm processor

Post by Merdini »

Okay, I understand what you mean.

So I should look at sleep states or throttle. Since my OS will just be a Web Server OS.


Thanks for you help.
User avatar
Dex
Member
Member
Posts: 1444
Joined: Fri Jan 27, 2006 12:00 am
Contact:

Re: bootloader - the loops - warm processor

Post by Dex »

Well DexOS does have hlt in the main loops, example CLI loop

Code: Select all

CheckForKey:
	call  GetCommand
	call  ProcessCmd
	hlt
	jmp   CheckForKey
Plus my getkeypress function have it in.
Merdini
Member
Member
Posts: 34
Joined: Fri May 04, 2007 10:11 pm
Location: Sweden, Gothenburg

Re: bootloader - the loops - warm processor

Post by Merdini »

Great that you could answer Dex.

Your OS is great for "HTPC-Like" computers. But without some kind of power management, the CPU gets really hot. (If there is no fan).
Most PII and PIII computers i have doesn't have/need a fan because of the huge heatsink.

Have you tried your OS with a old CPU without a fan?
User avatar
Dex
Member
Member
Posts: 1444
Joined: Fri Jan 27, 2006 12:00 am
Contact:

Re: bootloader - the loops - warm processor

Post by Dex »

Kurdistan wrote:Have you tried your OS with a old CPU without a fan?
Sure, i have run it as a server on this old PC
http://www.youtube.com/watch?v=ErPDIG8HQno

For 2 weeks or more, without a problem, but i will look into it, to see what i can do about it, thanks.
Post Reply