--- tags: linux2024 --- # [2024q1](http://wiki.csie.ncku.edu.tw/linux/schedule) 第 8 週測驗題 :::info 目的: 檢驗學員對 concurrency 的認知 ::: ==[作答表單: 測驗 1](https://docs.google.com/forms/u/1/d/e/1FAIpQLSfySr3ZaZklgus-_XkC1uXmdfoG9hZAvlYhCaz9Eflpu41U7w/viewform)== (針對 Linux 核心「設計」課程) ### 測驗 `1` [task](https://gist.github.com/jserv/745dab1d9be33a9a635b193aeb53191e) 是個運用 coroutine 實作的任務排程器,允許搭配 POSIX Thread 使用,使用 C11 Atomics 和 x86-64 組合語言開發。 編譯方式: ```shell $ gcc -O2 -Wall -Wextra -std=gnu11 \ -o test_task \ test_task.c task.c \ -lpthread ``` 參考執行輸出: ``` test_task_start test_task_sleep test_task_pause test_task_exit test_task_order test_task_detach ``` 預期不會觸發任何 assert。 作答規範: * AAAA 和 CCCC 是 bool 型態,亦即 `true` 或 `false` * BBBB 是 C11 Atomics 提供的函式 * 以最精簡的形式書寫