[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

Parallel Programmering Med Linux



Hej 
Jeg har proevet at faa svar paa mit problem fra flug's mailing lister, men
desvaerre, var der ikke en god loesning til problemet.

Jeg er igang med at lave et simpelt program som skal koere paa to
processorer ( i en maskine). Jeg bruger pthreads til dette formaal, og har
dermed to traade der skal koere paa hver sin processor. Traad 1 er
selvstaendig og regner loes paa nogle tal som den loebende indsaetter i et
array i indeks raekkefoelge. Arrayet er allokeret dynamisk, og den
function som koerer i traaden har faaet en reference til arrayet. Udover
arrayet, er der en global variabel, progress, (deklareret som volatile)
som faar tildelt det indeks som arrayet lige er blevet fyldt med. 

Den anden traad laeser progress, og ser om det entry i arrayet er blevet
fyldt af traad 1. Hvis ja, saa bruges vaerdien. Dette goer den  indtil
alle elementer i array er loebet igennem.

Mine problemer er to:

1- Jeg har et problem med at traad 1 haenger lige pludselig, selvom den er
selvstaendig.

2- Jeg faar nogen gange en segmentation fault naar traad 2 laeser fra
arrayet.


Saa mit spoergesmaal er om nogen af jer har haft erfaring med at
programmere parallet, og har haft nogenlunde samme problemer?

Skal jeg laase mine data, selvom det kun er den ene af traadene der
skriver i dem (og den anden laeser bare), og selvom jeg mener at det er
atomare laesninger og skrivninger der udfoeres? Jeg vil helst undgaa at
laase, da dette vil gaa ud over effektiviteten. 

Er det et problem hvis den ene traad laeser et entry i arrayet, og den
anden laeser et andet entry samtidig?


Jeg haaber jeg kan faa hjaelp herfra.

Paa forhaand tak

Jihad



 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2005-08-10, 20:34 CEST [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *