refactoring to send signal

This commit is contained in:
Tomoki Shirasawa
2015-10-15 17:10:02 +09:00
parent 6ae99454da
commit a325a78866
3 changed files with 131 additions and 133 deletions

View File

@@ -2090,7 +2090,7 @@ out:
void hold_thread(struct thread *thread)
{
if (thread->proc->pstatus & (PS_ZOMBIE | PS_EXITED)) {
if (thread->tstatus == PS_EXITED) {
panic("hold_thread: already exited process");
}
@@ -2130,15 +2130,15 @@ void destroy_thread(struct thread *thread)
struct resource_set *resource_set = cpu_local_var(resource_set);
int hash;
mcs_rwlock_writer_lock(&proc->threads_lock, &lock);
list_del(&thread->siblings_list);
mcs_rwlock_writer_unlock(&proc->threads_lock, &lock);
hash = thread_hash(thread->tid);
mcs_rwlock_writer_lock(&resource_set->thread_hash->lock[hash], &lock);
list_del(&thread->hash_list);
mcs_rwlock_writer_unlock(&resource_set->thread_hash->lock[hash], &lock);
mcs_rwlock_writer_lock(&proc->threads_lock, &lock);
list_del(&thread->siblings_list);
mcs_rwlock_writer_unlock(&proc->threads_lock, &lock);
cpu_clear(thread->cpu_id, &thread->vm->cpu_set, &thread->vm->cpu_set_lock);
list_for_each_entry_safe(pending, signext, &thread->sigpending, list){
list_del(&pending->list);
@@ -2801,7 +2801,7 @@ find_thread(int pid, int tid, struct mcs_rwlock_node_irqsave *lock)
if(thread->tid == tid){
if(pid <= 0)
return thread;
if(pid == thread->proc->pid)
if(thread->proc->pid == pid)
return thread;
}
}
@@ -2833,8 +2833,7 @@ find_process(int pid, struct mcs_rwlock_node_irqsave *lock)
mcs_rwlock_reader_lock(&phash->lock[hash], lock);
list_for_each_entry(proc, &phash->list[hash], hash_list){
if(proc->pid == pid){
if(pid == proc->pid)
return proc;
return proc;
}
}
mcs_rwlock_reader_unlock(&phash->lock[hash], lock);

View File

@@ -606,6 +606,7 @@ terminate(int rc, int sig)
do_kill(mythread, proc->pid, ids[i], SIGKILL, NULL, 0);
}
kfree(ids);
ids = NULL;
}
mcs_rwlock_reader_unlock(&proc->threads_lock, &lock);
@@ -3527,7 +3528,14 @@ SYSCALL_DECLARE(exit)
FUTEX_WAKE, 1, 0, NULL, 0, 0);
}
mcs_rwlock_reader_lock(&proc->threads_lock, &lock);
if(proc->pstatus == PS_EXITED){
mcs_rwlock_reader_unlock(&proc->threads_lock, &lock);
terminate(exit_status, 0);
return 0;
}
thread->tstatus = PS_EXITED;
mcs_rwlock_reader_unlock(&proc->threads_lock, &lock);
release_thread(thread);
schedule();