Thread: threads and pipes

  1. #1
    Registered User
    Join Date
    Aug 2009
    Posts
    192

    threads and pipes

    Hey so been starting learning stuff about threads and pipes. At first i used pipes for multiprocessing communications. Then realized to changed to threads, but I didn't want to change the pipe code to using conditional properties for threads. And it works with threads using pipes instead of conditions. I'm just asking in threory could there be a problem doing this I've been looking online and there hasnt been to much talk about threads using pipes to communicate information to eachother. Wondering if this could affect something in the System that I'm not aware off.

  2. #2
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981
    Shouldn't make much of a difference if what you had before was correct.

    >> And it works with threads using pipes instead of conditions.
    What do you mean "conditions"? What are you using the pipes for and how would these "conditions" replace it?

    gg

  3. #3
    Registered User
    Join Date
    Aug 2009
    Posts
    192
    well in pthreads theres a bunch of system calls for conditions like wait state or a signal state telling the other threads whether they would be in a suspended state waiting for data to be process somewhere else. mostly talking baout
    * Creating/Destroying:
    o pthread_cond_init
    o pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
    o pthread_cond_destroy
    * Waiting on condition:
    o pthread_cond_wait
    o pthread_cond_timedwait - place limit on how long it will block.
    * Waking thread based on condition:
    o pthread_cond_signal
    o pthread_cond_broadcast - wake up all threads blocked by the specified condition variable.

    So rather then using these system calls I'm thinking pipes should be sufficient since I'm just using htem to pass data when i call on it with a
    write( )
    read()
    command

  4. #4
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981
    >> pipes should be sufficient since I'm just using them to pass data
    I think so. I'd think any IPC mechanism could be used for "ITC".

    gg

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Leaking memory when creating threads
    By Elkvis in forum Windows Programming
    Replies: 3
    Last Post: 08-18-2009, 02:27 PM
  2. Best solution for inter-thread communication?
    By IceDane in forum Linux Programming
    Replies: 7
    Last Post: 05-25-2009, 05:15 AM