Further improve mmap() locking story

The way to use double linked lists, is to remove all the things you want
to work on, insert them into a new list on the stack. Then once you have
all the work items, you release the lock, do your work, and then lock it
again, to add the shelled out items back to a global freelist.
This commit is contained in:
Justine Tunney 2024-06-29 17:12:25 -07:00
parent 98e684622b
commit 1bf2d8e308
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
8 changed files with 84 additions and 101 deletions

View file

@ -58,7 +58,7 @@ static struct ZiposHandle *__zipos_alloc(struct Zipos *zipos, size_t size) {
granularity = __granularity();
mapsize = sizeof(struct ZiposHandle) + size;
mapsize = (mapsize + granularity - 1) & -granularity;
if ((h = __mmap(randaddr(), mapsize, PROT_READ | PROT_WRITE,
if ((h = __mmap(0, mapsize, PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0)) != MAP_FAILED) {
h->size = size;
h->zipos = zipos;