I need a visual basic module (preferred, dll or activeX negotiable) implementing 2 public functions P() and V() for locking purposes (conform the Dijkstra algorithm) Description of problem: A visual basic app I'm writing tries to access a certain dll. This dll cannot be called at the same time due to reentrance problems. There are a few timers in my program with code calling at random time the dll. Re-entrance should be avoided at all times. Therefor a locking mechanism needs to be implemented that prevents more than 1 thread at the same time to access the dll. What I want to do in my code is: P() V() the function P() implements the Lock and Wait function. If no other timer has called P(), then it immediately returns. If a timer called P(), but hasn't called V() yet, the function waits till V() has been called by the other timer , then returns. If several threads call P() while another thread still hasn't called V(), they need to be queued FIFO, and should be released one by one on each call of V() 1 more example timer1: P() ' gets the exclusive use timer2: P() ' finds lock is in use, and has to wait timer1: V() ' thread 1 releases lock, automaticly thread 2 continues. timer2: V() ' timer2 releases exlcusive use Waiting means, holds the function call, and allows the OS to something else, till V() has been called.
1) Complete and fully-functional working program(s) in source code. 2) Documentation required to use the functionality. 3) Complete ownership and distribution copyrights to all work purchased.
Should run on win98 and up under Visual Basic 6. .bas module preferred, but dll or activeX control is discussable.