Bob Latham <b…@sick-of-spam.invalid> wrote:
> > In my RISCOS 3 PRMs page 3-206 it says you can change the slot size > of the current slot by setting a value in register 0. > > At the bottom of that same page it also says - No tasks should set > their current slot size,: normally, a new task will call *wimpslot > which then calls Wimp_SlotSize. > > To my simple brain that is a major contradiction and I don't > understand it at all. > > Say I need to obtain some temporary extra memory for a sort buffer, > can extend the slot using this call, do the sort work and reduce the > slot size again? > > Can someone clarify for me please?
That bit was always confusing. I think what it's trying to say is don't use Wimp_SlotSize instead of *Wimpslot for setting the slot size for a new app. ie you should set it in your !Run file via *WimpSlot rather than in your !RunImage. For example in BASIC you might start with by default (for example) 640k and then try to expand via Wimp_SlotSize, but by that point the BASIC stack is set up at the 640k marker and changing Wimp_SlotSize later doesn't alter that, so you risk running out of stack and heap if you did it that way. AFAIAA it's fine to use Wimp_SlotSize to manipulate your slot at runtime as you suggest. BASIC would be unaware of any memory above END (set to your starting slot) so you would need your own allocator for memory above it. If you are just using that for a single buffer then such an allocator is trivial. Norcroft C supports chunked stacks so in theory it would be possible to add new stack frames in the expanded space above where the stack originally started from. I'm not sure if that would actually happen in practice. Likewise I'm not sure what other memory allocators would do; I believe 'flex' and maybe the SharedCLibrary are able to expand the slot according to their own requirements, but I'm a bit hazy on the details. I suspect they may be surprised if you expand the slot behind their back, but only if they tried to expand due to running out of memory. If you don't run out of heap memory, it's likely fine to extend the slot behind their back and then do your own allocations within it. Theo