Thread priority over Main program
Posted: Mon Aug 12, 2024 9:06 pm
Hello All,
I am new to working with threads and need to understand better how priority settings affect other tasks.
My project barrows the example code in the help file section for < CreateSemaphore()> It is Producer/consumer code . I have attempted using this approach in an RS485 sniffer program for a proprietary messaging protocol. I have a thread created that will gather serial data and stuff it in to a shared List. The main program then processes the data in to meaningful messages, writes them to a file and strips the processed data of the top of the list. The problem I have run into is the Data processing in the main seems to go through the data faster than the serial thread can populate the List object. I found this very surprising as the data processing portion is a bit complex, at least to me. The serial data is streaming at about 100millisecond message interval. This is about half the speed I anticipate once I get beyond the simulation stage I have tried a very high ThreadPriority() to the Producer but the main still out runs the producer thread. Do I need to put the Data processing in to a separate thread as well, taking it out of the main line code?
I am new to working with threads and need to understand better how priority settings affect other tasks.
My project barrows the example code in the help file section for < CreateSemaphore()> It is Producer/consumer code . I have attempted using this approach in an RS485 sniffer program for a proprietary messaging protocol. I have a thread created that will gather serial data and stuff it in to a shared List. The main program then processes the data in to meaningful messages, writes them to a file and strips the processed data of the top of the list. The problem I have run into is the Data processing in the main seems to go through the data faster than the serial thread can populate the List object. I found this very surprising as the data processing portion is a bit complex, at least to me. The serial data is streaming at about 100millisecond message interval. This is about half the speed I anticipate once I get beyond the simulation stage I have tried a very high ThreadPriority() to the Producer but the main still out runs the producer thread. Do I need to put the Data processing in to a separate thread as well, taking it out of the main line code?