Community
cancel
Showing results for 
Search instead for 
Did you mean: 
aminer10
Beginner
21 Views

About my SemaCondvar and SemaMonitor

Hello,


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.

Like this:

t:=TSemaMonitor.create(true,0,4);


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.


That's all.

You can download my SemaMonitor and SemaCondvar from:

https://sites.google.com/site/aminer68/light-weight-semacondvar-semamonitor

and from:

https://sites.google.com/site/aminer68/semacondvar-semamonitor
 

Feel free to port my SemaCondvar and SemaMonitor to other programming languages !



Thank you,
Amine Moulay Ramdane. 

Tags (1)
0 Kudos
0 Replies
Reply