My question is related to MUTEX
- I am using trylock_for() and trylock_until() function to protect my critical section. But after sometime my MBED os crash !!! why ??? I have attached image of terminal for more information.
- I cant understand how these function work. according to me when first thread enter in to critical section at that time MUTEX flag set for time mentioned in function bracket. After time elapsed mutex automatically unlock that . so next thread can enter into block. Am I right ???
But when next thread (suppose T2) enter at same time all other threads (which are standing at door) also enter in my critical section. Why ? why second thread not set mutex lock for other ?
I attached my code here :
void common_block(const char *name,int state)
printf("\n This %s Thread arrive at door with state %d \n",name,state);
Lock.trylock_until(1); //lock for 3000 ms
printf("\n Inside the door %s with state %d \n",name,state);
wait(02); //some how process stuck in wait state
printf("\n Thread %s is Ouside wait period with state %d \n",name,state);
void fun(void const *arg)
common_block((const char *)arg,0); //PASS STATE 0
common_block((const char *)arg,1);// PASS STATE 1
Why ??? OS crashed not immediately ???