top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

What is multicore programming and how it is different from normal C multithread program.

+1 vote
763 views

I was searching the differences in normal C-lang multithread program and a multicore programming. Can any one clarify the difference and how the "parallelism" OR "execution-speed" is achieved form multicore programming.

Using the thread attribute we can set the affinity(in which core he has to run) to the thread, not not getting the exact usage of multicore programming.

One more question how to access the common(global data) memory in multicore programming, will synchronization adds delay in execution? If yes then what is the use of multicore programming

posted Aug 19, 2014 by Venkatgiri T

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

Let me try to explain multicore and multithreading in conjunction with multicore-
Multicore refers to a computer or processor that has more than one logical CPU core, and that can physically execute multiple instructions at the same time.

Multithreading refers to a program that can take advantage of a multicore computer by running on more than one core at the same time.

Now coming to your problem -
We assign the affinity of the thread to a core so that that core only executes the thread the idea is reduce the thread context switching as context switch is costly.

Lets take a practical example, assume you have a network processor with 4 cores and you you reserve 1 core for the control plane (control plane does a lot of processing but speed is not a concern as load is not high) and you have three independent data thread which can be assigned to each remaining core. Since these three are high volume traffic so these core just process the data and as part of design we make sure that these three threads are completely independent so that synchronization issue does not arise (Multicore by itself does not care of synchronization).

Let me now still have some doubt.

answer Aug 19, 2014 by Salil Agrawal
Thanks for the response,
Got an idea with the practical example, not cleared with the three data threads completely independent?
If the data threads have to communicate with each other OR with control thread then how that communication would be, possibly it has to use IPC(Shared memory with locks)? If locks are introduced then it will be sequential processing not parallel am I right?
Thats the whole idea you design the system in such a way that you avoid the lock for example message from same session lands on the same core then u can avoid the lock. Again its a design element nothing to do with the multicore or multithreading.
Thanks for the response,
How about the scheduling in multiple core?
From the above example will three data threads, Will they fight for the scheduler or scheduler will be given enough time to finish their tasks independently.
Thats the whole point one core is like one processor and it is having only one thread so scheduling is only between OS and this thread. In these type of cases we keep OS also a very light weight i.e. micro kernal only.
Similar Questions
+5 votes

In the below figure through shared l2 cache what type of data (I mean is it global variables ?) is shared .

l2 cache

+2 votes

As we heard of terms like multi processor and multi core system

Both are same or some difference exist between them ??

0 votes

Intel Core i3, Core i5, and may be Core i7 CPU have been there from last 1-2 years but I don't know the real difference between these. Can someone help me with the difference between these three so that I can decide which one to buy.

...