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


Groups > comp.programming.threads > #4085

Scalable reference counting with efficient support for weak references version 1.01

From computer45 <computer45@cyber.com>
Newsgroups comp.programming.threads
Subject Scalable reference counting with efficient support for weak references version 1.01
Date 2018-03-19 20:29 -0400
Organization A noiseless patient Spider
Message-ID <p8p6jf$56g$4@dont-email.me> (permalink)

Show all headers | View raw


Hello...

Scalable reference counting with efficient support for weak references 
version 1.01

I have modified a little bit my scalable algorithm, now as you will 
notice i am not using decrement with support for antitokens in the 
balancers of the scalable counting networks, i am only using an 
"increment", please look at my new scalable algorithm inside the zip 
file, i think it is working correctly. Also notice that the returned 
value of _AddRef() method will be valid if it is equal to 0, please read 
also the following to understand better:

Author: Amine Moulay Ramdane

Description:

This is my scalable reference counting with support for efficient weak 
references, and since problems that cannot be solved without weak 
references are rare, so this library does scalable very well, this 
scalable reference counting is implemented using scalable counting 
networks that eliminate completely false sharing , so it is fully 
scalable on multicore processors and manycore processors and this 
scalable algorithm is optimized, and this library does work on both 
Windows and Linux (x86), and it is easy to port to Mac OS X.

Here is the parameters of the constructor:

First parameter is: The width of the scalable counting networks that 
permits my scalable refererence counting algorithm to be scalable, this 
parameter must be 1 to 31, it is now at 4 , this is the power, so it is 
equal to 2 power 4 , that means 24=16, and you have to pass this 
counting networks width to the n of following formula:

(n*log(n)*(1+log(n)))/4

The log of the formula is in base 2

This formula gives the number of gates of the scalable counting 
networks, and if we replace n by 16, this will equal 80 gates, that 
means you can scale the scalable counting networks to 80 cores, and 
beyond 80 cores you will start to have contention.

Second parameter is: a boolean that tells if reference counting is used 
or not, it is by default to true, that means that reference counting is 
used.

About the weak references support: the Weak<T> type supports assignment 
from and to T and makes it usable as if you had a variable of T. It has 
the IsAlive property to check if the reference is still valid and not a 
dangling pointer. The Target property can be used if you want access to 
members of the reference.

Note: the use of the IsAlive property on our weak reference, this tells 
us whether the referenced object is still available, and provides a safe 
way to get a concrete reference to the parent.

I have ported efficient weak references support to Linux by implementing 
efficient code hooking, look at my DSharp.Core.Detour.pas file for Linux 
that i have written to see how i have implemented it in the Linux 
library. Please look at the example.dpr and test.pas demos to see how 
weak references work etc.

Call _AddRef() and _Release() methods to manually increment or decrement 
the number of references to the object.

You can download my library for Windows and Linux from:

https://sites.google.com/site/aminer68/scalable-reference-counting-with-efficient-support-for-weak-references 


- Platform: Windows and Linux(x86)

Language: FPC Pascal v3.1.x+ / Delphi 2007+:

http://www.freepascal.org/

Required FPC switches: -O3 -Sd

-Sd for delphi mode....

Required Delphi switches: -$H+ -DDelphi

For Delphi XE versions and Delphi Tokyo use the -DXE switch

The defines options inside defines.inc are:

{$DEFINE CPU32} for 32 bit systems

{$DEFINE CPU64} for 64 bit systems


Thank you,
Amine Moulay Ramdane.

Back to comp.programming.threads | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

Scalable reference counting with efficient support for weak references version 1.01 computer45 <computer45@cyber.com> - 2018-03-19 20:29 -0400
  Re: Scalable reference counting with efficient support for weak references version 1.01 computer45 <computer45@cyber.com> - 2018-03-19 20:51 -0400

csiph-web