mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-06 03:08:31 +00:00
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:
parent
98e684622b
commit
1bf2d8e308
8 changed files with 84 additions and 101 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue