say I have 3 types of threads:
//Thread_1:
lock(mutex)
while(t1_unexceptable_cond){
wait(t1_cv, mutex);
}
//TAKE RESOURCES
if(should_signal_T2){
signal(t2_cv, mutex)
} else {
signal(t1_cv, mutex)
}
unlock(mutex)
//DO THINGS WITH RESOURCES
lock(mutex)
//RETURN RESOURCES
unlock(mutex)
//Thread_2:
lock(mutex)
while(t2_unexceptable_cond){
wait(t2_cv, mutex);
}
//ACQUIRE RESOURCES
if(should_signal_T2){
signal(t2_cv, mutex)
} else {
signal(t1_cv, mutex)
}
unlock(mutex)
//DO THINGS WITH RESOURCES
lock(mutex)
//RETURN RESOURCES
unlock(mutex)
//Thread_3:
lock(mutex)
//DO THINGs
unlock(mutex)
If I have a series of thread_1s and thread_2s waiting on the mutex, will a thread_3 starve since the other threads are getting signaled? I would assume the other threads would go first upon waking up, thus instances of thread_3 would never get a chance to run. Is my thought process correct here?