Find the answer to your Linux question:
Results 1 to 3 of 3
Hi, I have written application having two threads, first one is main process having while(1) to catch any user events and other one is while(1) to process the backgroud updates ...
  1. #1
    Just Joined!
    Join Date
    Feb 2008
    Posts
    50

    [SOLVED] Thread Synchronization

    Hi,

    I have written application having two threads, first one is main process having while(1) to catch any user events and other one is while(1) to process the backgroud updates for the application.

    Both threads call two common functions and I want to apply synchronization method to that 2 common functions. So if any thread calls common function other should wait till first completes processing of that common function.

    I tried with mutex but I can't it in this case.

    Can anybody help me how to solve my problem.

    Please help..!!

  2. #2
    Linux Newbie
    Join Date
    Mar 2010
    Posts
    121
    Quote Originally Posted by ypankaj View Post
    I tried with mutex but I can't it in this case.
    What do you mean? What have you tried?

    As an aside: you're probably not doing it right - a mutex is exactly what you want. Try going through a tutorial like this one:

    https:// computing.llnl.gov /tutorials/pthreads/#Mutexes

    (cannot post as complete URL because I'm too new! ANNOYING!!! )

  3. #3
    Just Joined!
    Join Date
    Feb 2008
    Posts
    50
    Thanks JohnGraham for your reply.

    I solved the problem using semaphores (with APIs sem_wait, sem_post).

Posting Permissions

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