2

Hypothetically, if you (I / someone) were to create a multi-threaded application, utilising the processing powers of multiple cores (for example, using TPL in C#). Would that program crash, if it were run on a computer with a single core? Or rather, would the application move to context switching / time-slicing?

8
  • Have added an example, hopefully it's clearer Dec 9 '16 at 10:17
  • 2
    Multi threading/tasking is much older than multi-core consumer CPUs. Threads get assigned short time slices, no matter how many cores your CPU has. Dec 9 '16 at 10:22
  • Okay, so can you explain what would happen in the case above? Dec 9 '16 at 10:22
  • 2
    You can set the cpu core affinity mask for a process in the task manager to simulate a single core CPU. Dec 9 '16 at 10:23
  • In your example of the TPL, it just won't do anything in parallel. That library adjusts to the cores available and spawns an appropriate number of threads for the available cores. So no it won't crash and no it won't use context switching. Other multi-threaded solutions will behave differently.
    – David Arno
    Dec 9 '16 at 10:28
7

No, multi-threading is much older then multi-core cpus. Even with multi-core cpus we use today, the number of threads on our systems vastly outnumbers the amount of cores. The specifics on how cpu time is allocated to each thread is OS dependent.

1
  • 1
    Some multithreaded programs can actually be more efficient on a single core as well
    – Nick Zuber
    Dec 9 '16 at 16:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.