| | |
| | | #include<stdio.h> |
| | | #include<math.h> |
| | | #include<pthread.h> |
| | | #include<unistd.h> //usleep requires it |
| | | //#include<unistd.h> //usleep requires it |
| | | //#include "io.h" |
| | | #include "general.h" |
| | | #include "timestep.h" |
| | |
| | | rnvec[0]=drand48(); |
| | | rnvec[1]=drand48(); |
| | | rnvec[2]=drand48(); |
| | | //TODO: you only need to taint (lock) vertices, that could be shared with another partition. You can leave out the rest. How can you test for that? Well, if any of vtx neighbours are in other partition, then you need to lock vertex and that neighbor. Otherwise not! |
| | | |
| | | /**** THREAD IS POTENTIALLY LOCKED ******/ |
| | | pthread_mutex_lock(data->vtx_tainting_lock); //taint if no other process is tainting or wait until you can taint |
| | | // ts_fprintf(stdout, "thID=%d:: Tainting vertex %d, level=%d. Waiting....\n",thID, i, vesicle->vlist->vtx[i]->locked); |
| | | |
| | | while(vertex_tainted(vesicle->vlist->vtx[i],1,1)){ |
| | | ts_fprintf(stdout, "thID=%d:: Vertex %d is tainted, so I cannot try vertexmove. Level=%d. BU(H)TELJ!\n neigh. vtxs: ",thID, i, vesicle->vlist->vtx[i]->locked); |
| | | ts_fprintf(stdout, "thID=%d:: Vertex %d is tainted, so I cannot try vertexmove. Amount=%d. BU(H)TELJ!\n neigh. vtxs: ",thID, i, vesicle->vlist->vtx[i]->locked); |
| | | for(j=0; j<vesicle->vlist->vtx[i]->neigh_no; j++){ |
| | | ts_fprintf(stdout, "%d ", vesicle->vlist->vtx[i]->neigh[j]->idx); |
| | | ts_fprintf(stdout, "%d(a=%d) ", vesicle->vlist->vtx[i]->neigh[j]->idx, vesicle->vlist->vtx[i]->neigh[j]->locked); |
| | | } |
| | | ts_fprintf(stdout, ".\n"); |
| | | } |
| | | |
| | | pthread_mutex_lock(data->vtx_untainting_lock); |
| | | vertex_taint(vesicle->vlist->vtx[i],2); |
| | | vertex_taint(vesicle->vlist->vtx[i],1); |
| | | pthread_mutex_unlock(data->vtx_untainting_lock); |
| | | |
| | | pthread_mutex_unlock(data->vtx_tainting_lock); |
| | |
| | | |
| | | single_verticle_timestep(vesicle,vesicle->vlist->vtx[i],rnvec); |
| | | pthread_mutex_lock(data->vtx_untainting_lock); |
| | | vertex_untaint(vesicle->vlist->vtx[i],2); |
| | | vertex_untaint(vesicle->vlist->vtx[i],1); |
| | | pthread_mutex_unlock(data->vtx_untainting_lock); |
| | | // ts_fprintf(stdout, "Vertex %d should be untainted, level=%d.\n", i, vesicle->vlist->vtx[i]->locked); |
| | | } |