Note that there are some explanatory texts on larger screens.

plurals
  1. POIs it a good idea to give a real time clock its own thread?
    text
    copied!<p>I'm fairly new to Real Time programming/multithreading and I'm trying to get some practical development under my belt. I'm trying to code a program (in C) for a school project that performs several tasks, including image processing (openCV), serving webpages (with a library like libmicrohttpd), and interfacing with a peripheral. This program will be heavily threaded, with each task basically running independently. </p> <p>A very central part of this program is event/data logging and setting the clock on a peripheral, which requires the computer's onboard time. That is to say, more than one of the threads will require the current time as part of its task. So my question is, is it a better idea to declare a global time struct and call gettime as it's needed in individual threads, or to have a separate thread that always maintains the current time, which every thread then just reads from? The former sounds like it could have access issues, while the second sounds challenging to update at the proper frequency.</p> <p>To give a more detailed idea of the tasks that I'm doing: </p> <ul> <li>I'm saving an image and a text log containing the time, whenever opencv detects a certain object </li> <li>I'm recording the times of the last ten packets received from the peripheral (it's a very low data rate connection)</li> <li>The peripheral doesn't have an onboard RTC, so this program will set it when it connects or drifts too far off. </li> </ul> <p>Thanks for any advice. </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload