From 4e56fe682e6ad34c161aa40c06af4e3e0088962e Mon Sep 17 00:00:00 2001 From: Samo Penic <samo.penic@gmail.com> Date: Fri, 22 Nov 2013 19:29:14 +0000 Subject: [PATCH] Testing of paralel algorithm with mutexes and tainting. Still no success. It seems tainting and untainting does not works as suspected --- src/vertex.c | 32 ++++++++++++++++++++++++++++++++ 1 files changed, 32 insertions(+), 0 deletions(-) diff --git a/src/vertex.c b/src/vertex.c index 38647aa..9fc96be 100644 --- a/src/vertex.c +++ b/src/vertex.c @@ -311,3 +311,35 @@ return vlist; } + + + +ts_bool vertex_taint(ts_vertex *vtx, ts_uint level){ + ts_uint i; + vtx->locked++; //lock current vertex + if(level==0){ //if we reach last in recursion exit + return TS_SUCCESS; + } + for(i=0; i<vtx->neigh_no; i++){ //else recursive call self with decreased level + vertex_taint(vtx->neigh[i], level-1); + } + return TS_SUCCESS; +} + +ts_bool vertex_untaint(ts_vertex *vtx, ts_uint level){ + vtx->locked--; + if(level==0){ + return TS_SUCCESS; + } + ts_uint i; + for(i=0; i<vtx->neigh_no; i++){ + vertex_untaint(vtx->neigh[i], level-1); + } + return TS_SUCCESS; +} + +inline ts_bool vertex_tainted(ts_vertex *vtx, ts_uint level, ts_uint amount){ + if(vtx->locked>amount) return 1; + + return 0; +} -- Gitblit v1.9.3