To get the uptime of the operating system use getElapsedMilliseconds or getElapsedTicks . Locks In order to keep your application thread safe you can use locks. With locks you can prevent an other thread to access a variable, function, ... in an unsafe state. Example for conflicting threads: void mainThread () { InitTask (thread2); while ( true ) { Serial. println ( " Thread1 " ); } } void thread2 () { while ( true ) { Serial. println ( " Thread2 " ); } } If you execute this code you will notice that it will output something strange like: 1hrThd2adTh Tadea T eared1hrThd2adTh Tadea T This is because while one thread is writing into the serial it will be interrupted by the other thread. In order to prevent this you can use locks. With the method GetLockObject you can create a instance of a lock object. Example: lock *serialLock = GetLockObject(); With AquireLock(serialLock) you can now lock the object. To release it use ReleaseLock(serialLock) . Example: void setup () { Serial. begin ( 9600 ); KernelInitializer::InitializeKernel (mainThread); } lock *serialLock = GetLockObject(); void mainThread () { InitTask (thread2); while ( true ) { AquireLock (serialLock); Serial. println ( " Thread1 " ); ReleaseLock (serialLock); } } void thread2 () { while ( true ) { AquireLock (serialLock); Serial. println ( " Thread2 " ); ReleaseLock (serialLock); } } The output will now be like expected: Thread1 Thread2 Thread1 Thread2
First seen: 2025-08-23 13:38
Last seen: 2025-08-23 17:39