-
Content Count
2977 -
Joined
-
Last visited
-
Days Won
106
Everything posted by dummzeuch
-
spinlock primitives
dummzeuch replied to dummzeuch's topic in Algorithms, Data Structures and Class Design
I'm writing my own spinlock to get a feel for what can be done. One of my programs shows some odd behavior when using a critical section so I tried to see whether this changes when switching to a spin lock. It seemed to work at first, but my last test failed miserably so I'm "going home" now. Quite possible, but since these require API calls, they have a significant overhead in the best case (no spinning required). I knew about Sleep(0) vs. Sleep(1), but wasn't that supposed to be changed in Windows Vista and later? (reading the second link) OK, apparently not. But since the threads in question are running with the same priority, Sleep(0) should work fine. Apart from that: the above code was just an example, how to prevent running a single CPU system at 100%. -
spinlock primitives
dummzeuch replied to dummzeuch's topic in Algorithms, Data Structures and Class Design
You mean instead of Sleep()? I haven't thought much about that case yet. Using doTryLock it with sleep which gives a much higher throughput than doLock or a Critical Section in my tests on my computer. But I am not yet sure whether this makes any difference in a real world scenario. Apparently there the is the Pause instruction on Intel CPUs: https://stackoverflow.com/questions/4725676/how-does-x86-pause-instruction-work-in-spinlock-and-can-it-be-used-in-other-sc I'll have to look into it. -
spinlock primitives
dummzeuch replied to dummzeuch's topic in Algorithms, Data Structures and Class Design
Yes, thats how a SpinLock is supposed to work, isn't it? That's why I added the doTryLock function which could be used like this: while not doTryLock(Lck) do Sleep(0); -
GExperts 1.3.18 experimental twm 2021-02-21 released
dummzeuch replied to dummzeuch's topic in GExperts
Does anybody else have this compile error? -
GExperts 1.3.18 experimental twm 2021-02-21 released
dummzeuch replied to dummzeuch's topic in GExperts
Hm, that's odd: I just checked out the sources to a new directory and run the build script. Compiled fine. (Bloody license server is acting up again, so I can't load it into the IDE right now.) -
GExperts 1.3.18 experimental twm 2021-02-21 released
dummzeuch replied to dummzeuch's topic in GExperts
Oddly enough, the file is right there: In Directory Source\UsesExpert: (Maybe it doesn't really belong in this directory because it's used by a unit in framework) I'm not sure what causes the compile error, but I will investigate. Did you compile in the IDE or via the build script? -
GExperts 1.3.18 experimental twm 2021-02-21 released
dummzeuch replied to dummzeuch's topic in GExperts
Not the genie, the GExpert 😉 -
GExperts 1.3.18 experimental twm 2021-02-21 released
dummzeuch replied to dummzeuch's topic in GExperts
Please no discussion about Covid here. -
I just committed a dproj file for Delphi 10.4 (GExpertsGrep.10-4.dproj) This works for me. The automatically converted Delphi 2007 dproj file didn't work for me either.
-
Hiding a public property in a descendant class
dummzeuch replied to Cristian Peța's topic in RTL and Delphi Object Pascal
Ouch! Wtf did they declare it public in TCustomEdit? Most not-yet-published properties of other components are declared protected. But there are exceptions there too: TCustomLabel.Caption is also public. Why? (Yes, I know, I won't get any definite answer here unless some Borland employee talked about it in the 1990s.) -
I always compile that tool with Delphi 2007. I currently can't test whether it compiles with Delphi 10.4 due a a connection problem with the license server. I have only seen that with Delphi 2007 before. It happens every time a Windows update deletes the files that the Delphi 2007 installer put into that directory. After I copied them back and everything compiled normally.
-
... and other older posts in this topic.
-
How do you identify bottleneck in Delphi code?
dummzeuch replied to Mike Torrettinni's topic in Tips / Blogs / Tutorials / Videos
Hey, I am the German here (*1). But now you sound like one. 😉 Spoilsport! (*1: Of course I am not the only German here.) -
Hiding a public property in a descendant class
dummzeuch replied to Cristian Peța's topic in RTL and Delphi Object Pascal
You won't have any functionality introduced in TEdit, only the one in TCustomEdit and whatever you implement yourself in TMyEdit. That probably was obvious. 😉 If you declare the property as public, it won't show up in the Object Inspector. For that it needs to be published. -
How do you identify bottleneck in Delphi code?
dummzeuch replied to Mike Torrettinni's topic in Tips / Blogs / Tutorials / Videos
You forgot one important reason to optimize: The pure fun of it. 😉 -
By default the IDE enables optimization and disables Range checking and Overflow checking. I've always found that odd, because I want the best possible compiler support for debugging which means: Optimization off Range checking on Overflow checking on
-
atomic setting of a double variable
dummzeuch posted a topic in Algorithms, Data Structures and Class Design
I need to set a double variable in a thread safe manner. I could, of course use some synchronization object, e.g. a critical section, but on the other hand there is InterlockedExchange64, which sets the contents of a 64 bit integer variable, and a double is also 64 bits, so I thought this should also be possible in the same manner. Unfortunately that function, while described as part of the WinAPI, doesn't seem to actually be a WinAP function but implemented as a C macro in winnt.h and in assembler in Delhpi 10.2. Google found DsiInterlockedExchange64 in the OmniThreadLibrary unit DSiWin32, which implements it in assembler for Win32 and Win64. I took that code and came up with the following for atomically setting a double variable: procedure InterlockedSetDouble(var target: double; Value: double); asm {$IFDEF CPUX64} lock xchg [target], value mov rax, value {$ELSE} { -> EAX target } { ESP+4 value } PUSH EDI PUSH EBX MOV EDI, EAX MOV EBX, DWORD PTR [value] MOV ECX, DWORD PTR [value+4] @@1: LOCK CMPXCHG8B [EDI] JNZ @@1 POP EBX POP EDI {$ENDIF ~CPUX64} end; { InterlockedSetDouble } I am for now only interested in 32 bit Windows where this seems to work, but being far from an assembler expert, I wonder whether I might be missing something. -
atomic setting of a double variable
dummzeuch replied to dummzeuch's topic in Algorithms, Data Structures and Class Design
Did you test it? Since access to 32 bit aligned memory is faster, it's quite possible that the compiler generates code that aligns all parameters, regardless of size (I didn't test it either though). But the parameter target might not be aligned. That depends on what is passed into that procedure. -
Maybe PasDoc?
-
Delphi Native Code: Fast or Reliable?
dummzeuch replied to Mike Torrettinni's topic in Tips / Blogs / Tutorials / Videos
Yes, he is correct. I had to restore those files several times after a Windows update. Not sure whether that's a Microsoft/Windows or a Borland/Codegear/Delphi 2007 problem. Are we supposed to add additional target files to the dotNet installation directory? -
Delphi Native Code: Fast or Reliable?
dummzeuch replied to Mike Torrettinni's topic in Tips / Blogs / Tutorials / Videos
There were a few changes to Windows that required changes to Delphi programs but these were mostly minor and I don't remember most of them. One that comes to mind was that the known ways to prevent the screen saver from activating stopped working one after another. I think I had to change that code at least 3 times to make it work for XP, Windows 7 and then Windows 10. Then of course there was the major headache of UAC Virtualization and the corresponding entries to the manifest. But that was mostly because I did not keep up with the Delphi versions so I had to fix Delphi 2007 projects to manage these correctly. And more recently there was high DPI and scaling. Again, these could be solved at least partly by updating to the latest Delphi versions. I have no experience with dotNET, so I can't compare. -
Splitting existing components to run- and design time packages
dummzeuch replied to aehimself's topic in General Help
Actually there was a time (in the 1990ies) when we did exactly that: Recompile the whole VCL/RTL in our projects. Mostly because we had to fix some bugs. These bugs were fixed by Borland (Yes, there was a time where this happened quickly.), so we stopped doing that. It also became impossible to simply recompile the RTL because it required some assembler. As for components: Yes, I still compile them from sources in programs that do not use packages. I want to be sure that the source code I see while debugging is the actual source code used in the program. Given Delphi's compile speed it doesn't really matter much. But we degrees. Of course every program has its own dcu output path. Sharing that between multiple programs is a really bad idea. -
How to determine the subjective brightness of my screen?
dummzeuch replied to Der schöne Günther's topic in Algorithms, Data Structures and Class Design
Actually he wants to adjust the room lighting: -
Splitting existing components to run- and design time packages
dummzeuch replied to aehimself's topic in General Help
Ok, what is wrong with this: Are you sure it's not there (I think I looked it up back then, but my memory might be faulty). Or are you referring to mentioning "Borland" rather than "Embarcadero"? -
Splitting existing components to run- and design time packages
dummzeuch replied to aehimself's topic in General Help
There is a page in the Delphi wiki on creating packages. https://delphi.fandom.com/wiki/Creating_Packages Edit: I had totally forgotten that I wrote that page myself (many years ago). After reading through it, I must say I still like it. There isn't much I'd change today.