Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

More precision about my inventions that are my SemaMonitor and SemaCondvar and my Monitor..

15 views
Skip to first unread message

amin...@gmail.com

unread,
Jun 24, 2020, 9:17:50 AM6/24/20
to
Hello,


More precision about my inventions that are my SemaMonitor and SemaCondvar and my Monitor..

My 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, read here about it:

https://stackoverflow.com/questions/1368061/whats-the-cost-in-cycles-to-switch-between-windows-kernel-and-user-mode#:~:text=1%20Answer&text=Switching%20from%20%E2%80%9Cuser%20mode%E2%80%9D%20to,rest%20is%20%22kernel%20overhead%22.

You can read about and download my inventions of SemaMonitor and SemaCondvar from here:

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

And the light weight version is here:

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

And i have implemented an efficient Monitor over my SemaCondvar.

Here is the description of my efficient Monitor inside the Monitor.pas file that you will find inside the zip file:

Description:

This is my implementation of a Monitor over my SemaCondvar.

You will find the Monitor class inside the Monitor.pas file 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 with wait() method, but when you set the first parameter of the construtor to false, if the threads are not waiting with the wait() method, the signal will be lost..

Second parameter of the constructor is the kind of Lock, you can set it to ctMLock to use my scalable node based lock called MLock, or you can set it to ctMutex to use a Mutex or you can set it to ctCriticalSection to use the TCriticalSection.

Here is the methods of my efficient Monitor that i have implemented:

TMonitor = class
private
cache0:typecache0;
lock1:TSyncLock;
obj:TSemaCondvar;
cache1:typecache0;

public

constructor Create(bool:boolean=true;lock:TMyLocks=ctMLock);
destructor Destroy; override;
procedure Enter();
procedure Leave();
function Signal():boolean;overload;
function Signal(nbr:long;var remains:long):boolean;overload;
procedure Signal_All();
function Wait(const AMilliseconds:longword=INFINITE): boolean;
function WaitersBlocked():long;

end;


The wait() method is for the threads to wait on the Monitor object for
the signal to be signaled. If wait() fails, that can be that the number
of waiters is greater than high(longword).

And the signal() method will signal one time a waiting thread on the
Monitor object, but if signal() fails , the returned value is false.

the signal_all() method will signal all the waiting threads on
the Monitor object.

The signal(nbr:long;var remains:long) method will signal nbr of
waiting threads, but if signal() fails, the remaining number of signals
that were not signaled will be returned in the remains variable.

and WaitersBlocked() will return the number of waiting threads on
the Monitor object.

and Enter() and Leave() methods to enter and leave the monitor's Lock.


You can download the zip files from:

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

and the lightweight version is here:

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


Thank you,
Amine Moulay Ramdane.

Scott Newman

unread,
Jun 24, 2020, 1:37:31 PM6/24/20
to
As always your code is buggy.
And Pascal is outdated.

0 new messages