C++ Polling with Sleep vs. Condition Variables

C++ Polling with Sleep vs. Condition Variables

In multithreaded programming, if we let a waiting thread continuously check whether a condition is met in a loop, and if it is, continue executing the corresponding processing operation, and if not, sleep for a while, can this achieve the same effect as using condition variables? The method of polling with sleep can indeed implement … Read more

A Classic Set of Embedded Interview Questions!

A Classic Set of Embedded Interview Questions!

1. What is variable scope? The variable scope determines the visibility and lifetime of a variable. In embedded systems, a correct understanding of scope directly relates to memory usage efficiency and system stability. Code Example: // Global variable – visible throughout the program's lifetime int global_var = 0; void func() { // Local variable – … Read more

A Classic Set of Embedded Interview Questions!

A Classic Set of Embedded Interview Questions!

Follow our official account to keep the embedded knowledge flowing! 1. Can you explain variable scope? The variable scope determines the visibility and lifetime of a variable. In embedded systems, understanding scope correctly directly relates to memory usage efficiency and system stability. Code Example: // Global variable – visible throughout the program's lifecycle int global_var … Read more

Is the Unexpected Wake-up of Condition Variables in Linux C a Bug?

Is the Unexpected Wake-up of Condition Variables in Linux C a Bug?

Hello everyone, I am the Intelligence Guy~ Most of you must have used condition variables (<span><span>pthread_cond_t</span></span>) in embedded Linux system programming. However, when I first used them, I was not aware of the issue of false wake-ups. You might have suspected this was a bug in Linux, but later research revealed that this is not … Read more