Click to See Complete Forum and Search --> : Help! about 2 threads share one com port


stans
December 20th, 2004, 03:16 AM
Now i have one serial com port, and i want it been shared by 2 threads. Now i am using the binary semaphore to control it. I want to ask is it good? or is it good to use the critical section?

Can any body help me compare these method to let me see which one is better?

Thanks

Andreas Masur
December 20th, 2004, 03:39 AM
Well...what is a binary semaphore in the first place? Critical sections and mutexes are more behaving the same. The major difference is, that the former one can only be used within one process while the latter one can act between several processes. Due to this, a critical section performs much better than a mutex, since there is no need to switch to kernel mode for it...