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


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

SemaCondvar was updated to version 1.11

Started byaminer <aminer@toto.net>
First post2013-09-19 11:40 -0700
Last post2013-09-19 13:55 -0700
Articles 3 — 1 participant

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


Contents

  SemaCondvar was updated to version 1.11 aminer <aminer@toto.net> - 2013-09-19 11:40 -0700
    Re: SemaCondvar was updated to version 1.11 aminer <aminer@toto.net> - 2013-09-19 13:34 -0700
    Re: SemaCondvar was updated to version 1.11 aminer <aminer@toto.net> - 2013-09-19 13:55 -0700

#1716 — SemaCondvar was updated to version 1.11

Fromaminer <aminer@toto.net>
Date2013-09-19 11:40 -0700
SubjectSemaCondvar was updated to version 1.11
Message-ID<l1f5u4$ten$1@news.albasani.net>
Hello,

SemaCondvar was updated to version 1.11, i have included
a portable spinlock that is very efficient more efficient than the
Windows Critical section on both high contention and low contention, so 
SemaCondvar have given an excellent performance now.


Description:

SemaCondvar and SemaMonitor are new and portable synchronization objects 
that combine all the charateristics of a semaphore and a condition 
variable, they only use an event object and a critical section , so they 
are fast.
Now you can pass the SemCondvar's initialcount  and SemCondvar'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.


You can download SemaCondvar from:

http://pages.videotron.com/aminer/


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;

Please take a look a the test.pas Object Pascal demo inside the zipfile, 
compile and run it...

Language: FPC Pascal v2.2.0+ / Delphi 7+: http://www.freepascal.org/

Operating Systems: Windows, Mac OSX , Linux , Unix...


Required FPC switches: -O3 -Sd -dFPC -dFreePascal

-Sd for delphi mode....

{$DEFINE CPU32} and {$DEFINE Windows32} for 32 bit systems

{$DEFINE CPU64} and {$DEFINE Windows64} for 64 bit systems

{$DEFINE OSX}  for Mac OSX on Delphi XE4 to XE5



Thank you,
Amine Moulay Ramdane..

[toc] | [next] | [standalone]


#1717

Fromaminer <aminer@toto.net>
Date2013-09-19 13:34 -0700
Message-ID<l1fciu$bhg$1@news.albasani.net>
In reply to#1716

Correction,  please read again the description:


Description:

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 very efficient and portable spinlock , so they are fast.

You can download SemaCondvar from:

http://pages.videotron.com/aminer/

Thank you,
Amine Moulay Ramdane.

[toc] | [prev] | [next] | [standalone]


#1718

Fromaminer <aminer@toto.net>
Date2013-09-19 13:55 -0700
Message-ID<l1fdp8$e29$1@news.albasani.net>
In reply to#1716
Hello,

As you have noticed i have used a very fast and
very efficient and portable spinlock inside
SemaCondVar.pas, i have made this choice cause the spinlock that i have 
included have by far
a better performance than the Windows critical section ,  but you will 
notice that this spinlock is now portable to the x86 systems and to 
Linux(x86) , Mac OSX(x86) and Windows(x86), but if you want to port it 
to other systems than the x86, please change inside SemaCondVar.pas the 
TSpinlock by the TCriticalSection of the SyncObjs unit and it will be 
potable to other systems
than the x86. That's all.


So enjoy SemCondvar and SemaMonitor cause they fast.

YYou can download SemaCondvar from:

http://pages.videotron.com/aminer/


Thank you,
Amine Moulay Ramdane.

[toc] | [prev] | [standalone]


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


csiph-web