Commit b2e23abc authored by Michael Quigley's avatar Michael Quigley
Browse files

updated async IPC

parent 1ddd9781
......@@ -20,7 +20,7 @@
#include <lcd-domains/thc.h>
#include <lcd-domains/thcinternal.h>
#include <lcd-domains/awe-mapper.h>
#include "../ring-chan/ring-channel.h"
#include "ipc.h"
......@@ -78,12 +78,6 @@ static int wait_for_tx_slot(struct ipc_message *imsg)
static int wait_for_rx_slot(struct ipc_message *imsg, bool is_async)
{
while (check_rx_slot_available(imsg)) { //while a slot is not available
if( is_async )
{
THCYield();
}
else
{
#if defined(USE_MWAIT)
monitor_mwait(ecx, &imsg->msg_status, cstate_wait);
#endif//usemwait
......@@ -91,7 +85,6 @@ static int wait_for_rx_slot(struct ipc_message *imsg, bool is_async)
cpu_relax();
#endif
}
}
return 0;
}
......@@ -208,7 +201,6 @@ noinline struct ipc_message *async_recv(struct ttd_ring_channel *rx, unsigned lo
{
struct ipc_message *recv_msg;
printk(KERN_ERR "MESSAGE ID RECEIVED IS: %lx\n", msg_id);
while( true )
{
recv_msg = get_rx_rec(rx, sizeof(struct ipc_message));
......@@ -221,22 +213,19 @@ noinline struct ipc_message *async_recv(struct ttd_ring_channel *rx, unsigned lo
}
else
{
awe_t* other_awe = get_awe_from_msg_id(msg_id);
printk(KERN_ERR "MESSAGE ID RECEIVED IS: %lx\n", recv_msg->msg_id);
printk(KERN_ERR "MESSAGE ID FOR CONTEXT IS: %lx\n", msg_id);
printk(KERN_ERR "CALLING YIELD TO\n");
THCYield();
/*
//THCYieldTo(other_awe);
TODO: Add support for YieldTo
This involves adding a data structure that maps awes to id numbers. This is because the continuation needed is not available at the time the message is sent, so instead an ID can be created and assigned so that when an ASYNC yields, the ID can then be used to correspond to the correct awe.*/
THCYieldToId((uint32_t) recv_msg->msg_id, (uint32_t) msg_id);
}
}
else
{
printk(KERN_ERR "spin yield\n");
THCYield();
THCYieldAndSave((uint32_t) msg_id);
}
}
awe_mapper_remove_id((uint32_t)msg_id);
inc_rx_slot(rx);
return recv_msg;
......
/*
* awe-mapper.c
*
* This file is part of the asynchronous ipc for xcap.
* This file is responsible for providing mappings
* between an integer identifier and a pointer to
* an awe struct.
*
* Author: Michael Quigley
* Date: January 2016
*/
#include <linux/bug.h>
#include "awe-mapper.h"
#define AWE_TABLE_COUNT 4
/*
* NOTE: This implementation right now is just a ring buffer.
* In the future, we probably want to change this to something
* like a red black tree or a B-tree to account for differing
* storage size requirements.
*/
static void* awe_table[AWE_TABLE_COUNT];
static uint32_t used_slots = 0;
//The address of this is used to indicate that something is
//allocated and not set to an awe_ptr yet.
static uint32_t allocated_marker = 0;
/*
* Initilaizes awe mapper.
*/
void awe_mapper_init(void){/*Does nothing for now.*/}
/*
* Uninitilaizes awe mapper.
*/
void awe_mapper_uninit(void){/*Does nothing for now.*/}
static bool is_slot_allocated(uint32_t id)
{
return awe_table[id] != NULL;
}
/*
* Returns new available id.
*/
uint32_t awe_mapper_create_id(void)
{
static uint32_t next_id = 0;
BUG_ON((used_slots >= AWE_TABLE_COUNT) && "Too many slots have been requested.");
do
{
next_id = (next_id + 1) % AWE_TABLE_COUNT;
}
while( is_slot_allocated(next_id) );
awe_table[next_id] = &allocated_marker;
used_slots++;
return next_id;
}
/*
* Marks provided id as available
*/
void awe_mapper_remove_id(uint32_t id)
{
BUG_ON(id >= AWE_TABLE_COUNT);
if(used_slots > 0)
{
used_slots--;
}
awe_table[id] = NULL;
}
/*
* Links awe_ptr with id.
*/
void awe_mapper_set_id(uint32_t id, void* awe_ptr)
{
BUG_ON(id >= AWE_TABLE_COUNT);
awe_table[id] = awe_ptr;
}
/*
* Returns awe_ptr that corresponds to id.
*/
void* awe_mapper_get_awe_ptr(uint32_t id)
{
BUG_ON(id >= AWE_TABLE_COUNT);
return awe_table[id];
}
/*
* awe-mapper.h
*
* This file is part of the asynchronous ipc for xcap.
* This file is responsible for providing mappings
* between an integer identifier and a pointer to
* an awe struct.
*
* Author: Michael Quigley
* Date: January 2016
*/
//#include <stddef.h>
//#include <stdint.h>
//#include <stdbool.h>
#include <linux/types.h>
#ifndef AWE_MAPPER_H
#define AWE_MAPPER_H
/*
* Initilaizes awe mapper.
*/
void awe_mapper_init(void);
/*
* Uninitilaizes awe mapper.
*/
void awe_mapper_uninit(void);
/*
* Returns new available id.
*/
uint32_t awe_mapper_create_id(void);
/*
* Marks provided id as available
*/
void awe_mapper_remove_id(uint32_t id);
/*
* Links awe_ptr with id.
*/
void awe_mapper_set_id(uint32_t id, void* awe_ptr);
/*
* Returns awe_ptr that corresponds to id.
*/
void* awe_mapper_get_awe_ptr(uint32_t id);
#endif
......@@ -5,10 +5,9 @@ EXTRA_CFLAGS=-DDEBUG_OUTPUT
INC_DIR = ../../IPC
CFLAGS_ipc.o = -O2 -DPOLL
CFLAGS_ring-channel.o = -I$(INC_DIR)
CFLAGS_awe-mapper.o = -I/users/mquigley/fast-ipc-module/current/awe-mapper
DEPS= $(INC_DIR)/ipc.h
rpc_testing-objs := ../../IPC/ipc.o ../../ring-chan/ring-channel.o ../../awe-mapper/awe-mapper.o callee.o caller.o rpc_test.o
rpc_testing-objs := ../../IPC/ipc.o ../../ring-chan/ring-channel.o callee.o caller.o rpc_test.o
KDIR := /lib/modules/`uname -r`/build
......@@ -18,4 +17,3 @@ clean:
make -C $(KDIR) M=$(PWD) clean
rm ../../IPC/ipc.o
rm ../../ring-chan/ring-channel.o
rm ../../awe-mapper/awe-mapper.o
#include <linux/random.h>
#include <linux/slab.h>
#include "../../awe-mapper/awe-mapper.h"
#include "rpc.h"
#include <lcd-domains/thc.h>
#include <lcd-domains/thcinternal.h>
#include <lcd-domains/awe-mapper.h>
static struct ttd_ring_channel *channel;
......@@ -81,11 +81,11 @@ static unsigned long add_nums(unsigned long trans, unsigned long res1)
return result;
}
static unsigned long add_nums_async(unsigned long trans, unsigned long res1, awe_t* awe)
static unsigned long add_nums_async(unsigned long trans, unsigned long res1, unsigned long msg_id)
{
struct ipc_message *msg;
unsigned long result;
unsigned long msg_id = (unsigned long)awe;
//unsigned long msg_id = (unsigned long)awe;
printk(KERN_ERR "MESSAGE ID IS: %lx\n", msg_id);
msg = get_send_slot(channel);
msg->fn_type = ADD_NUMS;
......@@ -208,12 +208,29 @@ static void test_async_ipc(void* chan)
res4 = res3 + res2;
res5 = res4 + res3;
DO_FINISH(
uint32_t id_num;
while (num_transactions < TRANSACTIONS / 3) {
// start = RDTSC_START();
ASYNC(add_nums_async(num_transactions, 1, awe););
ASYNC(add_nums_async(num_transactions, 2, awe););
ASYNC(add_nums_async(num_transactions, 3, awe););
ASYNC(
id_num = awe_mapper_create_id();
printk(KERN_ERR "ID_NUM: %d\n", id_num);
add_nums_async(num_transactions, 1,(unsigned long) id_num);
);
ASYNC(
id_num = awe_mapper_create_id();
printk(KERN_ERR "ID_NUM: %d\n", id_num);
add_nums_async(num_transactions, 2,(unsigned long) id_num);
);
ASYNC(
id_num = awe_mapper_create_id();
printk(KERN_ERR "ID_NUM: %d\n", id_num);
add_nums_async(num_transactions, 3,(unsigned long) id_num);
);
// end = RDTSCP();
// pr_err("%lu\n", end-start);
num_transactions++;
......@@ -253,7 +270,6 @@ static void test_sync_ipc(void* chan)
num_transactions++;
}
pr_err("Complete\n");
return 1;
}
int callee(void *chan)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment