deadlock with mutex lock

please tell me how to execute this piece ofcode

epthread mutex t first mutex;
pthread mutex t second mutex;
pthread mutex init(&first mutex,NULL);
pthread mutex init(&second mutex,NULL)
/* thread one runs in this function */
void *do work one(void *param) {
pthread mutex lock(&first mutex);
pthread mutex lock(&second mutex);
/**
* Do some work
*/
pthread mutex unlock(&second mutex);
pthread mutex unlock(&first mutex);
pthread exit(0); }
/* thread two runs in this function */
void *do work two(void *param) {
pthread mutex lock(&second mutex);
pthread mutex lock(&first mutex);
/**
* Do some work
*/
pthread mutex unlock(&first mutex);
pthread mutex unlock(&second mutex);
pthread exit(0);
}
Make it pretty -> http://www.cplusplus.com/articles/jEywvCM9/

Make it compile.
There's no point staring at random snippets of thread/mutex code.
There's no telling what important detail you've omitted.
actually i dont know which library i should include in this code
Topic archived. No new replies allowed.