Recent

Author Topic: Amine's announcements  (Read 30038 times)

aminer

  • Hero Member
  • *****
  • Posts: 956
AWE version 1.01 ...
« Reply #15 on: April 17, 2010, 10:47:22 pm »

Hello,


I have updated TAWEStorage to support Object Pascal
TStream, so, it now supports Memory streams , File streams etc...

and i have added two methods:

procedure LoadFromStream(in_stream: TStream);
procedure LoadFromFile(const FileName: string);



Description:


Why the  2 GB limitation on the Win 32 bits systems ?


My AWE Object pascal module is here, it  allows your application
 to use up to 64GB of RAM.


And here is the public interface of TAWEStorage class,
i  have implemented the follow methods:


TAWEStorage = class(TObject)
  public

    Size:longword;
    position:longword;
    PageSize:integer;

    constructor Create();
    destructor Destroy(); override;
    function GetMem(ulBytes: ULONG): BOOL;
    function FreeMem(): BOOL;
    function HowManyPagesAllocated(): ULONG;
    function CopyFrom(in_stream:TStream;count:longint):longint;
    function CopyTo(out_stream:TStream;count:longint):longint;
    function Read(var Buffer;count:longint):longint;
    function Write(const Buffer;count:longint):longint;
    function ToString:string;
    procedure LoadFromStream(in_stream: TStream);
    procedure LoadFromFile(const FileName: string);

  end;


Note: To be able to use AWE you have to set the user rights
correctly, so,go to:  Control Panel -> Administrative tools
-> Local Security Policy -> User Rights Assignment and give
'Lock pages in memory' right to the user that wants to use AWE.


Every TAWEStorage object can go up to 4GB , and you can go up to
64GB !


You can download my AWE module from:


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


TAWEStorage is very easy to use, here is an example:


-------------------------------------------------


program test;


uses AWE,classes;


var
awe1:TAWEStorage;
ptr:pointer;
fstream1:TFileStream;
stream1,stream2:TMemoryStream;


Function StringToStream(const AString: string): TMemoryStream;
begin
Result := TMemoryStream(TStringStream.Create(AString));
end;


begin


stream2:=TMemoryStream.create;


fstream1:=TFileStream.create('test.txt',fmCreate);


 stream1:=StringToStream('Hello world !');
awe1:=TAWEStorage.create;


writeln;
if awe1.getmem(stream1.size)
  then writeln('Memory was reserved...')
  else writeln('Memory was not reserved...');


writeln('Number of pages allocatd is: ',awe1.HowManyPagesAllocated);


if awe1.CopyFrom(stream1,stream1.size) <> 0
then writeln('CopyFrom ok ...')
else writelN('CopyFrom not ok ..');


awe1.position:=0;
awe1.CopyTo(stream2,awe1.size);


stream2.position:=0;
fstream1.copyfrom(stream2,stream2.size);
stream2.position:=0;
fstream1.position:=0;


writeln(awe1.tostring);


awe1.freemem;
awe1.free;
end.


--------------------------------------------------------------


A nice module, that you can use with ParallelHashList , right ?


There is another module at:


http://www.winsoft.sk/awe.htm


But you have to pay for it.. and i think my module is *better*.


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


Sincerely,
Amine Moulay Ramdane.



aminer

  • Hero Member
  • *****
  • Posts: 956
Re: Amine's announcements
« Reply #16 on: April 18, 2010, 12:21:53 am »
Hello,


I have updated AWE to version 1.02 , i have renamed TAWEStorage
to TAWEStream , and TAWEStream now ineherit from the Object Pascal TStream class ..


There is another module at:


http://www.winsoft.sk/awe.htm


But you have to pay for it.. and i think my module is *better*.


And my AWE module works with Windows 2000 and up (x86)...

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


Sincerely,
Amine Moulay Ramdane.



aminer

  • Hero Member
  • *****
  • Posts: 956
Re: Amine's announcements
« Reply #17 on: April 18, 2010, 05:50:58 am »

Hello,


AWE  have been updated to version 1.03


