Skip to content

julio981007/thread-safe-counter

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

thread-safe-counter

  1. Compare performance => Input = 10000

Mutex: 0.001 sec tscounter

Semaphore: 1.412 sec sem_counter

  1. Analysis(why?) => Mutex : Only one thread holding the lock enters (A mutex can be unlocked by who locked it)

Semaphore : Multiple enters with a counter (There is no lock owner concept)

Mutex use hardware for only one thread. In contrast, Semaphore use hardware for many threads. Therefore, Mutex is faster than Semaphore.

  1. OS environment => WSL2

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C 100.0%