## 面試時間:2024/11 ### 1. What's data race? * Ans: > 多個執行緒在沒有同步保護的情況下,同時存取(讀或寫)共享變數,其中至少有一個是寫操作 ### 2. What's difference between thread and process in Linux? * Ans: >* Process:每個Process擁有獨立的記憶體空間,Process之間是隔離的。 >* Thread:Thread是Process內的執行單位,共享進程的記憶體空間,Thread間需要同步。 ### 3. What's the bootloader in emedded system? * Ans: > 在嵌入式系統中,Bootloader是一段在系統開機或重置時執行的程式。它的主要功能是初始化硬體,並將主應用程式(或作業系統)從非揮發性記憶體載入到記憶體中。 ### 4. Plan a scheme for sending a batch of data for one IOT device to another IOT device. * Ans: >1. 數據格式:將數據以結構化格式(如 JSON 或 Protocol Buffers)序列化。 >2. 選擇協議:使用輕量級的協議如 MQTT,它支援低帶寬且可靠的傳輸。 >3. 分批處理與分塊:如果數據量大,將其分成多個塊(chunk),每塊傳送時附加序列號以便接收端重組。 >4. 傳輸過程: >* 發送端使用 MQTT 將數據塊發送到指定主題,並等待接收確認。 >* 接收端訂閱主題並接收數據塊,收到後重組並處理。 >5. 錯誤處理:使用檢查碼(如 CRC)來檢查數據的完整性,並在丟失或錯誤時進行重傳。 ### 5. Design a C program to calculate n-factorial by calling a recursive function. * Ans: ``` int factorial(int n) { if (n == 0 || n == 1) { return 1; } return n * factorial(n - 1); } ``` ### 6. What variable stored on the stack? ``` extern int ohNo; static int hello; int ohyeah; const int *p; const int *const x; void f(int a, int b) { a++; printf("a: %d", a); printf("b: %d", b++); } ``` * Ans: > a and b ### 7. Which code cannot pass? Why? ``` const int a=10; const int *p=&a; const int *const b=&a; int *const c=&a; int main(int argc, char *argv[]) { p++; a++; b++; c++; } ``` * Ans: > a++; b++; c++;