I was doing an experiment in VirtualBox. This is my setup.
I ran a simple code in the Guest OS
# include <stdio.h>
# include <stdlib.h>
int main()
{
while(1)
{
int * p = (int *)malloc(sizeof(int));
}
return 0;
}
I saw that there were simultaneous spikes in all 4 cores of the host OS.
I thought the guest OS is supposed to use a single core. What am I doing wrong or is this behaviour normal (If so, then why)?



My guess is that while your code only takes one core, your program when executed can be switched into and out of context on different cores during the execution by the operating system. That's why you see all cores used, but the spikes occur at different times. (But this make take a more accurate measurement than looking at the resource monitor).