I was doing some similar work last week and stumbled on the this discussion. I have been working with the Posix timers patch and was looking for a nice way to allocate ids for timers. I looked at get_pid() and also the code used for ipc/msg.c and friends. I thought I could do better so I wrote the attached routines. They are a subtle variation on the bitmap theme. I'm mixing a bitmap with a sparse array which is implemented as a radix tree. This means that the data structure grows/shrinks as needed. The interface is: id = id_new(idp, pointer); id_remove(idp, id); pointer = id_lookup(idp, id); The idp is a pointer to the structure which defines the id space. This provides, not only the bitmap allocation of the id but also, mapping the id to a pointer. In the case of pids, this would replace the hash table used by find_task_by_pid(). So far I have been playing with this code in user space. I'm including my test harness. I plan to try it with your program later today. My program was written more to test correctness, but I do collect a few numbers. Here is the output: jhouston@linux:~/id > time ./id_test my_id.count=1 new_cnt=5002501 avr_depth = 4996 id_lookup took 101 cycles id_new took 204 cycles id_remove took 148 cycles real 0m3.476s That's about 0.5us total to allocate an id, lookup a random id and remove it with a table containing 5000 ids. The times only double for 500000 ids. Jim Houston - Concurrent Computer Corporation.