add terminate thread

This commit is contained in:
Tomoki Shirasawa
2013-09-02 00:39:22 +09:00
parent 1d69225532
commit 040fb64b22
11 changed files with 154 additions and 32 deletions

View File

@@ -300,11 +300,8 @@ err:
return -ENOMEM;
}
static void process_msg_init(struct ikc_scd_init_param *pcp)
static void process_msg_init(struct ikc_scd_init_param *pcp, struct syscall_params *lparam)
{
struct syscall_params *lparam;
lparam = &cpu_local_var(scp);
lparam->response_va = allocate_pages(RESPONSE_PAGE_COUNT, 0);
lparam->response_pa = virt_to_phys(lparam->response_va);
@@ -313,12 +310,14 @@ static void process_msg_init(struct ikc_scd_init_param *pcp)
pcp->response_page = lparam->response_pa;
}
static void process_msg_init_acked(unsigned long pphys)
static void process_msg_init_acked(struct ihk_ikc_channel_desc *c, unsigned long pphys)
{
struct ikc_scd_init_param *param = (void *)pphys;
struct syscall_params *lparam;
lparam = &cpu_local_var(scp);
if(cpu_local_var(syscall_channel2) == c)
lparam = &cpu_local_var(scp2);
lparam->request_rpa = param->request_page;
lparam->request_pa = ihk_mc_map_memory(NULL, param->request_page,
REQUEST_PAGE_COUNT * PAGE_SIZE);
@@ -380,7 +379,7 @@ static int syscall_packet_handler(struct ihk_ikc_channel_desc *c,
switch (packet->msg) {
case SCD_MSG_INIT_CHANNEL_ACKED:
dkprintf("SCD_MSG_INIT_CHANNEL_ACKED\n");
process_msg_init_acked(packet->arg);
process_msg_init_acked(c, packet->arg);
return 0;
case SCD_MSG_PREPARE_PROCESS:
@@ -434,9 +433,36 @@ void init_host_syscall_channel(void)
get_this_cpu_local_var()->syscall_channel = param.channel;
process_msg_init(&cpu_local_var(iip));
process_msg_init(&cpu_local_var(iip), &cpu_local_var(scp));
pckt.msg = SCD_MSG_INIT_CHANNEL;
pckt.ref = ihk_mc_get_processor_id();
pckt.arg = virt_to_phys(&cpu_local_var(iip));
syscall_channel_send(param.channel, &pckt);
}
void init_host_syscall_channel2(void)
{
struct ihk_ikc_connect_param param;
struct ikc_scd_packet pckt;
param.port = 502;
param.pkt_size = sizeof(struct ikc_scd_packet);
param.queue_size = PAGE_SIZE;
param.magic = 0x1329;
param.handler = syscall_packet_handler;
dkprintf("(syscall) Trying to connect host ...");
while (ihk_ikc_connect(NULL, &param) != 0) {
dkprintf(".");
ihk_mc_delay_us(1000 * 1000);
}
dkprintf("connected.\n");
get_this_cpu_local_var()->syscall_channel2 = param.channel;
process_msg_init(&cpu_local_var(iip2), &cpu_local_var(scp2));
pckt.msg = SCD_MSG_INIT_CHANNEL;
pckt.ref = ihk_mc_get_processor_id();
pckt.arg = virt_to_phys(&cpu_local_var(iip2));
syscall_channel_send(param.channel, &pckt);
}

View File

@@ -31,9 +31,12 @@ struct cpu_local_var {
size_t runq_len;
struct ihk_ikc_channel_desc *syscall_channel;
struct syscall_params scp;
struct ikc_scd_init_param iip;
struct ihk_ikc_channel_desc *syscall_channel2;
struct syscall_params scp2;
struct ikc_scd_init_param iip2;
int status;
int fs;

View File

@@ -13,6 +13,7 @@ extern void kmalloc_init(void);
extern void ap_start(void);
extern void ihk_mc_dma_init(void);
extern void init_host_syscall_channel(void);
extern void init_host_syscall_channel2(void);
extern void sched_init(void);
extern void pc_ap_init(void);

View File

@@ -188,6 +188,7 @@ static void post_init(void)
if (find_command_line("hidos")) {
init_host_syscall_channel();
init_host_syscall_channel2();
}
ap_start();
}

View File

@@ -75,47 +75,73 @@ static void do_mod_exit(int status);
static void send_syscall(struct syscall_request *req)
{
struct ikc_scd_packet packet;
struct syscall_response *res = cpu_local_var(scp).response_va;
struct syscall_response *res;
unsigned long fin;
int w;
struct syscall_params *scp;
struct ihk_ikc_channel_desc *syscall_channel;
int cpu;
if(req->number == __NR_exit_group){
extern int num_processors;
scp = &get_cpu_local_var(0)->scp2;
syscall_channel = get_cpu_local_var(0)->syscall_channel2;
cpu = num_processors;
}
else{
scp = &cpu_local_var(scp);
syscall_channel = cpu_local_var(syscall_channel);
cpu = ihk_mc_get_processor_id();
}
res = scp->response_va;
res->status = 0;
req->valid = 0;
memcpy_async(cpu_local_var(scp).request_pa,
memcpy_async(scp->request_pa,
virt_to_phys(req), sizeof(*req), 0, &fin);
memcpy_async_wait(&cpu_local_var(scp).post_fin);
cpu_local_var(scp).post_va->v[0] = cpu_local_var(scp).post_idx;
memcpy_async_wait(&scp->post_fin);
scp->post_va->v[0] = scp->post_idx;
w = ihk_mc_get_processor_id() + 1;
w = cpu + 1;
memcpy_async_wait(&fin);
barrier();
cpu_local_var(scp).request_va->valid = 1;
*(unsigned int *)cpu_local_var(scp).doorbell_va = w;
scp->request_va->valid = 1;
*(unsigned int *)scp->doorbell_va = w;
#ifdef SYSCALL_BY_IKC
packet.msg = SCD_MSG_SYSCALL_ONESIDE;
packet.ref = ihk_mc_get_processor_id();
packet.arg = cpu_local_var(scp).request_rpa;
packet.ref = cpu;
packet.arg = scp->request_rpa;
ihk_ikc_send(cpu_local_var(syscall_channel), &packet, 0);
ihk_ikc_send(syscall_channel, &packet, 0);
#endif
}
int do_syscall(struct syscall_request *req, ihk_mc_user_context_t *ctx)
{
struct syscall_response *res = cpu_local_var(scp).response_va;
struct syscall_response *res;
struct syscall_request req2;
struct syscall_params *scp;
int error;
dkprintf("SC(%d)[%3d] sending syscall\n",
ihk_mc_get_processor_id(),
req->number);
if(req->number == __NR_exit_group){
scp = &get_cpu_local_var(0)->scp2;
}
else{
scp = &cpu_local_var(scp);
}
res = scp->response_va;
send_syscall(req);
dkprintf("SC(%d)[%3d] waiting for host.. \n",