????????????????????????????POSIX?????????????????????????е???????????????????????????????????????????????У????????????????????????н??????????

????????????????????????????????????????????????????????????????????????????????????????κ?????????????????????????????

???????????????????pthread_mutex_t???????????<bits/pthreadtypes.h>???о??????塣

????1???????????????????

/* Initialize a mutex.  */
int pthread_mutex_init (pthread_mutex_t *__mutex?? __const pthread_mutexattr_t *__mutexattr);

/* Destroy a mutex.  */
int pthread_mutex_destroy (pthread_mutex_t *__mutex);

?????????????????????????????????????????

?????????????????????????????????????г?????????£?

pthread_mutex_t mlock = PTHREAD_MUTEX_INITIALIZER;

???????????????pthread_mutex_init()???г?????????????????????????????????????г???????????????????г??????pthread_mutex_init()???????????????????????????????????????????????????NULL??

???????????????????????????????pthread_mutex_destroy()????????????????????

????2??????????????????

/* ?????????????????? */
int pthread_mutexattr_init (pthread_mutexattr_t *__attr);

/* ????????????????  */
int pthread_mutexattr_destroy (pthread_mutexattr_t *__attr);

/* ?????????????????????乲???????? */
int pthread_mutexattr_getpshared (__const pthread_mutexattr_t *__restrict __attr?? int *__restrict __pshared);

/* ????????????????????????乲????? */
int pthread_mutexattr_setpshared (pthread_mutexattr_t *__attr?? int __pshared);

?????????????????????pthread_mutex_init????????????????????????????NULL???????????????????

????????????????????????pthread_mutexattr_t????????????????????????????????????????????????????????????ò?????????????????????????????г???????????????????????pthread_mutexattr_setpshared???????????????????????????乲????????????????????????????????????????????????λ?????????????????

????pthread_mutexattr_setpshared()??????????????__pshared?????趨??????乲????????????PTHREAD_PROCESS_PRIVATE??PTHREAD_PROCESS_SHARED???????????y???乲???

??????????????????????????乲?????1????

pthread_mutex_t *pSharedMutex;  //?????????????????
pthread_mutexattr_t mutexAttr;  //??????????

pSharedMutex = /*??????????????????*/;

pthread_mutexattr_init(&mutexAttr);
pthread_mutexattr_setpshared(&mutexAttr?? PTHREAD_PROCESS_SHARED);
pthread_mutex_init(pSharedMutex?? &mutexAttr);

????3?????????????

/* Try locking a mutex.  */
int pthread_mutex_trylock (pthread_mutex_t *__mutex);

/* Lock a mutex.  */
int pthread_mutex_lock (pthread_mutex_t *__mutex);

/* Unlock a mutex.  */
int pthread_mutex_unlock (pthread_mutex_t *__mutex);

??????????????????????pthread_mutex_lock()??????÷?????????????????????????????????????????????ú???????????????????????????????? pthread_mutex_trylock()??????????????????????????????????????????EBUSY????????????????????????pthread_mutex_unlock() ????????????????????????????????????????

????????????????????????????????????????????????

?????????????????????????????????????????????????????????????????????????????????????????????????ж??????????????????????????????????????????????????????????????????????????CPU?????????