From 10190e9ed69f7dff7a943954e405830b425d3b15 Mon Sep 17 00:00:00 2001 From: Tomoki Shirasawa Date: Fri, 25 Jul 2014 09:17:43 +0900 Subject: [PATCH] prepare for a condition variable for each process. (Redmine#193) --- executer/kernel/control.c | 7 ++++--- executer/kernel/mcctrl.h | 2 +- executer/kernel/syscall.c | 4 ++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/executer/kernel/control.c b/executer/kernel/control.c index 4b0c837d..3a3bd6ae 100644 --- a/executer/kernel/control.c +++ b/executer/kernel/control.c @@ -330,12 +330,13 @@ retry_alloc: } wqhln->pid = pid; + wqhln->req = 0; init_waitqueue_head(&wqhln->wq_syscall); list_add_tail(&wqhln->list, &c->wq_list); } ihk_ikc_spinlock_unlock(&c->wq_list_lock, flags); - c->req = 1; + wqhln->req = 1; wake_up(&wqhln->wq_syscall); return 0; @@ -388,6 +389,7 @@ retry_alloc: } wqhln->pid = swd.pid; + wqhln->req = 0; init_waitqueue_head(&wqhln->wq_syscall); irqflags = ihk_ikc_spinlock_lock(&c->wq_list_lock); @@ -403,7 +405,7 @@ retry_alloc: list_add_tail(&wqhln->list, &c->wq_list); ihk_ikc_spinlock_unlock(&c->wq_list_lock, irqflags); - ret = wait_event_interruptible(wqhln->wq_syscall, c->req); + ret = wait_event_interruptible(wqhln->wq_syscall, wqhln->req); /* Remove per-process wait queue head */ irqflags = ihk_ikc_spinlock_lock(&c->wq_list_lock); @@ -427,7 +429,6 @@ retry_alloc: return -EINTR; } - c->req = 0; #if 1 mb(); if (!c->param.request_va->valid) { diff --git a/executer/kernel/mcctrl.h b/executer/kernel/mcctrl.h index 26c5adcb..0266068f 100644 --- a/executer/kernel/mcctrl.h +++ b/executer/kernel/mcctrl.h @@ -93,6 +93,7 @@ struct wait_queue_head_list_node { struct list_head list; wait_queue_head_t wq_syscall; int pid; + int req; }; struct mcctrl_channel { @@ -101,7 +102,6 @@ struct mcctrl_channel { struct ikc_scd_init_param init; void *dma_buf; - int req; struct list_head wq_list; ihk_spinlock_t wq_list_lock; }; diff --git a/executer/kernel/syscall.c b/executer/kernel/syscall.c index a748fdf2..e35f1e0e 100644 --- a/executer/kernel/syscall.c +++ b/executer/kernel/syscall.c @@ -255,6 +255,7 @@ retry_alloc: /* Prepare per-process wait queue head */ wqhln->pid = current->tgid; + wqhln->req = 0; init_waitqueue_head(&wqhln->wq_syscall); irqflags = ihk_ikc_spinlock_lock(&channel->wq_list_lock); @@ -271,7 +272,7 @@ retry_alloc: ihk_ikc_spinlock_unlock(&channel->wq_list_lock, irqflags); /* wait for response */ - error = wait_event_interruptible(wqhln->wq_syscall, channel->req); + error = wait_event_interruptible(wqhln->wq_syscall, wqhln->req); /* Remove per-process wait queue head */ irqflags = ihk_ikc_spinlock_lock(&channel->wq_list_lock); @@ -283,7 +284,6 @@ retry_alloc: printk("remote_page_fault:interrupted. %d\n", error); goto out; } - channel->req = 0; if (!req->valid) { printk("remote_page_fault:not valid\n"); }