Comment by chrisohara

Comment by chrisohara a day ago

4 replies

> Io in zig is for “things that can block execution”. Things that could semantically cause a yield of any kind. Allocation is not one of those things.

The allocator may yield to the OS when requesting or releasing memory (e.g. sbrk, mmap, munmap)?

messe a day ago

I don't find that a particularly compelling argument in this case, because so can accessing any memory address if it's not currently swapped in.

laserbeam a day ago

Yielding in this context means to a different “thread” in your context, not the OS. If you want to express “this is a point where the program can do something else” it is a yield. If you block and can’t switch to something else… it is not.

So if you’re using an API like mmap like that you should think of it as IO (I don’t think you can, but am not sure).

  • throwawaymaths a day ago

    the page allocator which is the root of many allocators calls mmap. of course the fixed buffer allocator does not.