• More of my philosophy about my inventions of SemaCondvar and SemaMonito

    From Amine Moulay Ramdane@21:1/5 to All on Fri Nov 4 15:11:43 2022
    Hello,



    More of my philosophy about my inventions of SemaCondvar and SemaMonitor and about technology and more of my thoughts..

    I am a white arab, and i think i am smart since i have also
    invented many scalable algorithms and algorithms..


    I think i am highly smart since I have passed two certified IQ tests and i have scored "above" 115 IQ, and my following new invention of SemaCondvar doesn't have spurious wakeups, and spurious wakeup happens when a thread wakes up from waiting on a
    condition variable that's been signaled, only to discover that the condition it was waiting for isn't satisfied. It's called spurious because the thread has seemingly been awakened for no reason, and my following inventions that are my SemaMonitor and
    SemaCondvar are fast pathed when the count of my SemaMonitor or my SemaCondvar is greater than 0, so in this case the wait() method stays on the user mode and it doesn't switch from user mode to kernel mode that costs around 1500 CPU cycles and that is
    expensive, the signal() method is also fast pathed when there is no item in the queue and count is less than MaximumCount, and here is my inventions:


    Author: Amine Moulay Ramdane.

    Description: SemaCondvar and SemaMonitor are new and portable synchronization objects , SemaCondvar combines some of the characteristics of a semaphore and all the characteristics of a condition variable and if you want the signal(s) to not be lost, you
    can configure it by passing a parameter to the constructor, SemaMonitor combines some of the characteristics of a semaphore and all the characteristics of an eventcount , and if you want the signal(s) to not be lost, you can configure it by passing a
    parameter to the constructor, they only use an event object and and a very fast and very efficient and portable lock.

    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.

    You will find the SemaMonitor and SemaCondvar classes inside the SemaMonitor.pas and SemaCondvar.pas files inside the zip file.

    When you set the first parameter of the constructor to true, the signal will not be lost if the threads are not waiting for the SemaCondvar or SemaMonitor objects, but when you set the first parameter of the construtor to false, if the threads are not
    waiting for the SemaCondvar or SemaMonitor the signal will be lost..

    Now you can pass the SemaCondvar's or Semamonitor's initialcount and SemaCondvar's or SemaMonitor's MaximumCount to the construtor, it's like the windows Semaphore`s InitialCount and the Semaphore's MaximumCount and it is where the signal(s) will be
    recorded.

    Like this:

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

    If you set it with ctMLock, it will use my scalable node based lock called MLock, you can set it to ctMutex to use a Mutex or to ctCriticalSection to use the TCriticalSection.


    And you can download them from my website here:

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

    And here:

    https://sites.google.com/site/scalable68/semacondvar-semamonitor


    More my philosophy about Closures and generic Lambdas and about technology and more of my thoughts..

    I am a white arab, and i think i am smart since i have also
    invented many scalable algorithms and algorithms..


    I think i am highly smart since I have passed two certified IQ tests and i have scored "above" 115 IQ, i think that Delphi and Freepascal and C++ have implemented and supported typed Lambdas, and i think that Delphi will soon support generic Lambdas,
    and i think that C++ 20 supports all the following: typed Lambdas and generic Lambdas and templated Lambdas, but i think that the abstraction with generic Lambdas and Closures can play the role of how we use message passing with channels in Go and
    passing the data and not using a Lock , but hiding it so that to avoid race conditions in parallel programming, so i think that there is not only the methodology of Rust with the Rust's ownership system so that to avoid race conditions, but there is also
    a methodology in Delphi and C++ with generic Lambdas and Closures, and it consists of hiding the Lock inside the closure and passing the Lambdas that will be executed inside another Lambda inside the closure so that to avoid race conditions in parallel
    programming, and of course you have to be disciplined so that to avoid to use global data , but you have to create the data (and i think you can also use C/C++ or Delphi or Freepascal _alloca function that i am talking about below so that to allocate
    size bytes of space from the Stack) and pass it with the Lambdas.


    More of my philosophy about non-linear regression and about technology and more of my thoughts..

    I think i am highly smart since I have passed two certified IQ tests and i have scored "above" 115 IQ, so the R-squared is invalid for non-linear regression, so you have to use the standard error of the estimate (Mean Square Error), and of course you
    have to calculate the Relative standard error that is the standard deviation of the mean of the sample divide by the Estimate that is the mean of the sample, and i think that the Relative standard Error is
    an important thing that brings more quality to the statistical calculations, and i will now talk to you more about my interesting software project for mathematics, so my new software project uses artificial intelligence to implement a generalized way
    with artificial intelligence using the software that permit to solve the non-linear "multiple" regression, and it is much more powerful than Levenberg–Marquardt algorithm , since i am implementing a smart algorithm using artificial intelligence that
    permits to avoid premature
    convergence, and it is also one of the most important thing, and
    it will also be much more scalable using multicores so that to search with artificial intelligence much faster the global optimum, so i am
    doing it this way so that to be professional and i will give you a tutorial that explains my algorithms that uses artificial intelligence so that you learn from them, and of course it will automatically calculate the above Standard error of the estimate
    and the Relative standard Error.

    More of my philosophy about non-linear regression and more..

    I think i am really smart, and i have also just finished quickly the software implementation of Levenberg–Marquardt algorithm and of the Simplex algorithm to solve non-linear least squares problems, and i will soon implement a generalized way with
    artificial intelligence using the software that permit to solve the non-linear "multiple" regression, but i have also noticed that in mathematics you have to take care of the variability of the y in non-linear least squares problems so that to
    approximate, also the Levenberg–Marquardt algorithm (LMA or just LM) that i have just implemented , also known as the damped least-squares (DLS) method, is used to solve non-linear least squares problems. These minimization problems arise especially in
    least squares curve fitting. The Levenberg–Marquardt algorithm is used in many software applications for solving generic curve-fitting problems. The Levenberg–Marquardt algorithm was found to be an efficient, fast and robust method which also has a
    good global convergence property. For these reasons, It has been incorporated into many good commercial packages performing non-linear regression. But my way of implementing the non-linear "multiple" regression in the software will be much more powerful
    than Levenberg–Marquardt algorithm, and of course i will share with you many parts of my software project, so stay tuned !

    More of my philosophy about C# and Delphi and about technology and more of my thoughts..


    I invite you to read the following article:

    Why C# coders should shut up about Delphi

    Read more here:

    https://jonlennartaasenden.wordpress.com/2016/10/18/why-c-coders-should-shut-up-about-delphi/


    More of my philosophy about Delphi and Freepascal compilers and about technology and more of my thoughts..

    According to the 20th edition of the State of the Developer Nation report, there were 26.8 million active software developers in the world at the end of 2021, and from the following article on Delphi programming language, there is 3.25% Delphi software
    developers this year, so it is around 1 million Delphi software developers in 2022. Here are the following articles, read them carefully:

    https://blogs.embarcadero.com/considerations-on-delphi-and-the-stackoverflow-2022-developer-survey/

    And read here:

    https://www.future-processing.com/blog/how-many-developers-are-there-in-the-world-in-2019/


    I think i am highly smart since I have passed two certified IQ tests and i have scored "above" 115 IQ, of course that i have already programmed in C++, for example you can download my Open source software project of Parallel C++ Conjugate Gradient Linear
    System Solver Library that scales very well from my website here:

    https://sites.google.com/site/scalable68/scalable-parallel-c-conjugate-gradient-linear-system-solver-library

    But why do you think i am also programming in Delphi and Freepascal ?

    Of course that Delphi and Freepascal compilers support modern Object Pascal, it is not only Pascal, but it is modern Object Pascal, i mean
    that modern Object Pascal of for example Delphi and Freepascal support object oriented programming and support Anonymous methods or typed Lambdas , so i think that it is a decent programming language, even if i know that the new C++ 20 supports generic
    Lambdas and templated Lambdas, but i think that Delphi will soon also support generic Lambdas, and in Delphi and Freepascal compilers there is no big runtime like in C# and such compilers, so you get small native executables in Delphi
    and Freepascal, and inline assembler is supported by both Delphi
    and Freepascal, and Lazarus the IDE of Freepascal and Delphi come
    both with one of the best GUI tools, and of course you can make .SO, .DLL, executables, etc. in both Delphi and Freepascal, and both Delphi
    and Freepascal compilers are Cross platform to Windows, Linux and Mac
    and Android etc. , and i think that modern Object Pascal of Delphi
    or Freepascal is more strongly typed than C++ , but less strongly typed than ADA programming language, but i think that modern Object Pascal of Delphi and Freepascal are not Strict as the programming language ADA and are not strict as the programming
    language Rust or the pure functional programming languages, so it can also be flexible and advantageous to not be this kind of strictness, and the compilation times of Delphi is extremely fast , and of course Freepascal supports the Delphi mode so that
    to be compatible with Delphi and i can go on and on, and it is why i am also programming in Delphi and Freepascal.

    And you can read about the last version 11.2 of Delphi from here:

    https://www.embarcadero.com/products/delphi

    And you can read about Freepascal and Lazarus from here:

    https://www.freepascal.org/

    https://www.lazarus-ide.org/


    More of my philosophy about Asynchronous programming and about the futures and about the ActiveObject and about technology and more of my thoughts..

    I am a white arab, and i think i am smart since i have also
    invented many scalable algorithms and algorithms..


    I think i am highly smart since I have passed two certified IQ tests and i have scored "above" 115 IQ, i think from my new implementation of
    future below, you can notice that Asynchronous programming is not a simple task, since it can get too much complicated , since you can
    notice in my implementation below that if i make the starting of the thread of the future out of the constructor and if i make the passing of the parameter as a pointer to the future out of the constructor , it
    will get more complex to get the automaton of how to use
    and call the methods right and safe, so i think that there is
    still a problem with Asynchronous programming and it is that
    when you have many Asynchronous tasks or threads it can get
    really complex, and i think that it is the weakness of Asynchronous programming, and of course i am also speaking of the implementation
    of a sophisticated ActiveObject or a future or complex Asynchronous programming.


    More of my philosophy about my new updated implementation of a future and about the ActiveObject and about technology and more of my thoughts..



    I think i am highly smart since I have passed two certified IQ tests and i have scored "above" 115 IQ, so i have just updated my implementation
    of a future, and now both the starting the thread of the future and the passing the parameter as a pointer to the future is made from the constructor so that to make safe the system of the automaton of the how to use and call the methods, and I have just
    added support for exceptions, so you have to know that programming with futures is asynchronous programming, but so that to be robust the future implementation has to deal correctly with "exceptions", so in my implementation of a future when an exception
    is raised inside the future you will receive the exception, so i have implemented two things: The HasException() method so that to detect the exception from inside the future, and the the exception and its address is returned as a string in the
    ExceptionStr property, and my implementation of a future does of course support passing parameters as a pointer to the future, also my implementation of a future works in Windows and Linux, and of course you can also use my following more sophisticated
    Threadpool engine with priorities as a sophisticated ActiveObject or such and pass the methods or functions and there parameters to it, here it is:

    Threadpool engine with priorities

    https://sites.google.com/site/scalable68/threadpool-engine-with-priorities

    And stay tuned since i will enhance more my above Threadpool engine with priorities.

    So you can download my new updated portable and efficient implementation of a future in Delphi and FreePascal version 1.32 from my website here:

    https://sites.google.com/site/scalable68/a-portable-and-efficient-implementation-of-a-future-in-delphi-and-freepascal


    And here is a new example program of how to use my implementation of a future in Delphi and Freepascal and notice that the interface has changed a little bit:


    --

    program TestFuture;

    uses system.SysUtils, system.Classes, Futures;

    type

    TTestFuture1 = class(TFuture)
    public
    function Compute(ptr:pointer): Variant; override;
    end;

    TTestFuture2 = class(TFuture)
    public
    function Compute(ptr:pointer): Variant; override;
    end;

    var obj1:TTestFuture1;
    obj2:TTestFuture2;
    a:variant;


    function TTestFuture1.Compute(ptr:pointer): Variant;
    begin

    raise Exception.Create('I raised an exception');

    end;

    function TTestFuture2.Compute(ptr:pointer): Variant;
    begin

    writeln(nativeint(ptr));
    result:='Hello world !';

    end;


    begin

    writeln;

    obj1:=TTestFuture1.create(pointer(12));

    if obj1.GetValue(a) then writeln(a)
    else if obj1.HasException then writeln(obj1.ExceptionStr);

    obj1.free;

    writeln;

    obj2:=TTestFuture2.create(pointer(12));


    if obj2.GetValue(a) then writeln(a);

    obj2.free;

    end.

    ---



    More of my philosophy about quantum computing and about matrix operations and about scalability and more of my thoughts..


    I think i am highly smart since I have passed two certified IQ tests and i have scored "above" 115 IQ, i have just looked at the following
    video about the powerful parallel quantum computer of IBM from USA that will be soon available in the cloud, and i invite you to look at it:

    Quantum Computing: Now Widely Available!

    https://www.youtube.com/watch?v=laqpfQ8-jFI


    But i have just read the following paper and it is saying that the powerful Quantum algorithms for matrix operations and linear systems of equations are available, read about them on the below paper, so as you notice in the following paper that many
    matrix operations and also the linear systems of equations solver can be done in a quantum computer, read about it here in the following paper:

    Quantum algorithms for matrix operations and linear systems of equations

    Read more here:

    https://arxiv.