Skip to content

cf_make_sem

Category: multithreading
GitHub: cute_multithreading.h


Returns an initialized semaphore.

CF_Semaphore cf_make_sem(int initial_count);
Parameters Description
initial_count The initial value of the semaphore.

Remarks

Semaphores are used to prevent race conditions between multiple threads that need to access common resources. Usually you'll have N resources, and initialize the semaphore to N. This is a rather advanced and low-level topic, beware. To learn more about semaphores I suggest reading the online book "The Little Book of Semaphores".

CF_Semaphore
cf_sem_value
cf_destroy_sem
cf_sem_post
cf_sem_try
cf_sem_wait