I feel that i must explain to you how do work my inventions that are my SemaCondvar and SemaMonitor objects, you will find those classes inside the SemaCondvar.pas file inside the zip file, SemaCondvar and SemaMonitor are new and portable synchronization objects , SemaCondvar combines all the charateristics of a semaphore and a condition variable and SemaMonitor combines all charateristics of a semaphore and an eventcount , they only use an event object and a very fast and efficient and portable FIFO fair Lock , so they are fast and they are FIFO fair.
When you set the first parameter of the constructor to true it will add the characteristic of a Semaphore to the condition variable or to the Eventcount, so the signal will not be lost if the threads are not waiting for the SemaCondvar or SemaMonitor object, but when you set the first parameter of the constructor to false it will not behave like a Semaphore because if the threads are not waiting for the SemaCondvar or SemaMonitor the signal will be lost..
Now you can pass the SemaCondvar's or Semamonitor's initialcount and SemaCondvar's or SemaMonitor's MaximumCount to the construtor, it's like the windows Semaphore`s InitialCount and the Semaphore's MaximumCount.
You have 5 options in the defines.inc file for setting the kind of locks, just look inside defines.inc , if you want to set it for the Mutex that is energy efficient because it blocks the threads,uncomment the option Mutex, if you want to set it for my node based scalable Lock, uncomment the option MLock, if you want to set it for my scalable array based lock called AMLock just uncomment the option AMLock inside defines.inc, if you want to set it for Ticket Spinlock just uncomment the option TicketSpinlock ,If you want to set it for Spinlock just uncomment the option Spinlock.
You can download my SemaMonitor and SemaCondvar from:
Feel free to port my SemaCondvar and SemaMonitor to other programming languages !
Amine Moulay Ramdane.
- Parallel Computing