What is a "semaphore timeout period?"

I have some personal experience with the semaphore timeout period error. I was able to get the error resolved, but that still left me asking, what in the world is a "semaphore timeout period?" How can I prevent it from happening? Why does it only happen when large data transfers are in question?

2 Answers

A semaphore (and a mutex) is a synchronization object, used to communicate amongst various processes sharing a resource. For example,if you had multiple threads performing division checks for primality, you would want to assign different divisors after each test finishes.

A thread needs to check the semaphore using a Wait Function to see if the object is free. However, to handle deadlocks should one thread fail to release a semaphore, wait functions can specify a finite time-out, the message you see. If a transfer takes too long, then the semaphore controlling it expires.

For more information, see WaitForSingleObject function, or the C++ Tutorial Multi-Threaded Programming.

So what might you do in a real-world situation when transferring large files over a network with limited bandwidth?

  1. Compress the files (XML data, in particular, compresses ~10:1 with Zip).

  2. Break the files into chunks (a nuisance, but applicable to any file type).

  3. Improve bandwidth. For example, I found SSH/SFTP extremely slow on an older server, but when RAM was added, data transferred more rapidly.

I tripped on the solution for the timeout -- I was backing up my HD to an external drive and kept on getting the semephore time-out error and found a suggestion to change USB connection and success. Problem gone.

0

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like