Railway ticketing counter explains how CPU functions
One of my old article, republishing it.
Today I was explaining how CPU is utilized by VMs in a virtualized environment. I thought of an analogy. This might help someone out there.
Imagine a busy Railway junction with two ticketing centres (One each on either side of the station). Each centre has 10 counters and each counter has two lines/queues (one for each of men and women. Just an example. I have no idea of hurting the neutrals ??).
Now, I tie the knots.
Railway junction - Physical Host/Server
Ticketing centre (2 in eg.) - CPU socket
Ticketing counter (10 in eg.) - CPU core
Lines/queues (2 in eg.) - Threads
At any point, the Railway employee can serve only one request. When he accepts requests alternatively from both the queues, it appears as if he is serving two queues. Similarly, a core executes only one instruction per one CPU cycle but alternates between the threads when hyper-threading is enabled.
This is how two threads (also called logical cores) are handled by one physical core. Each physical core is an independent unit just like each person sitting at the ticket counter.
A number of such physical cores reside in a Socket and there could be up to 4 sockets in a server.
Corrections/ Suggestions/ Comments are welcome.