I never really knew much about how CPUs worked until I took a class in CPU design at Cornell. Until that point I never knew about registers and cache and pipelines. Ever since then I’ve been growing in my understanding of how the CPU works and how all the parts fit together. This culminated in me building five or six computers for myself and relatives. In that past few years, these computers have been dual or quad core computers. I’ve been using a dual core computer for my Linux computer for around a year now but I didn’t really think about it too much until this weekend. I was working on a new strip for my webcomic, “I’m Not Mad” (which I do with Nothing to the Table‘s Daniel). A particular panel was taking forever to render, so I opened up the system monitor to take a look. The image was split into a bunch of squares and each square was given to a CPU core to work on. And, for basically the entire render time, both CPUs were maxed out as I expected. When it only had one square to do, one of the CPUs dropped to idle because there wasn’t anything for it to do. Nothing out of the ordinary there. But then I noticed this crazy pattern:
Even though it was only working on one square and, therefore, only needed one CPU core, it looks like it kept trading back and forth between both of the cores. Each time, the one was that wasn’t working on the square idled back to zero. (Or near zero, I had some other programs running like Pidgin – which routinely checks to update my buddy list) But why the back and forth? It’d think the CPU that was stuck with the rendering when it was all said and done would just work on it until it was done. Why the switching? If anyone knows, please let me know in the comments.
4 responses to “Interesting CPU Behavior”
I believe the CPU behavior like this has something to do with heat and duty cycle. of course, I’m completely guessing, of course, but maybe the CPU distributes the load back and forth like that between the cores
That’s an entirely probable guess. Thanks for commenting. If I come across the answer, I’ll be sure to post in the comments.
Whatever program you were using is probably split into consecutive threads or processes. When one finishes and the next one starts there is some overlap where one core is more idle than the other, so that’s where the new job goes.
That totally makes sense. I didn’t even think of it being even more atomic than the squares I could see being completed. Thanks for that explanation!