求c++信息奥赛考纲和近几年考题,信息奥赛一本通上最新的都是07年的题
你是csp吗
这个是在c++20
之后才支持的,要注意编译器版本,头文件引入#include <semaphore>
,常用模板类counting_semaphore
(初始化需要赋初值counting_semaphore<5> cs(0)
;其中5
是我自己瞎写的表示一次可以被唤醒的线程个数上限。)的模板特化为binary_semaphore
(counting_semaphore
上限为1
的情况) 其中常用的成员函数有release和acquire 。
a. semaphore release == condition_variable notify
b. semaphore acquire == condition_variable wait