How can I sync between multiple threads so that their transaction ID be unique without using mutex?

Posted by poly on Programmers See other posts from Programmers or by poly
Published on 2012-04-12T20:31:39Z Indexed on 2012/04/14 5:40 UTC
Read the original article Hit count: 165

Filed under:
|

I'm writing an application in C that requires multiple threads to request a unique transaction ID from a function as shown below;

struct list{
  int id;
  struct list *next
};

function generate_id()
{
  linked-list is built here to hold 10 millions 
}

How can I sync between two or more threads so that their transaction ID be unique among them without using mutex, is it possible?

Please share anything even if I need to change linked list to something else.

© Programmers or respective owner

Related posts about c

    Related posts about multithreading