Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Threads and locks problem Consider the code written by Harry Q. Bovik for the following problem. Please assume that all necessary header files are included
Threads and locks problem
Consider the code written by Harry Q. Bovik for the following problem. Please assume that all necessary header files are included in the code and all system calls and accessory functions always succeed. You may assume that the locks have been initialized correctly in main(), which we do not show. Bovik comes to you and complains that funel () seems to misbehave. Is he lying or is there something wrong with his code? Defend your answer in 1-3 sentences. 2. Bovik is complaining about func2 () as well. He insists to your boss that this program sometimes hangs and your boss would like your opinion. Is Bovik lying again or is there a problem? Defend your answer in 1-3 sentences. pthread_mutex_r , count_1, .l_count; int ref_count, tid_1, tid_2, tid_3, tid_4; void .threadl(void .vargp) { tid_2 = pthroad_self(); pthread_mutex_lock (count_1); ref_count++; pthread_mutex_unlock (count_l); return(0); } void .thread2(void .vargp) ( tid_1 = pthread_self(); pthread_mutex_lock (count_l); pthread_kill(pthread_self (), SIGKILL); ref_count++; pthread_mutex_unlock (count_l); return(0); } void .thread3(void .vargp) (tid_3 = pthread_self(); pthread_mutex_lock (count_l); pthread_mutex_lock (l_count); ref_count++; pthread_mutex_unlock (l_count); pthread_mutex_unlock (count_l); return(0); void .thread4(void .vargp) tid_4 = pthread_self(); pthread_mutex_lock (l_count); pthread_mutex_lock (count_l); ref_count --; pthread_mutex_unlock (l_count); pthroad_mutex_unlock (count_l); return(0); }Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started