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 ...
- 04-08-2010 #1Just 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..!!
- 04-08-2010 #2Linux Newbie
- Join Date
- Mar 2010
- Posts
- 121
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!!! )
- 04-09-2010 #3Just Joined!
- Join Date
- Feb 2008
- Posts
- 50
Thanks JohnGraham for your reply.
I solved the problem using semaphores (with APIs sem_wait, sem_post).



