Live data from Hacker News

What happens when a CPU starts

lateblt.tripod.com

41–50 of 133 posts

Re: What happens when a CPU starts

#41
post #39
post #37

Earlier quoted context omitted.

writing programs for old game consoles, Oh yeah, like the Intellivision. particularly the Nintendo DS. Oh come on, the DS ain't that old.

20 years next year.

I haven't even reached 30, yet that comment of yours made me feel old.

Re: What happens when a CPU starts

#42
If anyone is interested in what happens with an older CPU, I've written up how the IBM 1401 from 1959 starts up: https://www.righto.com/2021/02/an-ibm-1401-mainframe-compute...

Among other things, since it uses magnetic core memory, you can run the program that was loaded when you shut it off.

Re: What happens when a CPU starts

#43
> This is because when the power supply is first powering up, even if it only takes a second or two, the CPU has already received "dirty" power, because the power supply was building up a steady stream of electricity. Digital logic chips like CPUs require precise voltages, and they get confused if they receive something outside their intended voltage range.

This is only partially true. When digital chips boot up, gate outputs are in an indeterminate state. The reset sets them to know initial (and valid) values/bits.

Re: What happens when a CPU starts

#44
post #40

Earlier quoted context omitted.

> But they run no OS, your program runs directly on the hardware How is threading/time scheduling/interrupt handling/context switching usually done?

I dunno about the DS, which doesn't really qualify as that old to me; it's got a pretty decent sized rom for when you don't have a cartridge in, and I'd guess the SDK gives you something approaching an OS, maybe even with a threading library. But on real old hardware, you're not going to run threads or a scheduler, you're going to run one iteration of your game loop, then wait for a sign that it's time to do your gra…

> In a typical Windows 10 installation with many background processes and services, the CPU context switching rate can vary greatly depending on the specific system's hardware configuration, running processes, and workload. However, on a typical system, the context switching rate can be anywhere from a few hundred to a few thousand times per second.

Would you agree with this statement from ChatGPT? Is the Windows kernel handling thousands of context switches and time slicing processes the way you described? pushad/pushfd + popad/popfd

Re: What happens when a CPU starts

#45
post #37
post #5

Earlier quoted context omitted.

Yeah modern hardware is crazy hard to understand and a lot is proprietary/trademark stuff like you saw on the rpi. Arduino is a good start but it's just so low level that it doesn't get you much further to understanding how a modern system works. One slightly weird but fascinating path I have been playing with is writing programs for old game consoles, particularly the Nintendo DS. You can get full and comprehensive…

writing programs for old game consoles, Oh yeah, like the Intellivision. particularly the Nintendo DS. Oh come on, the DS ain't that old.

Never done anything but I think the gameboy family is a good choice. Unlike NES or SNES which use assembly heavily, we can use C for the GBA. There are also great communities devoted for them.

Re: What happens when a CPU starts

#46
post #39

Earlier quoted context omitted.

20 years next year.

I haven't even reached 30, yet that comment of yours made me feel old.

It's probably more confusing since the DS had several iterations, first one in 2004, then the lite in 2006, DSi 2008, DSi XL 2009. And then the 3DS having mostly the same form factor probably made the design feel new for a lot longer.

Re: What happens when a CPU starts

#47
post #3

Amongst the first sentences... > It may be thought of as what happens when a whole computer starts, since the CPU is the center of the computer and the place where the action begins. I thought that too. Last year I spent a while getting as low-level as I could and trying to understand how to write a boot loader, a kernel, learn about clocks and pins and interrupts, etc. I thought, "I know, I'll get a Raspberry Pi! Th…

Would you mind sharing some of your favorite youtube videos that you've come across?

Re: What happens when a CPU starts

#48
post #40

Earlier quoted context omitted.

I dunno about the DS, which doesn't really qualify as that old to me; it's got a pretty decent sized rom for when you don't have a cartridge in, and I'd guess the SDK gives you something approaching an OS, maybe even with a threading library. But on real old hardware, you're not going to run threads or a scheduler, you're going to run one iteration of your game loop, then wait for a sign that it's time to do your gra…

> In a typical Windows 10 installation with many background processes and services, the CPU context switching rate can vary greatly depending on the specific system's hardware configuration, running processes, and workload. However, on a typical system, the context switching rate can be anywhere from a few hundred to a few thousand times per second. Would you agree with this statement from ChatGPT? Is the Windows ker…

Yeah, more or less; mostly more. pusha/pushad is one of those instructions that sounded good, but isn't used much (it became invalid in amd64), windows will push the registers one at a time, and maybe FPU, MMX, SSE, etc registers; of course, that's a lot of extra pushing, so there's strategies to avoid it if the thread doesn't use them. If you switch to a different task, you're going to need to load its page tables, and these days you've gotta flush a bunch of caches to avoid Spectre (although you shouldn't avoid the Spectre game from the 90s, that was nifty).

If you're good at Windows, you can probably get a count of context switches per second on your system, with your load. Context switches generally includes interrupts as well as calls into the kernel from userspace. A server work load is going to go up to hundreds of thousands, maybe millions per second, again depending on your load.

Re: What happens when a CPU starts

#49

"It starts at 0 and executes instructions" is a funny, but mostly true way to express this. Some people are shocked that no magic happens before the instructions start.

If older CPUs have no magic, what is the 6502 doing here (https://youtu.be/yl8vPW5hydQ?t=706) that causes it to put eb60 → ffff → eb60 → 01f7 → 01f6 → 01f5 on the address bus, before it actually reads from memory?

Re: What happens when a CPU starts

#50
post #3

Amongst the first sentences... > It may be thought of as what happens when a whole computer starts, since the CPU is the center of the computer and the place where the action begins. I thought that too. Last year I spent a while getting as low-level as I could and trying to understand how to write a boot loader, a kernel, learn about clocks and pins and interrupts, etc. I thought, "I know, I'll get a Raspberry Pi! Th…

the "whole computer" is also thought to start on the memory, because you can have memory on a computer and a manual operator of it, but you can't have a computer with an operator of it and no memory.
Post reply on HN