signal: send signal to thread using thread-id. not cpu-id

This commit is contained in:
Tomoki Shirasawa
2016-09-12 15:43:29 +09:00
parent 419f5e495b
commit 9390fe5d2c
3 changed files with 18 additions and 15 deletions

View File

@ -291,7 +291,7 @@ SYSCALL_DECLARE(rt_sigreturn)
extern struct cpu_local_var *clv;
extern unsigned long do_kill(struct thread *thread, int pid, int tid, int sig, struct siginfo *info, int ptracecont);
extern void interrupt_syscall(int all, int pid);
extern void interrupt_syscall(int pid, int tid);
extern int num_processors;
#define RFLAGS_MASK (RFLAGS_CF | RFLAGS_PF | RFLAGS_AF | RFLAGS_ZF | \
@ -1287,7 +1287,7 @@ done:
cpu_restore_interrupt(irqstate);
if (doint && !(mask & tthread->sigmask.__val[0])) {
int cpuid = tthread->cpu_id;
int tid = tthread->tid;
int pid = tproc->pid;
int status = tthread->status;
@ -1298,7 +1298,7 @@ done:
}
if(!tthread->proc->nohost)
interrupt_syscall(pid, cpuid);
interrupt_syscall(pid, tid);
if (status != PS_RUNNING) {
if(sig == SIGKILL){

View File

@ -882,7 +882,7 @@ static void *main_loop_thread_func(void *arg)
struct thread_data_s *td = (struct thread_data_s *)arg;
td->tid = gettid();
td->remote_tid = (int)td->tid;
td->remote_tid = -1;
pthread_barrier_wait(&init_ready);
td->ret = main_loop(td->fd, td->cpu, td->lock);
@ -1680,16 +1680,14 @@ do_generic_syscall(
}
static void
kill_thread(unsigned long cpu)
kill_thread(unsigned long tid)
{
if(cpu >= 0 && cpu < n_threads){
pthread_kill(thread_data[cpu].thread_id, LOCALSIG);
}
else{
int i;
int i;
for (i = 0; i < n_threads; ++i) {
for (i = 0; i < n_threads; ++i) {
if(thread_data[i].remote_tid == tid){
pthread_kill(thread_data[i].thread_id, LOCALSIG);
break;
}
}
}
@ -1848,6 +1846,8 @@ int main_loop(int fd, int cpu, pthread_mutex_t *lock)
//pthread_mutex_lock(lock);
thread_data[cpu].remote_tid = w.sr.rtid;
switch (w.sr.number) {
case __NR_open:
ret = do_strncpy_from_user(fd, pathbuf, (void *)w.sr.args[0], PATH_MAX);
@ -2440,7 +2440,9 @@ return_execve2:
break;
}
thread_data[cpu].remote_tid = -1;
//pthread_mutex_unlock(lock);
}
__dprint("timed out.\n");

View File

@ -847,14 +847,15 @@ terminate_host(int pid)
}
void
interrupt_syscall(int pid, int cpuid)
interrupt_syscall(int pid, int tid)
{
dkprintf("interrupt_syscall,target pid=%d,target cpuid=%d\n", pid, cpuid);
dkprintf("interrupt_syscall,target pid=%d,target tid=%d\n", pid, tid);
ihk_mc_user_context_t ctx;
long lerror;
kprintf("interrupt_syscall pid=%d tid=%d\n", pid, tid);
ihk_mc_syscall_arg0(&ctx) = pid;
ihk_mc_syscall_arg1(&ctx) = cpuid;
ihk_mc_syscall_arg1(&ctx) = tid;
lerror = syscall_generic_forwarding(__NR_kill, &ctx);
if (lerror) {