Single-core processors will only ever execute one thread at any given time as that is all they are capable of. However, in order to ensure that we don't see our applications hanging and being unresponsive, these processors rapidly switch between multiple threads of execution many thousands of times per second. This switching between threads is what is called a "context switch," and involves storing all the necessary information for a thread at a specific point in time, and then restoring it at a different point further down the line.
Using this mechanism of constantly saving and restoring threads allows us to make progress on quite a number of threads within a given second, and it appears like the computer is doing multiple things at once. It is, in fact, doing only one thing at any given time, but doing it at such speed that it's imperceptible to the users of that machine.
When writing multithreaded applications in Python, it is important to note that these context switches are, computationally, quite expensive. There is no way to get around this, unfortunately, and much of the design of operating systems these days is about optimizing for these context switches so that we don't feel the pain quite as much.
The following are the advantages of single-core CPUs:
- They do not require any complex communication protocols between multiple cores
- Single-core CPUs require less power, which makes them better suited for IoT devices
Single-core CPUs, however, have these disadvantages:
- They are limited in speed, and larger applications cause them to struggle and potentially freeze
- Heat dissipation issues place a hard limit on how fast a single-core CPU can go