Ankit Yadav wrote:i am bit confused with the concurrency implementation in CPU. As now a days single processors are multicored. So are the developing programs for multi-core same as of multiprocessor or any difference is there? moreover, can we implement our programs independent of processor's ability to multiprogram (i.e. either multicore or multiprocessor) ?
In most respects a multicore processor behaves the same as multiple processors. The only essential difference is the cache architecture --- a multicore processor tends to share some level of cache between the cores, but less cache tends to be shared between multiple processors in the same system.
From a developer's perspective they are the same unless you are dealing with very low-level algorithms for communicating between threads.
When developing an application that uses concurrency, it is good to make the algorithm scale with the number of processors. You can explicitly control the number of threads you use by using
std::thread::hardware_concurrency() to find the number of hardware threads supported by your system, and scaling appropriately. Alternatively, use a mechanism such as
std::async() or a thread pool where the runtime determines the number of threads.
The same code will run on multicore processors, multi-processor systems, and single-core single-processor systems. However, if you have more threads that are ready to run than processor cores then the OS will typically switch between your threads, giving each a small time slice before moving to the next, and so on.