Now using LoadFromStream() - to copy streams of memory from
a TAWEStream to a TAWEStream is working properly. Look
inside test1.pas example inside the zipfile ,  as you have noticed ,
you have to  use getmem() before using LoadFromStream() on
a TAWEStream...-


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


Sincerely,
Amine Moulay Ramdane



aminer

  • Hero Member
  • *****
  • Posts: 956
Parallel Compression version 1.21 ...
« Reply #18 on: April 21, 2010, 02:14:18 am »

Hello,


I have updated my parallel compression library to version 1.21 ,

in the GzipCompress() i have done something like this:

-------------------------------
1 - if count_compress = Tjob(obj).index
2- then
3-     begin
4-       
5-         bzip.compressStream(Tjob(obj).stream,local_stream);
6-       local_stream.position:=0;
7-       Tjob(obj).fstream.CopyFrom(local_stream,local_stream.size);
8-       count_compress:=count_compress+1;
9-       local_count:=count_compress;
10-      break;
11-    end;
12- until false ;
------------------------------------------------


But there is a race condition , since between line 8 and 9 a
thread may modify count_compress and you can get a corrupt
information in line 9.


I have corrected it with something like this:

-------------------------------
 if count_compress = Tjob(obj).index
 then
     begin
       
         bzip.compressStream(Tjob(obj).stream,local_stream);
       local_stream.position:=0;
       Tjob(obj).fstream.CopyFrom(local_stream,local_stream.size);
       local_count:=count_compress+1;
       count_compress:=local_count;
       break;
    end;
 until false ;
------------------------------------------------



And you can download the new updated version from:

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




Sincerely,
Amine Moulay Ramdane.




aminer

  • Hero Member
  • *****
  • Posts: 956
Lockfree_mpmc was updated ...
« Reply #19 on: April 21, 2010, 11:08:08 am »

Hello,


I have been working all the night on the following  problem:

'Sometimes'  the producer threads of my Threadpool was hanging  ,
and i have finally discovered what is the problem...

In the push() method inside lockfree_mpmc.pas you will see that
 it is using a repeat until   , this tight loop around the CAS
was not working properly and was hanging the producer threads
from time to time,  and the solution to this problem was to
add a sleep(0) in this tight loop.

Now Threadpool is working perfectly , and is perfectly stable
- i have tested it all the night ! - .


Please download all my modules that contains lockfree_mpmc.pas
- like ParrallelQueue, Threadpool, Pthreadpool , Parallel compression ,
Parallel Quicksort etc. -

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



Amine Moulay Ramdane


aminer

  • Hero Member
  • *****
  • Posts: 956
Thread Pool Engine version 1.33 ...
« Reply #20 on: April 22, 2010, 04:15:13 am »

Hello,

I have been testing all the night , and i have discovered a
problem, look at the following in the execute() method inside
my Thread Pool Engine:

--------------------------------------------------------------------------

function TThreadPool.execute(func:TMyProc;const Context: Pointer): Boolean;

var
local_balance,local_count:integer;
params:  PParams;
p:pointer;

begin
new(params);
setlength(params^,1);
params^[0].proc:=func;
params^[0].data:=context;

local_balance:=LockedIncLong(balance1) mod FThreadCount;
1-local_count:=Queues[local_balance].count;
2-while not Queues[local_balance].push(tobject(params^))  do;
3-if local_count=0 then events[local_balance].setevent;
p:=params;
dispose(p);

end;

------------------------------------------


If local_count is not zero  and between 1-3 the worker thread
have poped all the objects from the queue and it enters in a
waiting state,  the event will not be signaled from the producer ,
and  there is a possibility of a 'deadlock'.


So i have changed it to the following, to avoid the deadlock:

--------------------------------------------------------------------------

function TThreadPool.execute(func:TMyProc;const Context: Pointer): Boolean;

var
local_balance,local_count:integer;
params:  PParams;
p:pointer;

begin
new(params);
setlength(params^,1);
params^[0].proc:=func;
params^[0].data:=context;

