I am quite a newbie to c programming. Until now i only found pthread_mutex_lock can make the code region run only by one thread. Does there are any other ways to implement a lock? Or every other way to do a lock is still use pthread_mutex_lock function?
I am quite a newbie to c programming. Until now i only found pthread_mutex_lock
Share
Threads were only introduced into the ISO C standard with C11, a rather recent edition to the standard so not necessarily widely supported yet.
You need to look into
threads.hand themtx_*functions for an understanding of that.Before then,
pthreadswas probably your best bet with its wide implementation although, not being standard C (a), its support wasn’t mandated.For example, Windows has its own way of doing threading, using functions like
CreateThread.However, there are various third-party products such as pthreads-win32 that aim to give pthreads support to Windows, to assist in porting of applications from POSIX-compliant operating systems.
(a) It is a POSIX standard (part of IEEE 1003.1) so that may be good enough for some people.