uti: Replace dead uti thread with new mcexec thread in proc->tids

Change-Id: Ic6e906dd1bfac1b07f1317732cbe0a5191831cd8
This commit is contained in:
Masamichi Takagi
2018-09-03 18:02:35 +09:00
parent 96aab7e215
commit 04d4145b3e
7 changed files with 68 additions and 16 deletions

View File

@@ -2623,6 +2623,21 @@ void __release_tid(struct process *proc, struct thread *thread) {
}
}
/* Replace tid specified by thread with tid specified by new_tid */
void __find_and_replace_tid(struct process *proc, struct thread *thread, int new_tid) {
int i;
for (i = 0; i < proc->nr_tids; ++i) {
if (proc->tids[i].thread != thread) continue;
proc->tids[i].thread = NULL;
proc->tids[i].tid = new_tid;
kprintf("%s: tid %d (thread %p) has been relaced with tid %d\n",
__FUNCTION__, thread->tid, thread, new_tid);
break;
}
}
void destroy_thread(struct thread *thread)
{
struct sig_pending *pending;
@@ -2646,7 +2661,11 @@ void destroy_thread(struct thread *thread)
mcs_rwlock_writer_lock(&proc->threads_lock, &lock);
list_del(&thread->siblings_list);
__release_tid(proc, thread);
if (thread->uti_state == UTI_STATE_EPILOGUE) {
__find_and_replace_tid(proc, thread, thread->uti_refill_tid);
} else {
__release_tid(proc, thread);
}
mcs_rwlock_writer_unlock(&proc->threads_lock, &lock);
mcs_rwlock_writer_unlock(&proc->update_lock, &updatelock);