local_balance:=LockedIncLong(balance1) mod FThreadCount;
//local_count:=Queues[local_balance].count;
while not Queues[local_balance].push(tobject(params^))  do;
//if local_count=0 then events[local_balance].setevent;
events[local_balance].setevent;
p:=params;
dispose(p);

end;

------------------------------------------



You can download my Thread Pool Engine ,and the other modules
that use it, from:

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


Sincerely,
Amine Moulay Ramdane.



aminer

  • Hero Member
  • *****
  • Posts: 956
Re: Amine's announcements
« Reply #21 on: April 22, 2010, 04:24:57 am »

Hello,

Look at the new code:

1- while not Queues[local_balance].push(tobject(params^))  do;
2- events[local_balance].setevent;


Now if between 1-2 the worker thread have poped all the objects
from the queue and it enters in a waiting state,  the event will
be signaled by the producer - so no problem -

and

If the consumer was in a waiting state , the event will be signaled
by the consumer - so no problem -

and

If the consumer was doing its job poping and exxecuting, the event
will be signaled - so no problem here -


And in all those cases, there will be NO deadlock.



Sincerely,
Amine Moulay Ramdane.
 
.

aminer

  • Hero Member
  • *****
  • Posts: 956
Hello,


An M/M/n queuing model simulation with Object Pascal and my Thread Pool Engine.
 

Author: Amine Moulay Ramdane


Description:

It's harder and sometimes impossible to get analytical results
about waiting times and and queue length for general interarrival
and service distributions; so it's important to be able to estimate
these quantities by observing the results of simulation.

It's very easy in Object Pascal to simulate a sequence of arrival times
with a given interarrival distribution.

Look for example at the M/M/n example MMn.pas inside the zip file:

---------------------------

InterArrivals:=TExponentialDistribution.Create(420623,1.0/3.0);
ServiceTimes:=TExponentialDistribution.Create(220623,1.0/4.0);

currtime:=0.0;

for i:=1 to simnumber
do
begin
obj:=TJob.create;
obj.simnumber:=simnumber;
obj.number:=i;
currtime:=currtime+InterArrivals.Sample;
obj.ArrivalTime:=currtime;
obj.Servicetime:= ServiceTimes.sample;
TP.execute(myobj.myproc1,pointer(obj),NORMAL_PRIORITY);
end;
-------------------------------------------

Here we have the InterArrivals object and ServiceTimes object and
we are calling InterArrivals.Sample to get our samples from the
Exponential Distribution.

After that we are calling myobj.myproc1 to simulate our
M/M/n queuig model...

If you look at MMn.pas , you will see that the InterArrival rate
is 3 and the Service rate is 4 , so, this will give us a theoretical
value of 1/(4-3) = 1, and the Object Pascal simulation give us 1.02.
 


You can download  the M/M/n queuing model simulation from:

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


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

Operating Systems: Win , Linux and Mac (x86).

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

-Sd for delphi mode....

Required Delphi switches: -DMSWINDOWS -$H+

For Delphi 5,6,7 use -DDelphi

For Delphi 2005,2006,2007,2009,2010+ use the switch -DDELPHI2005+



Sincerely,
Amine Moulay Ramdane.



aminer

  • Hero Member
  • *****
  • Posts: 956
I wrote:

>If you look at MMn.pas , you will see that the InterArrival rate

>is 3 and the Service rate is 4 , so, this will give us a theoretical

>value of 1/(4-3) = 1, and the Object Pascal simulation give us 1.02.

 

I mean for one server - M/M/1 -  it gives a theorerical value
of 1/(4-3) = 1 and 1.02 in the simulation..

But as you have noticed  MMn.pas can simulate an M/M/n queuig model
with 1 or many servers...



Sincerely,
Amine Moulay Ramdane.




aminer

  • Hero Member
  • *****
  • Posts: 956
Hello ,

I have updated MMn.pas to version1.01 - i have corrected a bug -
and put it back inside the zip file that you can download from:


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


Note:  MMn.pas - n: numbers of servers -  is queuing model simulation with
         Object Pascal and my Thread Pool Engine.


Sincerely,
Amine Moulay Ramdane.


