
So Im at the point to implement handles to my OS to gain abstraction and security for my syscalls/apis.
I thought a long time about whats actually the best way to create handles.
The best I came up with is a map or an array list which contains the handle information like the handle type, access, refcount and the pointer to the real encapsulated data.
But how does one create handles reliable and fast ( something between O(1) and O(ln(n)) ) ?
I'd have to loop through the map/array to find free slots.
This of course can be speeded up by creating a queue which holds deleted/empty slot numbers, but thats still not perfect in my opinion.
The handle list is then saved for each process/context seperately to avoid bruteforcing the indexes.
Hope someone can enlight me how this is done on Windows or Linux.
(Wasnt sure if this is more OS theory, if this is the wrong forum please move the thread if needed)