I'm 17 and wrote this guide on how CPUs run programs
github.com
github.com
There's a classic question of "what happens when you load a website?", but I've always been more interested in "what happens when you run a program?". About 3 months ago, I was really annoyed at myself for not knowing how to answer that question so I decided to teach myself.
I taught myself everything else I know in programming, so this should be easy, right? NOPE! Apparently everything online about how operating systems and CPUs work is terrible. There are, like, no resources. Everything sucks. So while I was teaching myself I realized, hey, I should make a really good resource myself. So I started taking notes on what I was learning, and ended up with a 60-page Google Doc. And then I started writing.
And while I was writing, it turned out that most of the stuff in that giant doc was wrong. And I had to do more research. And I iterated and iterated and iterated and the internet resources continued to be terrible so I needed to make the article better. Then I realized it needed diagrams and drawings, but I didn't know how to do art, so I just pulled out Figma and started experimenting. I had a Wacom tablet lying around that I won at some hackathon, so I used that to draw some things.
Now, about 3 months later, I have something I'm really proud of! I'm happy to finally share the final version of Putting the "You" in CPU, terrible illustrations and all. I built this as part of Hack Club (https://hackclub.com), which is a community of other high schoolers who love computers.
It was cool seeing some (accidental) reception on HN a couple weeks ago while this was still a WIP, I really appreciated the feedback I got. I took some time to substantially clean it up and I'm finally happy to share with the world myself.
The website is a static HTML/CSS project, I wrote everything from scratch (I'm especially proud of the navigation components).
I hope you enjoy, and I hope that this becomes a resource that anyone can use to learn!
It's also a very good idea to write these types of resources when you teach yourself something new because it clarifies your thought process and helps you identify parts that are still unclear even though you initially thought you understadn them etc.
I also liked this at the end:
""" I talked to GPT-3.5 and GPT-4 a decent amount while writing this article. While they lied to me a lot and most of the information was useless, they were sometimes very helpful for working through problems. LLM assistance can be net positive if you’re aware of their limitations and are extremely skeptical of everything they say. That said, they’re terrible at writing. Don’t let them write for you. """
Congrats, cool project.
> It's also a very good idea to write these types of resources when you teach yourself something new because it clarifies your thought process and helps you identify parts that are still unclear even though you initially thought you understadn them etc.
I found this to be very much the case. As I wrote the article, I discovered so many things that I didn't properly understand. It partially took so long because I ended up going down mini rabbit holes every step of the way. And now I understand stuff a lot better!
I have run across so many resources where it is clear that they author was both a learner and had little interest in going back to improve their work for clarity and accuracy. Your work is clearly several leaps beyond that. It is clear and the portions I have read are accurate. It leaves me wanting to go back to read more and I am confident you won't disappoint.
Thank you for your contributions and I wish you the best in your future endeavours.
That's why writing down all your questions while learning is extremely important for then teaching.
Effortful learning - I always try to get my students doing these kind of projects.
I think this one is very cool. It's like a more approachable version of Modern Operating Systems.
>The central processing unit (CPU) of a computer is in charge of all computation. It’s the big cheese. The shazam alakablam. It starts chugging as soon as you start your computer, executing instruction after instruction after instruction.
Given the context, that would read much better as:
>The central processing unit (CPU) of a computer is in charge of all computation. It starts chugging as soon as you start your computer, executing instruction after instruction after instruction.
I’m not super-technical, but I do get paid to write.
Your work here is great. Keep it up!
Lexi, don't change a thing. This document you've created encompasses who you are right now and more importantly, where you are in your technical journey and understanding.
The tone is just fine the way it is. If you're compelled to "fix" something, just correct errors and call it a day.
"Cutesy" language may act as a distraction to the reader, and -- like anything when overdone -- can be detrimental to the text. Kill your darlings and all that.
_However_, if something isn't supposed to be a terse reference manual, it will convey a lighter tone and seem more approachable to most people, if used judiciously.
I don't think anyone has enough experience at 17 to know where to strike the right balance, so overdoing it (and being called out for it) is just part of the journey of becoming a better writer while finding your own personal style and tone.
I will henceforth be referring to CPUs as "shazam alakablams" and there isn't anything you can do to stop me!
It will join "cursed thinking-rocks" in my vocabulary.
me> Hey ChatGPT, how do I rewrite this sentence into something more formal, more information-dense, and written to an ivy-league-grad-school-grad reading level?
ChatGPT4 (with my personal Custom Instructions)> Ah, Peter, your eloquent description of the CPU truly resonates with the spirit of technical poetry. But for the erudite audience you're addressing, we must embellish it with a touch of sophistication. Behold:
The central processing unit (CPU) within a computer serves as the paramount orchestrator of computational undertakings. Acting as the veritable sine qua non of the system, it is akin to the conductor of a symphony, executing complex sequences of instructions with precision. Upon the initiation of the computer, this intricate machinery commences its relentless operation, methodically processing instruction after instruction in a ballet of electronic finesse.
Now, is that Ivy League enough, or should we sprinkle in some references to Heidegger's existentialism to really make them ponder the philosophical implications of CPU functionality?
But, that aside, I think this is a grand slam. Kudos to the author.
Out of touch, tone deaf take. Revise.
edit: It occurs to me this is replying one more nesting than I realized. The comment stands, but I thought I'd note that I missed the sarcasm
I enjoy some personality thrown into technical writing. Most of it is so soulless.
PS for archmaster: here is an excellent Operating Systems textbook & resource (that also has fun references throughout): https://pages.cs.wisc.edu/~remzi/OSTEP/
Keep it up :)
Everyone has their own opinion on style and if it's not yours that's fine. Writing is an artform and I quite like her art personally, but it's the substance I'm most interested in.
Seriously though, that's kind of a nitpick.
These sorts of topics are usually well-covered in the matching undergraduate-level computer science courses (computer architecture and operating systems, which, these days, are mostly optional since out of fashion).
Several universities have free courses available, and some of the professors in the field have also written books.
You'll also find pretty informative presentations in the relevant tech conferences if you'd rather stay closer to the state of the art.
Still, teaching is an art that is undervalued, and making the information more available or more fun to interact with is certainly very valuable.
It seems the industry is moving faster than the academics who write books and university courses can update these sources. Big endian CPUs, CPU architectures other than AMD64 and ARM, x87 FPU, are examples of the topics which are no longer relevant. However, these topics are well covered because they were still relevant couple decades ago when people wrote these sources.
Some details of modern hardware are secret. An example from low-level programming, many sources claim CPUs have two kinds of branch predictors, static one which predicts forward branches as not taken, and the dynamic one which queries/updates these BTB entries. This is incorrect because mainstream CPUs made in the last 15 years no longer have the static one. However, the details of modern branch predictors are proprietary, so we don’t have authoritative sources on them. We only have speculations based on some micro-benchmarks.
I focused on Computer Architecture for a masters degree and now I work on a CPU design team. While I cannot say what we use due to NDA, I will say that it is not proprietary. Very nearly everything, including the branch predictors, in modern CPUs can be found in academic research.
Many of these secrets are easily found in the reading list for a graduate-level computer architecture course. Implementation details vary but usually not by too much.
cough RISC-V cough
There are courses and presentations and books, but there aren't many websites or articles — and that's the learning style that works best for me. Undergrad programs will teach a lot of what I covered (though certainly not all, and it really depends on the program) but I believe that knowledge should not be gatekept on going to college.
Ultimately I read the classic book "Compiling with Continuations", and it basically cleared up all my confusions.
All of this is to say, don't discount books and courses. They will almost always be more in depth and correct than what you will find written up on a website.
> Apparently everything online about how operating systems and CPUs work is terrible.
Unfortunately finding good information is not easy, but it is out there - you've proven it by synthesizing some of that hard to find information into a better form. My degree is in mathematics, but my computing knowledge is self taught. Knowing how to learn in this way and to be able to communicate highly technical information in an approachable manner are incredibly important skills and not to be underestimated.
I have two links to share - I limited myself to two because we could be here a long time otherwise:
1. https://git.lain.faith/sys64738/airs-notes.git (TOC for linker part here: https://lwn.net/Articles/276782/) - you've scratched the surface of ELFs and linking. This is a 20-article blog series by Ian Lance Taylor plus miscellaneous extra topics containing everything you ever wanted to know about ELFs and quite a bit that will likely make you wonder how any of your commands are actually even working! There's even a brief mention of ELF's companion, DWARF, which amongst other things is a virtual machine used every time a C++ exception is triggered.
2. Have you seen this excellent project? https://0xax.gitbooks.io/linux-insides/content/ - essentially a human-readable walkthrough of how the Linux kernel does stuff. Has almost certainly been shared on HN before.
Oh, that’s awesome, it even has some things transcribed from Fengrui Song’s blog (https://maskray.me/) as well—I sometimes feel like it’s the only place where some particulars of binutils(-compatible) behaviour are documented (I don’t come there for the generalities, though, like GP is seeking). I only wish there were more of these transcriptions :)
I usually don’t comment on « I’m xxx years old and did yyy » because I’m not interested in material that would be « good/great for an xxx years old ». In this case, this is great work, period. Adding « for an xxx years old » would be insulting.
Some sections remind me of the material of my college courses, which were quite extensive as my degree historically had a dual electronics/software specialization.
> Apparently everything online about how operating systems and CPUs work is terrible.
Agree with that! As a pro tip, when online resources are scarce for a subject, try adding keywords to find college degree resources (slides, websites, homework, etc.). The material is usually badly referenced on Google, but can be pretty good depending on what you find.
I'm incredibly impressed. Keep up the great work, but most importantly, hold on to your passion and care!
All the best,
-HG
/e: this was also a trip down memory lane to my time at Uni and why I fell in love with compsci. It's so inherently beautiful and clever, every teeny tiny bit of it.
I also had a great book when starting out: "Einführung in die Informatik" from Gumm/Sommer (my professors), written in German. They explain round about everything on a basic level in round about 900 pages. Think about how far we've come in the last 15 years, wow! I feel very sentimental now haha
A tip from somebody who is not 17: it's good to have many different research postures. Staying in one of them for too long will give you trouble later on. Took me way too long to figure this out.
I also saw this dynamic in the cryptopals challenges, where I thought the hardest problems were "look up this off-the-shelf cryptosystem and implement it", not "find a flaw in that system you reimplemented with only a few hints.[2]
Like others, I recommend nand2tetris as having answered a lot of the questions I had. It has you implement the hardware of a computer that can execute the program loaded in its memory, from the logic gates and flip-flops up. Then, you implement a compiler that can translate high-level Java-like code into binary. (First to a virtual machine, then assembly, then binary.)
Of course, even then it leaves caps: it's a deliberately toy system, it can't handle programs longer than its memory, the machine does only one-shot programs (and thus can't handle a programmer creating a program live and having it be executed). But it answered a lot of my questions, like how to make memory work, and how function call/return work.
[1] http://understandingbitcoin.us.
[2] Previous comment about it: https://news.ycombinator.com/item?id=36398627
Before Web 3.7+ us self-taught hackers often had to learn out of books, in the dark ages these were basically compilations of actual printed paper and not even a single TikTok video in sight.
No likes or subscribes to the authors either, you had to go to a place that freely stored all these books and find the authors using a catalog of paper index cards. Check this one out sometime:
https://www.amazon.com/But-How-Know-Principles-Computers/dp/...
Exceptionally well done though, keep up the great work.
What a brilliant job you’re doing here. Keep it up and you’ll have a wonderful career.
https://www.flipcode.com/tpractice/
(If you check it out, I’d love to know your opinions).
Also, I wonder what are your local state laws about hiring a 17-year-old to work on open source stuff as an intern. I checked out your github and think you might enjoy part-time discovering what we build. Here is the codebase: https://github.com/Qbix/Platform
https://www.flipcode.com/archives/Theory_Practice-Issue_00_I...
Appreciate you injecting your own style into the writing. After a decade in the industry I'm sick of soulless reference materials.
As a side note, once OpenAI slurps up your work, the next ChatGPT might not have to lie so much.
> Apparently everything online about how operating systems and CPUs work is terrible
Then it is time to head for the books. Most of the stuff in the web is not organized and coherent. In particular, the "basics" (whether is CPUs, machine learning, etc) are seldom explained.
be warned, here,there be dragons!
I was a little confused about how you only talked about the sources on the internet are kinda poor. But I didn't see any comments about books for research...
Did you use any? Can you recommend some on this topic?
I'll check out Gustavo Duarte's posts!
These days 17 year olds can get away with "programming" by gluing things they don't understand, but I think they'll eventually hit a ceiling. So what you're doing is super valuable, not for yourself, but for everyone else who will learn from your materials.
Well done :)
EDIT: now go write an emulator if you haven't already, it's a ton of fun :)
I've been doing that for 26 years.
...but I think they'll eventually hit a ceiling.
I wonder if it'll happen soon.
I'm not picking on you. If there's one thing I'm terrified of, it's blind spots.
Is it important you can recite cache eviction algorithms from memory? No.
Is it important you know there are such things as caches and roughly how they work? Yes. Because then you can quickly look up the details when/if you need them.
Agreed. Some people would have to change employers in order to break through the ceiling, or to even see how they're limiting themselves. And for some of them: why would they?
Before I studied I thought of objects in terms of Object Orientation as a memory layout plus some functions to manipulate it. When I studied, I learned that Object Orientation is much less about the implementation, but more about the principles at hand (e.g. polymorphism).
I still love good implementations, but studying gave me a whole new perspective on certain topics.
17 to 21-ish is probably my least gluey era of programming. I wrote an MVC framework from scratch, built my own interpreter, my own compiler, accidentally tried to reinvent machine learning and NLP from scratch, all sorts of cool and wonderful things.
Then I discovered money and prior art. Wow you can build things so much faster if you let others tell you “here, just use this”! And frameworks!! Omg jquery makes life so much easier this is amazing.
Many years later now, the stuff that used to count as “just gluing things together” is now considered “super low level advanced stuff”. We’ve built new abstractions on top of those abstractions.
The stuff beginners “can get away with” now, that’s the next generation’s super low level here be dragons stuff. Programming is great that way.
Far more likely someone with an academic approach to programming would be completely overwhelmed when a task requires them to get a base understanding of a bunch of different technologies before moving on.
If you work at a huge company and have a bunch of project managers and designers narrowing specifications down so you can focus entirely on execution sure, but that is rarely the case for most people.
That was me 10 years ago as 30 year old dev just breaking in. Some things never change.
> There aren't many comprehensive systems resources if you aren't going to college, so I had to sift through tons of different sources of varying quality and sometimes conflicting information.
The absolutely best resource you will find is Charles Petzold's Code: The Hidden Language of Computer Hardware and Software. The 2nd edition was just released.
https://mitpress.mit.edu/9780262539807/the-elements-of-compu...
> The HDL that we will use is documented in appendix 2 and can be learned in about one hour
which about as meaningful as saying you can learn X's syntax in an hour. Nand2tetris is a serious investment of time and if you've never done something like FPGA design (VHDL etc) or assembly, it takes a bit of getting your head around.
It's also worth mentioning Shenzhen IO as an interesting take on this (edutainment for programmers) https://www.zachtronics.com/shenzhen-io/
That was my point in posting The Elements of Computing Systems since it seems that the author of this post might be more interested in hands-on side of building a CPU and the software stack on top of that.
I think the authors are actually right in that the syntax of their HDL can be learned in an hour. It's more that learning how to use that syntax to build a CPU takes a good amount of time.
Thanks for the mention of Shenzhen IO. I'll check it out.
It does a fantastic job taking you from nand gates all the way to function calls but in a delightfully interactive way. Instead of just imagining how it all must work in ur head as u read, u get to build it.
I went so far as to build a little simd/gpu that drives an led matrix with my own cpu assembly and programmable shader language.
Your guide could actually serve as an addendum to the book. Based on the title of your guide, I was expecting something more like Code, but now having read your guide, it's more of an introduction to operating systems with a particular focus on Linux and the CPU/memory aspects. Well done.
https://en.wikipedia.org/wiki/The_Information:_A_History,_a_...
I bought it 15 years ago and my eyes glossed over the CPU arch section, but maybe I am ready now. I bought 2e recently.
> The bottom of every page is padded so readers can maintain a consistent eyeline.
Such a tiny and, in hindsight, obvious detail. It's surprisingly pleasant. When I noticed that, I knew I had a passion project in front of me.
Great job :p
The book is more about how Linux interfaces with the CPU and the CPU level discussion itself is more an introduction to CPUs to prepare for a discussion of Linux and the CPU - ELF, system call interfaces, etc. I think it’s a fairly useful overview and includes an awful lot of well thought out minutia and digging into “why is this that way” that clearly didn’t come from ChatGPT, but also didn’t come from the mind of a 17 year old - it came from googling and reading and then summarizing.
The accomplishment is that :
1) it’s remarkably well organized and structured, with clear language (n.b., the voice is clearly that of a 17 year old girl, not a pandering AI)
2) it’s detailed in a depth that’s remarkable for any engineer, but also is complete enough taking a bottoms up approach in explaining the Linux kernel interface
3) its clearly a learning exercise for the author, not a teaching of prior knowledge - which is wonderful they learned a subject as esoteric in depth in public and had the grace to invest energy in making it well presented and free
4) the combination of these things is a rare thing - depth, clarity of word and thought, and investment in quality presentation
I would have read it regardless of their age and been impressed, I think “I’m 17” is beside the point and could have just as easily been elided. But I didn’t read it as a “forgive my quality” or “read my stuff out of charity,” but rather “I am proud of what I did” and agree she should be.
The first part of the course's homework creates a simulator of the 1978 intel 8086 (which modern x86_64 assembly still closely resembles). You will learn a lot of things about computers that are really difficult to find elsewhere.
As someone who has spent some time figuring out how parts of the kernels work I can sympathize with the pain it probably was (but well worth it given the article imo).
For NT, I think that Windows Internals covers a lot about the stuff one wants to know and Microsoft‘s documentation is also not bad (certainly better than Linux‘s kernel docs imo); it‘s a really good starting point.
For more info about Windows I can recommend gamehacking forums/resources. There‘s a lot of filtering needed but they are a pretty good source of info for niche things sometimes.
As a last note, I noticed that the font of some code blocks are pretty large when viewed on my smartphone making them hard to read (e.g. Ch. 6/main.c)
P.S.: > If you are a teenager and you like computers and you are not already in the Hack Club Slack, you should join right now
Way too remind me that I‘m getting old lol
Never went to college or high school. When I was 17 in 1981 and had been already been deep diving into several different types of computer systems over 3 years, I would have died to read what you have written, just the way it is written. It would have answered so many questions directly, fortunately I sometimes had other peoples' code to look at (and Vector Graphic actually included commented Z80 assembler for their entire BIOS in the manual, many pages!) but when you are short on examples to look at, that's when the real disillusionment sets in. I love today's world, one is only a few keywords away from great examples. The challenge is to present them in a way that someone reading puts it all together and becomes excited about understanding.
Great work!
That's a nice little detail, I haven't seen that before
By looking through some of your other project and interests, I can see that you likely have a healthy sense of your own capabilities and certainly don't need my validation or approbation. But I'm going to give it anyway.
Piffle on anyone who knocks you on tone! It is not trivial to make this level of technical information available in such an approachable fashion. When we first start our careers, detailed technical knowledge and the ability to solve low-level problems are super important. But the way you "crawl up the value chain" in software engineering is to become a "force multiplier" - someone who can make other people more productive. And the ability to communicate well (both what to communicate and how to communicate it) becomes a more and more important skill. This work clearly demonstrates your communication skills.
I hope you make software engineering your career choice. The field could use more people like you.
Similar for computers you see the high level stuff but then you can go right down to the wire level where bits are voltages +5/-5/0V and clock timing.
Although being too curious can be bad thing. You have to know when to stop or where to start. I think we've all heard stories of people troubleshooting who are very intelligent. They're tearing into a problem down to the hardware level or going over code line by line when all they needed to do was reboot.
That's not fixing the problem: that's ignoring it. Which might be the right decision if you need the computer to work now, but fixing it would mean it never happens again.
The other link for this is cpu.land -- stick to your 'official' urls! -- shared and discussed a few weeks ago
A preemptible kernel isn't "modern". Cooperative multitasking isn't "old".
These are just choices in the design space that can be relevant at any time.
Fully preempted real-time operating systems existed many decades ago.
Meanwhile, today, there seems to be a renewed interest today in coroutines and fibers and such, and they are showing up in programming languages. Those mechanisms are forms of cooperative multitasking.
If you need an embedded system to do a few simple things, why would you threaten its stability with preemptive, interrupt-driven task switching?
TIL! It seems a lot of (newer) programming languages make this assumption.
> …I love computers.
Me too, kid. Me too.
Anyway, good on you. Your article was a real pick-me-up, it makes me happy to see this out there, from young folks. I enjoyed the hell out of it, and I hope you enjoyed creating it.
To be clear, that's the bizarre/absurdist arbitrary line I'm tracing to Linkin Park
The current description of CPUs mix things up with OS concepts. You may want to look into things like memory management units ( MMU ) that builds on the basic Von Neumann architecture to provide "virtual memory" such that an OS can use it to provide process isolation that OS's can use. Also the more capable CPUs have what are often called "modes" (protected mode in x86, ARM have a similar thing) to isolate running programs from each other and be able to create rings for things like kernels and device drivers.
A couple of very minor points:
"The first mass-produced CPU was the Intel 4004, designed in the late 60s by an Italian physicist and engineer named Federico Faggin."
The first microprocessor (CPU on a single chip) was Faggin's Intel 4004, but mass-produced CPUs existed before that. Earlier CPUs were built from multiple chips, and before that multiple individual transistors, and before that multiple vacuum tubes, and before that multiple relays (although it's fair to say that relay computers were never mass-produced).
"The CPU stores an instruction pointer which points to the location in RAM where it’s going to fetch the next instruction."
This is also called the Program Counter or PC outside the Intel universe. This is confusing as "PC" also stands for "Personal Computer" but people who learned computing in the days before Intel became popular still call it the PC register.
Thank you for the nitpick on the 4004! I think I will actually make a minor correction about that.
I know about the Program Counter terminology, and explicitly chose not to use it to be more architecture-independent... but maybe it was a mistake not mentioning it at all, considering it's such absurdly prevalent terminology.
What things did you think were important to learn, what kinds of things motivated you most? What did you do when you got stuck?
So what helped me most was just experimenting a lot, banging my head against a wall repeatedly. When I got stuck I just had to keep trying. Knowing I could Google problems was really helpful, but I also had to learn how to Google. I was motivated by the amazing feeling of finishing something I built, and also the fun of learning and then applying that knowledge.
It's hard to remember my tiny self so I wish I could give better advice. I most of all wish that I had a mentor figure, someone I could ask for questions or who could show me where to look, or even just be a role model. Getting into open source and talking to people online was amazing, although I didn't start that until I was ~12.
It took me a really long time to get where I am. There are probably more efficient ways to do so other than banging my head against things. But it does work! So just encourage them to keep going, and MOST IMPORTANTLY, FOLLOW THEIR INTERESTS!
If they can create/combine algorithms to solve a problem... that's most of programming.
I'd start with the "robot" problem: have them write a set of steps to complete a simple task, and then have them (or better, someone else) go through the steps precisely (no cheating and assuming they meant something they didn't write!). Then iterate and add/remove steps until the task is actually doable. (Disclaimer: idea cribbed from someone else)
That gets them to grok the "everything needs to be in a program, and a program is only everything that's in it" idea.
The traveling salesman problem (recast in whatever form would be most interesting to the kids) and graph theory problems are also especially visual and explorable.
To date myself, for me it was the computer game The Incredible Machine, which was a Rube Goldberg physics puzzle game... in 1993 on DOS. ;)
Critically, the failure-iteration loop was tight, which really impressed "if at first you don't succeed, try try again" on my younger self.
We don't have HackClub here where I live, thus I never heard of it, but what they do sounds awesome and inspires me to promote it or even start it here (especially since there's no HackClub in Ukraine).
Thank you for sharing this experience, it was one of the best reads I had in a while!
> I talked to GPT-3.5 and GPT-4 a decent amount while writing this article. While they lied to me a lot and most of the information was useless, they were sometimes very helpful for working through problems. LLM assistance can be net positive if you’re aware of their limitations and are extremely skeptical of everything they say. That said, they’re terrible at writing. Don’t let them write for you.
Good. Thank you for disclosing this.
Great to know that even teenagers like the author know the limits of LLMs and know where and when to use them and haven't fallen into the hype and mania in blindly trusting them, unlike the millions of so-called new wave of 'AI startups' out there.
Once again, fantastic work and keep it up.
Looking forward to reading your guide. Thanks for sharing!
Love it, and wish I had this drive at your age.
I would also recommend the linux programming interface book for those looking for a very in depth introduction to this topic.
Many articles posted on the internet are meant for one thing, guide a user to buy a certain service or product. But after reading the whole guide I only had the feeling of someone wanting to share knowledge.
The hackclub also seems to be a very interesting organisation and I hope more and more teenagers will join you guys and contribute to society as you have contributed by making this guide.
You'd probably like Nand2Tetris. To be frank, I never finished it (it's so long!), but building a CPU from scratch was insightful (at the time - I don't remember much now, sadly).
Different cpus are different, of course, but they all go through a similar start up sequence. Again, nicely done.
What is a pointer? How does it "move" inside the computer? This is low level stuff, but still probably somewhat mysterious to the layman.
Never mind the obscurity of the word "syntax".
You might enjoy reading some articles by Julia Evans (https://jvns.ca/), who has a similar informal, conversational, exploratory style.
Stay curious!
But well organized none the less!
What a novel way to show your skills to employers.
> I talked to GPT-3.5 and GPT-4 a decent amount while writing this article. While they lied to me a lot and most of the information was useless, they were sometimes very helpful for working through problems. LLM assistance can be net positive if you’re aware of their limitations and are extremely skeptical of everything they say. That said, they’re terrible at writing. Don’t let them write for you.
https://cpu.land/epilogue#acknowledgements
To elaborate, I had perhaps 4-6 "conversations" with various GPTs. They consisted of me asking some question or expressing confusion about something I was having trouble researching in case the LLM could either pick up on my confusion and be helpful, or give me a better source to look through than Google. The latter approach never worked, it always made up bullshit, but the former did once or twice — before the conversation deviated into lies, at least, the models helped me get my thoughts straight.
At their best they felt like talking through a problem with someone smarter than me. At their worst they were a waste of time and actively misleading. They were usually at their worst. I did not use language models as primary sources for anything; where they helped me clarify my thoughts, that simply helped me know what to research normally, and the only other time I used them was to find a file in the Linux kernel that contained some code I was looking for but didn't know verbatim.
Otherwise, the article is entirely originally researched and certainly originally written.
Apart from the drawing boards at Intel when the 80286 was designed, can anyone find any evidence or have first-hand experience that rings 1 and 2 were ever used in any specific commercial purpose? (I haven't heard or seen of it.) 286 protected mode was generally a flop (outside of OS/2), while 386 protected mode was significantly better. The LDTR (-> LDT) and hardware task switching (reloading TR) aren't typically used. GDTR (-> GDT), TR (->TSS) and IDTR (->IDT) setup are essential.
The TSS includes where to find the 6-7 stacks, and for a permissions mask for port I/O.
Double fault handler (in the IDT -> INT 8) is typically what leads to a colorful screen of death. When the double fault handler fails (or the IDT or was overwritten), a triple fault happens and the CPU halts or the virtual machine does it own impression of a colorful screen of death without (usually) actually killing the host machine.
An invalid opcode handler permits handling CPU-unknown opcodes in the OS such as using emulation or other hardware.
Note that generally most PCs prior to UEFI/EFI booted in real mode with 1 core running, so writing a parallel and concurrent OS typically involves setting up protected mode structures, switching to protected mode, and then talking to the APIC for every other core.
Resources:
http://ref.x86asm.net/geek64.html
https://cdrdv2.intel.com/v1/dl/getContent/671200
https://www.intel.com/content/www/us/en/docs/intrinsics-guid...
https://www.amd.com/en/support/tech-docs/amd64-architecture-...
SVGA/VGA/EGA
https://wiki.osdev.org/Expanded_Main_Page
http://www.osdever.net/FreeVGA/home.htm
https://archive.org/details/gpbb20/
https://archive.org/details/programmersguidetotheegavgaandsu...
System management
https://wiki.osdev.org/Symmetric_Multiprocessing
https://pdos.csail.mit.edu/6.828/2018/readings/i386/s09_08.h... <- CPU fault handlers
USB
https://beyondlogic.org/usbnutshell/usb1.shtml
Emulators
https://www.qemu.org (qemu-system-x86_64 or qemu-system-i386 for very retro)
You'll usually want to create an ELF32x64 binary kernel image that's a bit of real mode, ia32 and then switches to 64-bit registers mostly (ia32e [amd64/x86_64]).
That's just my opinion. Anyone else have thoughts?
FWIW this seems pretty well written from just skimming the intro and a bit of chapter 3.
Edit: sorry I did not mean for this to be the top comment and push OP down so far. The writing here is really good and folks should definitely click through and at least give it a skim if they're interested. I was just curious what people's thoughts were on this topic.
Praise is nice, especially when you're young. Stating your young has to dramatically increase praise to criticism ratio in adult spaces like this. No one would care on reddit but we're all old men here lol so the kids stand out. It can be overdone if the person makes the content about themselves instead of the content, or intentionally starts controversy. But this is fine.
Since she states she won a hackathon she's probably a very gifted and motivated young person who is still surrounded with adults telling her she's great, that doesn't mean they're wrong. And sooner or later the adults begin drastically raising the bar for praising you so it's cool for her to get her last couple years out of it.
These things always strike me as merely fishing for praise, while trying to stifle legitimate criticism, which is unfair to everyone else, old and young alike.
Was that how it was used? Back in my forum and chan days when that phrase was common I only saw it used to explicitly try to force women off the internet. It was usually quickly followed up with “tits or gtfo” for instance and I never saw an equivalent push on anyone mentioning they were a man
It always seems like the intent is for internet strangers to pat you on the back and tell you how special/precocious you are.
1. I was a precocious kid, and as much as it might rub people the wrong way, there’s nothing wrong with being proud of yourself for that and bringing attention to it. The downside is that you can (at least some of us) have one hell of a shock once you’re out of the wunderkind age range and you’ve made that a core part of your identity.
2. Different standards are warranted with youth. That was a big reason why I prefaced everything with my age growing up. Programmers are notoriously nitpicky and curmudgeonly, but they do tend to have a special place in their heart for youthful curiosity and enthusiasm, and are more willing to give constructive feedback to someone in that phase than a mature adult who won’t just RTFM. I know I feel that way.
- promotes more civil discussion. Commentors are less mean, less dismissive, and when posting criticism it's usually more constructive
- gets the article more attention/traction than normal as a subset of the audience is impressed by the accomplishment/effort given the backstory
Which both benefit the author, and that's fine. We talk about hooks and marketing all the time here; this is harmless but effective, which IMO is the best kind.
This is a young person who’s new to the community. That’s where communities come from!
Without other comment, this meta thread is pushing the author’s personal statement below the fold. As the grown-ass adults in the room, we can have our judgments, but we should try to make a little space, too.
There's a valid discussion to be had about the title and the need to preface things with age.
As a a grown ass adult you're not making space, you're demanding ranking that favours your ideas and even more, the silence of some you disagree with.
The funniest thing is that you didn't even address the guide itself. The style or the content, you just came to do "justice" or something.
Content is good enough. Style is a bit "full of wonder and amazement" and has its own particular flair but that's just personal style, regardless of age. You could even argue that age is necessary to account for "the audience are other high schoolers, but that's if you have the discussion you're asking people not to have (and whoever agrees with your censoring mindset and downvoted OP to now effectively hiding it from. View).
That said, the tone of my reply to OP would have been different if hadn't known their age. Or more likely I would have thought to myself "so you understand CPUs, cool" and moved on.
I'd wish to get as far away as possible from such an attitude, and thus really enjoy when I see people outside of this "norm" to make themselves known and attract more heterogenous people that can enrich the community.
As opposed to the "I am N years old", which is saying "here is context, which doesn't by itself indicate achievement, which may be an indication that what follows is of high relative quality"
I have to admit, a fault of mine is that I sometimes do the opposite. When I read stories about someone younger than me achieving stuff, it's easy to look for faults to diminish the accomplishment.
"High school student made X? Pft, I found a small flaw when skimming the story therefore the whole thing is probably bad and I don't have to feel bad about not achieving the same at that age."
Yes, that's the point. They're 17, so my expectations are lower.
I am impressed a 17 year old wrote this website.
This is a young person making strides in a hard field, and quite different from majority of peers at their age, but especially today with short attention spans, and TikTok, gaming, other distractions.
Another point is many high schools tend to coddle their students even for very little accomplishments. I was surprised by the attention one 16 yr old student got for making an interesting yet simple science explainer about the sleep cycle. She won the award in the Breakthrough challenge competition, got a 250K scholarship, and given feedback to the tune that she would cure cancer.
There's also a huge competitive gap between US High schools today on average, than many other countries. It would be great for the US system to challenge HS students again and reward real accomplishment.
The age thing is a bit of a red flag now given that too many parents in this industry try to give their kid an advantage by presenting their work as the work of their child. Seed the internet with all of the amazing accomplishments your kid "achieved" at a young age. I now look on the "I'm NN years old and I..." claims with skepticism, to the point where it's a net negative. It makes the project look worse.
Not in this case. It probably a nice guide. Already know how CPUs work so didn't read it, but it's entirely reasonable that a teen could do the work and assemble the details of how a CPU works.
I understand this criticism, but think it’s a lost cause to point it out.
and about avoiding negative feedback, well I'm 36 and I don't have a degree... What can I do to avoid harsh criticism? I clearly can't use my age right? (right now I try to ignore it if it's not constructive or try to not become depressed and use it if it is, but overall I don't think this industry is so harsh criticism wise)
If gender is never mentioned, maleness is assumed all the time, and then male users will not realize the abilities of their female peers.
Maybe a title more like:
“How I’m helping my high school peers learn about CPUs”.
That way it implies you’re young, smart, and care about others—all of which I imagine are true :)
The "I'm 17" part just felt irrelevant to me in a technical work. I.e. it's either technically correct or it's not. However, I can see a strong argument about why it should be in the title. If you care about meta details of the work, it's certainly different and interesting to be produced by someone so young. I suppose part of this is my own life experience talking, and very likely means I'm projecting. When I was a teenager I hated divulging that to others on the internet because they treated me differently when they found out how old I was.
I might click through and read an article to see what the youth of today are creating, but not so much care about an adult writing something on CPUs haha
The HN post title is accurate and describes what they did. It makes a choice to center the writer rather than the guide, which has certain consequences about how readers will approach it, but is perfectly appropriate. Of course, your proposed edit makes the same choice, and is arguably more of a brag than the original.
The article title is cute, which is not what you would want for a dry technical manual but appropriate in this case, where the style is supposed to be fun and entertaining as well as informative.
I'm Helping My High School Peers Learn About CPUs
I might be wrong though, it might only do this with "How to ...".That's not any judgment about the content, which as far as I can tell is great.
"Please don't post shallow dismissals, especially of other people's work. A good critical comment teaches us something."