Search the Community
Showing results for tags 'threads'.
Found 6 results
-
Background first, if you please: RadStudio 12.2, in C++ on Windows 11. Monitors status information from up to 4 microprocessor nodes using TTL to USB converters. Each node is a separate board with its own interface. Ideally, I use a serial port package in C++ which (non-blocking) reads a package and updates a data panel on the display. Decoding the packet is no problem, getting it, is. Communication is in ASCII encoded packets to avoid premature terminating zeros, so string reads will work. Tried the APRO interface, but documentation seems to be lacking, with lots of features in the packages I don't need and no basic startup information. Tried the BOOST rabbit hole, which I somewhat got to work (gotta love the documentation (if any)). and then lost the solution. It seems to be blocking only, which I could tolerate if I could create a task. I could do this with a microprocessor, it would simply mirror the drivers in the hardware, using FreeRTOS tasks to read each port (one task = 1 port), and tasks can be blocking without a problem. Anybody know of a well documented serial package that can do non-blocking reads, C++ compatible? Then I need to do multiple threads, haven't looked at that yet in C++. I don't really have a problem with C++, but the add-ons are a problem. Got the UI (more or less customizable) up and running, custom buttons (made from panels) can be enabled/disabled with different text for pressed, different colors when active. so the C++ is not a problem. Thanks in advance Harvey
- 8 replies
-
- c++
- serial data
-
(and 2 more)
Tagged with:
-
There have been a lot of questions in this forum about running python code in threads using Python4Delphi. I have created a comprehensive guide in this Wiki topic.
-
Communicating from one thread to another and the latter "talking" to a Dbgrid.
promero posted a topic in General Help
Hello Dear Friends, I have a problem and I would like to hear your opinion. It's in Delphi 11.2 I have 2 threads, one that "prepares" emails from templates and another, which is the one that sends them. The first thread, which manufactures/prepares the emails, stores them in an 'EMAILS' table in a SQLITE database, ready to be sent. It is inside a Task class. It works ok. The second thread actually sends the emails recorded in the 'EMAILS' table to the recipients. It is based on the Thread class. With every email sent, it updates the "SENT" column from EMAILS table, with "true" value. What I need: -I need the first thread "notify" the second thread "hey, I sent you lot of new emailss, please send them": that's it: send it a signal. If the second thread don't receive that signal, let it remain paused. -That the second threads, also sends an update of the sent emails to another process. This process is simply a Dbgrid showing the EMAILS table with a Column "Sent". I want that view to update 'sent' column...that is, to shows what the second thread is doing. Some suggestions? Many thanks Friends -
This is a simplified version of what I had in my app. procedure Test(); var TerminateProc: TThreadProcedure; S: string; begin S := 'Terminated'; TerminateProc := procedure begin ShowMessage(S); end; TThread.CreateAnonymousThread( procedure begin // Do stuff TThread.Queue(nil, TerminateProc); TerminateProc := nil; // Memory leak without this end).Start; end; I had to insert the statement with the comment "Memory leak without this" to avoid memory leaks. Any idea why the compiler does not free TerminateProc on its own? Is this a compiler bug?
- 4 replies
-
- anonymousmethods
- threads
-
(and 1 more)
Tagged with:
-
Here is the problem (a bit of a long message) - I'm writing a threaded program to run on workstations with dual Xeons. Each of the Xeons has eight hyperthreaded cores. (I've read https://www.delphipraxis.net/113427-beginthreadaffinity-setthreadaffinity.html but I don't think it helps me.) Dual-Xeon systems have Non-Uniform Memory Access (NUMA) - each of the Xeons have direct access to their own memory, but they can access memory on the other Xeon - but it takes a long time for a thread running on one Xeon to access memory on the other Xeon. The bottleneck in the program is accessing memory. I have the program set so I can adjust the number of threads it is running. As I test from 1 up to 16 threads, performance improves. TaskManager/performance/Resource meter shows that all 16 threads are running on one Xeon. But if I go to 17 threads or more, it hurts performance (compared to 16 threads on one Xeon). What must be happening is that threads 17 and above are executing on the second Xeon but their memory must be on the first Xeon. That's the problem. I've tried to set the affinity for each thread to a particular CPU and hope it uses that CPU for its memory, but setting the affinity inside a thread isn't working at all (even with only one thread, it runs on all CPUs.) What I have right now is I limit an instance of the program to running 16 threads and I have the affinity set to run on the first Xeon. Then I start a second instance of the program - it checks to see if the first instance is running, and if so, it sets its affinity to run on the second Xeon. Then I merge the results later (which isn't an ideal situation). This is working, with double the performance of running on one Xeon, but it is no different from running on two computers, each with one Xeon. So is there a way to get one instance to use all 32 available CPUs with full performance? (If I could assign each thread and its memory to a particular CPU, that should fix the problem, but I haven't been able to do that.)
-
When I create FDQuery in threads, should I set CmdExecMode to amNonBlocking or leave amBlocking? http://docwiki.embarcadero.com/Libraries/Tokyo/en/FireDAC.Stan.Option.TFDResourceOptions.CmdExecMode