Question: Please explain the code line by line in detail. As im so confuse how the code work. The code below is for Deadlock Prevention -

Please explain the code line by line in detail. As im so confuse how the code work.
The code below is for Deadlock Prevention - Hold-and-wait
Code:
void vector_add(vector_t * v_dst, vector_t *v_src ){
pthread_mutex_lock(&global);
pthread_mutex_lock(&v_dst->lock);
pthread_mutex_lock(&v_src->lock);
pthread_mutex_unlock(&global);
int i;
for(i=0; i VECTOR_SIZE; i++){
v_dst->value[i]=v_dst->values[i]+ v_src->values[i];
}
pthread_mutex_unlock(&v_dst->lock);
pthread_mutex_unlock(&v_src>lock);
}
 Please explain the code line by line in detail. As im

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!