shared transaction ID function among multiple threads

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

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 
}

my concern is how to sync between two or more threads so that transaction id can be unique among them without using mutex, is this 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