Thread concept

Thread concept

Hi all,Theoritically i understood two or 'N' threads are run parrallely. but in embeeded system how it would be. however threads should share the cpu time by means of some algorithms like roundrobin,FIFO,Shortest jobfirst,preemptive.so seems like noparallelism. if one thread finishes the allocated cpu time another thread will execute then where is the concurrent concepts arises.similarly threads are nothing but a task,if a thread executes it will be in RUN state. another recently arrived thread would be in ready state, if a thread present in RUN state finishes it work,whatever task present in the ready state now pushed in to running state so it will execute. so no threads are run parrally?Pls clear my doubts.RegardsMuthazhagan

6 posts / novo 0
Último post
Para obter mais informações sobre otimizações de compiladores, consulte Aviso sobre otimizações.

A Processor is generally described as a package (with pins on the bottom)

A Processor may contain one or more dies (silicon chips affixed into the processor package)

Each die may contain one or more Cores (e.g. Dual Core Processors)

Each Core may contain one or more hardware threads.

Each hardware thread "looks like" a dedicated processor.

An embedded system can be as restrictive as:

1 processor package with
1 die with
1 core, eachwith
1 hardware thread

In the above, you historicallywould call it "a processor"

Consider an embedded system with an Intel Atom Dual-Core processor wiht HyperThreading

1 processor package with
1 die with
2Cores, each with
2 hardware threads

In the above, you have one processor that looks like 4 processors (also called 4 logical processors)

A single logical processor, single die, single core, single thread system can still support multiple threads in a time-sliced manner(what you describe). But this technique is being replaced by a more capable processor (more hardware threads).

Jim Dempsey

www.quickthreadprogramming.com

May be this lik will be of some help to youhttp://www.csie.nctu.edu.tw/~wjtsai/EmbeddedSystemDesign/Ch1-2.pdf

Is it possible create one block of code, that create two thread and each thread run on each core of the processor?

Att.
Maycon

Sure

In C/C++ using OpenMP

#pragma omp parallel for
for(int i=0; i < n; ++i)
{
// each thread enters here with different subset of iteration space
}

Or

#pragma omp parallel
{
// all threads enter here
}

You should read documentation on OpenMP as there are programming issues and means to resolve these issues. The principal among these are data sharing issues. Look at SHARED(...) and PRIVATE(...) clauses for OpenMP statements.

Jim Dempsey

www.quickthreadprogramming.com

Deixar um comentário

Faça login para adicionar um comentário. Não é membro? Inscreva-se hoje mesmo!