Commit f8487ff3 authored by Pankaj Kumar's avatar Pankaj Kumar

Fixed the locking issue in code, Added function call to release cnode lock...

Fixed the locking issue in code, Added function call to release cnode lock after calling lcd_cnode_get in testcase, Changed testcases output messages
parent 1d9e003b
......@@ -65,7 +65,7 @@ struct cdt_root_node * get_cdt_root(void)
#ifdef KERNEL
cdt_node = kmem_cache_alloc(cdt_cache.cdt_root_cache, 0);
#else
cdt_node = (struct cdt_root_node*)malloc(1 * sizeof(struct cdt_root_node));
cdt_node = malloc(1 * sizeof(*cdt_node));
#endif
cdt_node->state = ALLOCATION_VALID;
#ifdef KERNEL
......@@ -174,6 +174,15 @@ int __lcd_cap_init_cspace(struct cspace *cspace)
exit(-1);
}
#endif
/*
* Initialized cdt locking
*/
ret = __lcd_cap_init();
if (ret < 0) {
LCD_ERR("CDT cache initialization failed\n");
return ret;
}
/*
* Initialize the cnode table cache. We can't use the
......@@ -634,7 +643,7 @@ static int try_delete_cnode(struct cspace *cspace, struct cnode *cnode)
#ifdef KERNEL
if (!mutex_trylock(&cnode->cdt_root->lock)) {
#else
if (!pthread_mutex_lock(&cnode->cdt_root->lock)) {
if (pthread_mutex_lock(&cnode->cdt_root->lock)) {
#endif
/*
* Tell caller to retry
......
......@@ -33,9 +33,9 @@ int testcase1()
ret = __lcd_cap_init_cspace(csp);
if (ret < 0)
printf("cspace Initialization Passed. Address:%p \n", csp);
printf("Cspace Initialization Failed!!\n");
else
printf("cspace Initialization Failed!!\n");
printf("Cspace Initialization Passed Address:%p \n", csp);
/* cptr cache intialization. This is totally users stuff */
cache = malloc (1 * sizeof(*cache));
......@@ -54,7 +54,7 @@ int testcase1()
ret = __lcd_cap_insert(csp, slot_out, p, LCD_CAP_TYPE_PAGE);
if (ret) {
LCD_ERR("set up cspace");
LCD_ERR("cap insertion failed\n");
goto fail;
}
......@@ -69,13 +69,16 @@ int testcase1()
else
printf("Capability lookup failed!!!\n");
}
/* Release cnode Lock */
__lcd_cnode_put(check);
/* Capability deletion from cspace.
* Presently, I am getting an issue in this functionality.
* Some locking issue. I am working on it.
* For now, I am commenting the code.
*/
/*
slot_out_orig = slot_out;
__lcd_cap_delete(csp, slot_out);
printf("Old=0x%lx New=0x%lx\n", cptr_val(slot_out_orig), cptr_val(slot_out));
......@@ -87,12 +90,11 @@ int testcase1()
LCD_ERR("Lookup failed\n");
//goto fail;
} else {
if (check->object == p)
if (check1->object == p)
printf("Screwed!!!\n");
else
printf("Yippiee!!!\n");
}
*/
/* Free the cspace
* Here we will destory the cspace.
......
Markdown is supported
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