AnsweredAssumed Answered

Deadlock example in C using MQX Lite

Question asked by Dandan Huang on Nov 18, 2015
Latest reply on Nov 18, 2015 by soledad

Hi there,

 

I'm pretty new to multithread, but I need to write a test case for Deadlock condition. Saw an example using mutex, but with pthread.

Thread 1:

pthread_mutex_lock(&m1);

pthread_mutex_lock(&m2);

pthread_mutex_unlock(&m2);

pthread_mutex_unlock(&m1);

Thread 2:

pthread_mutex_lock(&m2);

pthread_mutex_lock(&m1);

pthread_mutex_unlock(&m1);

pthread_mutex_unlock(&m2);

 

How should I re-write it here?

 

Thanks a lot!

Vivian

Outcomes