Shared memory multiprocesses

Posted by poly on Programmers See other posts from Programmers or by poly
Published on 2012-04-02T22:04:01Z Indexed on 2012/04/02 23:41 UTC
Read the original article Hit count: 170

Filed under:

I'm building an multi processes application and I need to save session ID, the sessions ID is 32 bit, and of course it can't be used twice in its lifetime, I'm currently using DB that saves all the ID in a table, and I do the following,

ID table is (int key, char used(1)) //1 is used, 0 is not 1. lock table 2. get one key for one sessions 3. update used field in it to used 4. unlock

After the session is finished the process use below to free key, 1. lock table 2. update used field in it to not used 4. unlock

I'm really wondering whether this is a good/fast implementation. and please note it's multi processes application.

© Programmers or respective owner

Related posts about multithreading