summaryrefslogtreecommitdiff
path: root/src/lib/tests
diff options
context:
space:
mode:
authordimitri staessens <[email protected]>2016-05-07 16:11:09 +0200
committerdimitri staessens <[email protected]>2016-05-07 16:11:09 +0200
commiteb9f44379d5316e7f7e9311d7a66d2041eca743a (patch)
tree2489605a42bb2c9582c0c4e912c2de0c40512b2a /src/lib/tests
parentde8f2015cbd015b1cced366cb12c054be62c23b1 (diff)
downloadouroboros-eb9f44379d5316e7f7e9311d7a66d2041eca743a.tar.gz
ouroboros-eb9f44379d5316e7f7e9311d7a66d2041eca743a.zip
irmd: flow allocation and fast path
This commit has a first implementation of flow allocation (the "slow path") and read/write (the "fast path") for ouroboros. It provides basic but unstable communications over the shared memory. It required a lot of changes all over the stack, and fixes a number of previously undetected issues. This PR still need heavy revision regarding data model, locking and cleanup. lib/dev: modifications to the API. It now uses an ap_init() call to set the AP name and sets the Instance ID to the pid of the process. It also binds the AP to the shared memory and creates tables for mappings in the fast path. A call to ap_fini() releases the resources. lib/shm_ap_rbuff: added ring buffer for data exchange between processes in the fast path. It passes an index in the shm_du_map. lib/shm_du_map: rewrote API to work with calls from dev.c. Garbage collector added. Tests updated to new API. ipcpd/ipcp-data: removed everything related to flows, as these are universal for all ap's and kept in ap_data (dev.c), or similar structs for shim ipcps. shim-udp: added flow allocator and read/write functions and shm elements. irmd: revised data model and structures necessary for flow allocation. tools: echo updated to new dev.h API. messaging system was updated to comply with new flow allocation messages. All exchanges use pid and port_id to bootstrap the fast path.
Diffstat (limited to 'src/lib/tests')
-rw-r--r--src/lib/tests/shm_du_map_test.c53
1 files changed, 29 insertions, 24 deletions
diff --git a/src/lib/tests/shm_du_map_test.c b/src/lib/tests/shm_du_map_test.c
index 85a82e4d..55938a62 100644
--- a/src/lib/tests/shm_du_map_test.c
+++ b/src/lib/tests/shm_du_map_test.c
@@ -32,7 +32,7 @@
#include <ouroboros/logs.h>
-#define SIZE_OF_DU_BUFF 24
+#define SIZE_OF_DU_BUFF 32
#define TEST_BUFF_SIZE (SHM_DU_BUFF_BLOCK_SIZE - SIZE_OF_DU_BUFF)
#define MAX(a,b) (a > b ? a : b)
@@ -44,7 +44,7 @@ void * produce()
{
struct shm_du_map * dum;
long test_buf_size = 0;
- uint8_t * test_values;
+ uint8_t * test_values;
int headspace;
int tailspace;
long i;
@@ -66,9 +66,8 @@ void * produce()
test_values[i] = 170;
clock_gettime(CLOCK_MONOTONIC, &starttime);
- for (i = 1; i < SHM_BLOCKS_IN_MAP; i++) {
- struct shm_du_buff * sdb;
- size_t len;
+ for (i = 1; i < 16 * SHM_BLOCKS_IN_MAP; i++) {
+ size_t len;
test_buf_size = TEST_BUFF_SIZE;
@@ -77,21 +76,19 @@ void * produce()
len = test_buf_size - (headspace + tailspace);
- sdb = shm_create_du_buff(dum,
- test_buf_size,
- headspace,
- test_values,
- len);
-
- if (sdb != NULL) {
- bytes_written += len;
- }
- else {
- sync = -2;
- break;
+ if (shm_create_du_buff(dum,
+ test_buf_size,
+ headspace,
+ test_values,
+ len) < 0) {
+ continue;
}
+
+ bytes_written += len;
}
+ sync = -2;
+
clock_gettime(CLOCK_MONOTONIC, &stoptime);
elapsed =(stoptime.tv_sec + stoptime.tv_nsec / 1000000000.0) -
(starttime.tv_sec + starttime.tv_nsec / 1000000000.0);
@@ -104,13 +101,14 @@ void * produce()
sync = -1;
+ shm_du_map_close(dum);
+
return 0;
}
void * consume()
{
struct shm_du_map * dum;
-
struct timespec ts;
ts.tv_sec = 0;
@@ -123,10 +121,15 @@ void * consume()
return (void *)-1;
}
- while (!sync) {
- while (!shm_release_du_buff(dum));
- nanosleep(&ts, NULL);
+ while (true) {
+ shm_release_du_buff(dum, 1823429173941);
+ if (sync)
+ break;
}
+ nanosleep(&ts, NULL);
+
+
+ shm_du_map_close(dum);
return 0;
}
@@ -149,7 +152,7 @@ int shm_du_map_test(int argc, char ** argv)
return -1;
}
- shm_du_map_close(dum);
+ shm_du_map_destroy(dum);
LOG_INFO("done.");
@@ -165,7 +168,7 @@ int shm_du_map_test(int argc, char ** argv)
pthread_create(&consumer, NULL, consume, NULL);
pthread_join(consumer, NULL);
- shm_du_map_close(dum);
+ shm_du_map_destroy(dum);
LOG_INFO("done.");
@@ -173,6 +176,8 @@ int shm_du_map_test(int argc, char ** argv)
LOG_INFO("starting concurrency test.");
+ sync = 0;
+
dum = shm_du_map_create();
res1 = (int) pthread_create(&producer, NULL, produce, NULL);
@@ -181,7 +186,7 @@ int shm_du_map_test(int argc, char ** argv)
pthread_join(producer, NULL);
pthread_join(consumer, NULL);
- shm_du_map_close(dum);
+ shm_du_map_destroy(dum);
LOG_INFO("done.");