On 08/01/2012 07:55 PM, Jiří Zárevúcky wrote: > We could implement some kind of reservation system. > That is, application would call something like as_area_reserve() to > reserve just a piece of virtual address space, not physical memory. > Then there would be another call distinct from as_area_create() that > would map pages in a previously reserved region. Is there a way to > handle access to unmapped pages from userspace?
Well, it already works like that. When you create a, say anonymous, address space area, only virtual address space is allocated. Physical memory is allocated only when the corresponding virtual page is first referenced. So in fact, what you can do right now is give each fibril an anonymous area of some size (which would, until it is possible to grow an area downwards, determine the maximum stack size) and place its stack at its end. As the fibril consumes its stack space, the stack will automatically grow as needed (no kernel change necessary!) down to the base address of the area. The fibril will consume only as much physical stack memory as actually needed. Of course, you will need to decide on how much virtual memory to reserve for each fibril. Actually, I don't understand why nobody came with this simple and brilliant idea before :-) The only problem is that, as of now, you don't have a way to create a permanent gap in the address space which you could create at both ends of the anonymous area used for the stack. Perhaps a dedicated as area type could help here (backend_gap?). So to sum it up, there is actually a way for the uspace to have a growing stack up to some fixed limit, but there is no way to effectively protect that stack with guard pages or grow the stack beyond the limit. Obviously, both limitations can be addressed. Jakub _______________________________________________ HelenOS-devel mailing list [email protected] http://lists.modry.cz/cgi-bin/listinfo/helenos-devel
