Total members 11890 |It is currently Thu Apr 25, 2024 3:03 pm Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





Hey,

I'm developing a multi-threaded program in C.
I have a thread - a dispatcher responsible for receiving information from a pipe and sending it to three other threads
I used conditional variables to (try) to synchronize the program, but I'm having some problems.

For a start I used pthread_cond_signal()

Code:
//dispatcher
pthread_cond_signal(&cond)

//thread1
while (letMeWork == 0) {
         puts("COMPRESSOR BLOCKED");
         pthread_cond_wait(&cond, &mutex)
      }
      printf("[COMPRESSOR]");

//thread2
while (letMeWork == 0) {
         puts("ENCRYPTOR BLOCKED");
         pthread_cond_wait(&cond, &mutex)
      }
      printf("[ENCRYPTOR]");
...


What I'm trying to do is: when I receive something in the pipe (the filename) the thread dispatcher sends a signal to thread1 in order for this to compress the file, after that the thread2 will work in that same file (modified by thread1).
Note, I could have different files, so thread1 is compressing one file and thread2 is encrypting another.

The problem is that, after receiving a signal, only thread1 works.
I've tried with broadcast() but in that case it's worse...

Any help is very welcome,

Thanks ;)




Author:
Newbie
User avatar Posts: 1
Have thanks: 0 time

Hi.. you did not write problem clearly here..

can u send ur programme that i can debug that..

or u can use fork here instead of thereads.. create two process
do ur work it would be better option to do so..
as i can understand Your Problem..


Enjoy!!!!!!!!!! :gOOd:


Author:
Newbie
User avatar Posts: 3
Have thanks: 0 time
Post new topic Reply to topic  [ 2 posts ] 

  Related Posts  to : Multi Thread Program
 daemon thread - What is the use of deamon thread?     -  
 Javascript Multi-dimensional Arrays     -  
 Multi colored table rows     -  
 Toggle the Multi Monitor Setting in Windows XP     -  
 multi-frameset and non-re-sizable html frame pages     -  
 $2500 per month working with Multi-million dollar companies     -  
 Thread Safe     -  
 Thread of Event Dispatcher     -  
 invokes a thread's run() method     -  
 initial state of thread     -  









Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com