Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.programming.threads > #2657 > unrolled thread

Benchmarks of my lightweight SemaMonitor and SemaCondvar

Started byRamine <ramine@1.1>
First post2014-11-02 08:57 -0800
Last post2014-11-02 09:10 -0800
Articles 2 — 1 participant

Back to article view | Back to comp.programming.threads


Contents

  Benchmarks of my lightweight  SemaMonitor and SemaCondvar Ramine <ramine@1.1> - 2014-11-02 08:57 -0800
    Re: Benchmarks of my lightweight  SemaMonitor and SemaCondvar Ramine <ramine@1.1> - 2014-11-02 09:10 -0800

#2657 — Benchmarks of my lightweight SemaMonitor and SemaCondvar

FromRamine <ramine@1.1>
Date2014-11-02 08:57 -0800
SubjectBenchmarks of my lightweight SemaMonitor and SemaCondvar
Message-ID<m35d6i$s5t$2@dont-email.me>
Hello,


I have just benchmarked my SemaMonitor against the Windows Semaphore,
and the Windows Semaphore is only 37% faster than my SemaMonitor,
I compiled it for Win64 platform and my SemaMonitor is faster on
it, so i think my SemaMonitor and my SemaCondvar are useful and
powerful synchronization mechanisms.

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 and a 
very fast and very efficient and portable FIFO fair Lock , so they are 
fast and they are FIFO fair.

Now you can pass the SemaCondvar's initialcount  and SemaCondvar's 
MaximumCount to the construtor, it's like the Semaphore`s InitialCount 
and the Semaphore's MaximumCount.

Like this:

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

When you pass True in the first parameter of the constructor the 
signal(s) will not be lost even if there is no waiting threads, if it's 
False the signal(s) will be lost if there is no waiting thread.

Here is the methods that i have implemented :

TSemaCondvar = class
    public

constructor
Create(m1:TCriticalSection;state1:boolean=false;InitialCount1:longword=0;MaximumCount1:longword=INFINITE);
      destructor Destroy; override;
      function  wait(mstime:longword=INFINITE):boolean;
      procedure signal();overload;
      procedure signal_all();
      procedure signal(nbr:integer);overload;
      function WaitersBlocked:integer;
    end;

TSemaMonitor = class
    public
      constructor
Create(state1:boolean=false;InitialCount1:longword=0;MaximumCount1:longword=INFINITE);
      destructor Destroy; override;
      function  wait(mstime:longword=INFINITE):boolean;
      procedure signal();overload;
      procedure signal_all();
      procedure signal(nbr:integer);overload;
      function WaitersBlocked:integer;
       end;




You can download my lightweight SemaCondvar and Semamonitor that are 
faster from:

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



Thank you,
Amine Moulay Ramdane.

[toc] | [next] | [standalone]


#2658

FromRamine <ramine@1.1>
Date2014-11-02 09:10 -0800
Message-ID<m35e00$vvn$1@dont-email.me>
In reply to#2657
I wrote:

"SemaMonitor combines all charateristics of a semaphore and an eventcount"


In fact my SemaMonitor is more powerful than that, cause when you pass 
True in the first parameter of the constructor the signal(s) will not be 
lost even if there is no waiting threads, if it's False the signal(s) 
will be lost if there is no waiting threads.

That the same for my SemaCondvar.


Hope this is clear now.



Than you,
Amine Moulay Ramdane.

[toc] | [prev] | [standalone]


Back to top | Article view | comp.programming.threads


csiph-web