/* * @@name: cas.2 * @@type: C * @@operation: run * @@expect: success * @@version: omp_5.1 */ #include #include #include #include #define N 10 typedef struct Node{ struct Node *next; int id; } Node; typedef struct Queue{ Node *head; Node *tail; } Queue; void enqueue( Queue *, Node * ); int main(){ Queue q; Node nodes[N]; int id_check[N]; // Initializing for(int i=0; iid]=node->id; //Store found id at position id node =node->next; }while(node->next != NULL); id_check[node->id]=node->id; //checking also the 1st node here for(int id=0; idnext = queue->tail; do{ #pragma omp atomic compare capture { result = queue->tail == node->next; if(result) { queue->tail = node; }else{ node->next = queue->tail; } } }while(!result); }