Hi, Joan Lledó <joanlluisll...@gmail.com> writes:
> As I mentioned in my previous post about ioctl operations[1], LwIP > establishes a maximum limit of sockets, which is a big problem for a > system like the Hurd. Now I've finished all tasks in my initial > proposal, I thought it was a good idea to spend some time studying > this issue and trying to find a solution. > > The problem is this: in LwIP, sockets are stored in a fixed-size > array, which is the best solution for embedded systems as it is a > natural way of indexing items without need of additional variables and > allows the user to directly access any socket from its index taking > the same time. If we remove the limited amount of sockets, then we > cannot keep using an array, and another solution is required to handle > all this. > > In the LwIP translator, I've chosen to replace the array for a linked > list, and that has some implications: the need to iterate the list any > time we need to create, destroy or look for a particular socket, I would be good to avoid having socket lookup require time proportional to the number of sockets. The number of sockets may grow quite large in some applications. Instead of a linked list, how about using a dynamic array? https://en.wikipedia.org/wiki/Dynamic_array This would give you constant-time lookups, amortized constant time insertions and deletions, and better data locality and cache behavior. What do you think? Mark