aminer

  • Hero Member
  • *****
  • Posts: 956

Hello


Note: next time i will show you how to simulate
         a more complex problem in Object Pascal...

Of course, if you want to  simulate a  'general' distribution ,
like uniform or normal ,you can do it like this  by changing
your variables inside MMn.pas: 

 
Define your variables:

var InterArrivals: TUniformDistribution;
    ServiceTimes:  TUniformDistribution;

and after that:

InterArrivals:=TUniformDistribution.Create(420623,0,2);
ServiceTimes:=TUniformDistribution.Create(2990623,0,1.5);

for i:=1 to simnumber
 do
  begin
   obj:=TJob.create;
   obj.simnumber:=simnumber;
   obj.number:=i;
   currtime:=currtime+InterArrivals.Sample;
   obj.ArrivalTime:=currtime;
   obj.Servicetime:= ServiceTimes.sample;
   TP.execute(myobj.myproc1,pointer(obj),NORMAL_PRIORITY);
   
  end;




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


That all.


Sincerely,
Amine Moulay Ramdane.


aminer

  • Hero Member
  • *****
  • Posts: 956
WinMenus 1.0 ...
« Reply #26 on: May 20, 2010, 05:35:19 pm »

Hello,


Author: Amine Moulay Ramdane

Description:

Drop-Down Menu widget using the Object Pascal CRT unit.
Please look at the test.pas example inside the zip file.

Use the 'Delete' on the keyboard to delete the items
Use the 'Insert' on the keyboard to insert the items
and use the 'Up' and 'Down' and 'PageUp and 'PageDown' to scroll ..
and use the 'Tab' on the keyboard to switch between the Drop Down Menus


You can download WinMenus from:

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

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

-dUnix for Linux , Unix and Mac OSX

-dWindows for windows

Required Delphi switches: -DMSWINDOWS -$H+

For Delphi 5,6,7 use -DDelphi switch

For Delphi 2005,2006,2007,2009,2010+ use the switch -DDELPHI2005


Sincerely,
Amine Moulay Ramdane.




aminer

  • Hero Member
  • *****
  • Posts: 956
Re: WinMenus 1.0 ...
« Reply #27 on: May 20, 2010, 06:41:57 pm »

Hello all,

I have updated WinMenus to version 1.01 , now it
is working properly with Delphi 2010.

Take a look at the test.pas example and

Use the 'Delete' on the keyboard to delete the items
Use the 'Insert' on the keyboard to insert the items
and use the 'Up' and 'Down' and 'PageUp and 'PageDown' to scroll ..
and use the 'Tab' on the keyboard to switch between the Drop Down Menus
and 'Enter' to select an item..
and the 'Esc' on the keyboard to exit..


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



Sincerely,
Amine Moulay Ramdane.





 

aminer

  • Hero Member
  • *****
  • Posts: 956
Re: Amine's announcements
« Reply #28 on: May 23, 2010, 09:49:16 pm »

Hello,

WinMenus have been updated to 1.1 , now it's stable.

Description:

Drop-Down Menu widget using the Object Pascal CRT unit.
Please look at the test.pas example inside the zip file.

Use the 'Delete' on the keyboard to delete the items                 
Use the 'Insert' on the keyboard to insert the items                   
and use the 'Up' and 'Down' and 'PageUp and 'PageDown' to scroll .. 
and use the 'Tab' on the keyboard to switch between the               
Drop Down Menus                                                           
and 'Enter' to select an item..                                         
and the 'Esc' on the keyboard to exit..                                 
and the 'F1' on keyboard to delete all the items from the list         

You can download WinMenus from:

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


Sincerely
Amine Moulay Ramdane.






aminer

  • Hero Member
  • *****
  • Posts: 956
Re: Amine's announcements
« Reply #29 on: May 23, 2010, 10:44:19 pm »

Hello again,


I have updated Winmenus to version 1.11 ,
i have just changed itemnum from byte to integer
to support more than  256 items..


Now Winmenus is stable and you can download it from:

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



Sincerely,
Amine Moulay Ramdane.



 

TinyPortal © 2005-2018