Recent

Author Topic: SemaCondvar module version 1.0 is here...  (Read 4951 times)

aminer

  • Hero Member
  • *****
  • Posts: 956
SemaCondvar module version 1.0 is here...
« on: June 13, 2013, 02:33:22 pm »

Hello,

SemaCondvar module version 1.0 is here...


SemaCondvar and SemaMonitor are new and portable synchronization objects...


Authors: Amine Moulay Ramdane.


Description:

Description: SemaCondvar and SemaCondvar are a new synchronization objects that combines a semaphore and a condition variable, it only uses an event object and a critical section , so it's fast.

If you don't want the signal to be lost if the threads are not
waiting, just pass True to the state argument of to the constructor,
if you pass False to the state argument of the construtor so the signals will be lost if the threads are not waiting.

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


The implemented methods are:

function  wait(mstime:longword=INFINITE):boolean;
procedure signal();overload;
procedure signal_all();
procedure signal(nbr:integer);overload;
function WaitersBlocked:integer;


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....


You can download SemaCondvar from:

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


Thank you,
Amine Moulay Ramdane.

aminer

  • Hero Member
  • *****
  • Posts: 956
Re: SemaCondvar module version 1.0 is here...
« Reply #1 on: June 13, 2013, 02:53:24 pm »

Hello,

Please test SemaCondvar and SemaMonitor
under Linux and Mac OSX cause they are portable, i have just tested them  under windows.

Just compile and run the test.pas example inside the zipfile...


Thank you,
Amine Moulay Ramdane.


aminer

  • Hero Member
  • *****
  • Posts: 956
Re: SemaCondvar module version 1.0 is here...
« Reply #2 on: June 13, 2013, 03:05:33 pm »

Hello,

I will explain my algorithm and the source code the next time..


Thank you,
Amine Moulay Ramdane.

aminer

  • Hero Member
  • *****
  • Posts: 956
Re: SemaCondvar module version 1.0 is here...
« Reply #3 on: June 13, 2013, 04:16:49 pm »

Hello,

Sorry for my english...

Here is again the description:

Description: SemaCondvar and SemaMonitor are new and portable synchronization objects that combine the characteristics of a semaphore and a condition variable, they only use an event object and a critical section ,
so they are fast.


You can download SemaCondvar from:

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


Thank you,
Amine Moulay Ramdane.

aminer

  • Hero Member
  • *****
  • Posts: 956
Re: SemaCondvar module version 1.0 is here...
« Reply #4 on: June 13, 2013, 04:45:57 pm »

Hello,

I have updated SemCondvar to version 1.01

You can download SemaCondvar 1.01 from:

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


Thank you,
Amine Moulay Ramdane.

aminer

  • Hero Member
  • *****
  • Posts: 956
Re: SemaCondvar module version 1.0 is here...
« Reply #5 on: June 13, 2013, 05:12:27 pm »

Hello,


I have ported also SemaCondvar and SemaMonitor to Delphi XE1 to XE4, and they compile now perfectly under Win32 ,Win64 and OSX, and they are also
compatible with FreePascal and Lazarus
and it's of course portable under FreePascal and Lazarus.

You can download SemaCondvar 1.01 from:

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


Thank you,
Amine Moulay Ramdane.




aminer

  • Hero Member
  • *****
  • Posts: 956
Re: SemaCondvar module version 1.0 is here...
« Reply #6 on: June 14, 2013, 01:32:33 am »

Hello,

I have updated SemCondvar to version 1.1, now it supports ALL the charateristics of a semaphore and a condition variable,
i have also corrected a bug.


You can download SemaCondvar 1.1 from:

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


Thank you,
Amine Moulay Ramdane.


aminer

  • Hero Member
  • *****
  • Posts: 956
Re: SemaCondvar module version 1.0 is here...
« Reply #7 on: June 14, 2013, 01:44:57 am »

Hello,

I have updated SemaCondvar to version 1.1, now it supports ALL the charateristics of a semaphore and a condition variable,
i have also corrected a bug.

Description: SemaCondvar and SemaMonitor are new and portable synchronization objects that combine all the characteristics 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.


If you want to detect spurious wakeups just test the boolean value returned by the timed wait method.

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 SemaCondvar 1.1 from:

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


Thank you,
Amine Moulay Ramdane.



 

TinyPortal © 2005-2018