Find the answer to your Linux question:
Results 1 to 5 of 5
Hi All, I have written one app that contains 3 different threads. I used mutex to handle the shared/ global data within this app. I have written different mutex for ...
  1. #1
    Just Joined!
    Join Date
    Feb 2008
    Posts
    50

    mutex around the threads

    Hi All,

    I have written one app that contains 3 different threads. I used mutex to handle the shared/ global data within this app. I have written different mutex for each thread ie. 3 mutex and not used mutex within main().

    Is it right? or Will I have to use single mutex for all threads even for main() ?

    Please guide me on this.

    Thanks,
    Pankaj.

  2. #2
    Just Joined!
    Join Date
    Feb 2008
    Posts
    50
    Plz answer on this...

  3. #3
    Just Joined!
    Join Date
    Jan 2009
    Posts
    4

    Re : mutex around the threads

    Hi pankaj,


    No, it's not right. U need to take single global mutex for all three threads for shared data access by each thread at one time only. if u'll take different mutex for each thread then each mutex would be local for that thread and won't provide control to prevent shared data access from other threads if one out of three threads accessing shared global data.

    Use single global mutex and use it in threads.

  4. #4
    Just Joined!
    Join Date
    Feb 2008
    Posts
    50
    Thanks Tarun, Do you have some ebook link to more focus on this topic!

  5. #5
    Just Joined!
    Join Date
    Jan 2009
    Posts
    4

    Re : mutex around the threads

    Hi pankaj,

    It's good book for study on IPC mechanism that describes mutexes also well.

    UNIX Network Programming, Volume 2: Interprocess Communications (2nd Edition)

    By : Richard Stevens

    i don't kno link to download it.
    you search for it and get it.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...