Making module tasks
Terje Slettebø (285) 275 posts |
Hi guys. Using GCC, I’m trying to make a Wimp task that runs as a module, so I’m using Cmunge and “module-is-runnable”. So far so good, but when I call Wimp_Initialise from main(), it crashes with a “Trap while in trap handler” error. I’ve tried changing it to a Toolbox application, instead, but when calling Toolbox_Initialise, the same thing happens. Am I missing something obvious, here, and have any of you successfully made a module task using GCC? I could of course try DDE, but I want to be able to use modern C++, so if I can’t get this to work, I think I’ll have to resort to assembly code, if even that works. Any help appreciated. Regards, Terje |
Colin Ferris (399) 1814 posts |
Is your Wimp slot being taken away? You have to ask for it to be kept. |
Terje Slettebø (285) 275 posts |
Aha, I didn’t know that. As a matter of fact, I haven’t set it up at all. Do you mean I have to call Wimp_SlotSize before calling Wimp_Initialise, to ensure I have memory for the task? I didn’t think it used that one for module tasks. |
Julie Stamp (8365) 474 posts |
You need to claim Service_Memory when it’s called with R2 = base of your module:
and in your cmhg
|
Alan Adams (2486) 1149 posts |
Is this something specific to modules written in C? My limited understanding was that running a module allocated space in RMA to load the file, and any extra memory needed had to be allocated withing the Initialisation code. Does a module also need a Wimp slot? |
Terje Slettebø (285) 275 posts |
@Julie That worked, thanks a lot! I notice it’s listed under “Application tasks” in the Task Manager, so my next question is, why is it not listed under “Module tasks”? P.S. I’m off to re-read the “Modules” chapter in the PRM. Obviously, there’s something I don’t understand. |
Julie Stamp (8365) 474 posts |
A task appears in Module Tasks when it doesn’t have an app slot. Your task does have an app slot, so it appears under Application Tasks instead. Pinboard is another example of a task that is started by entering a module as an application but appears under Application Tasks, as it uses an app slot.
No, when putting an application in a module you can choose whether or not you want to use a Wimp (app) slot.
When someone’s writing an application in C contained in a module, by default it uses memory from an app slot, rather than from the RMA (save for the little block of RMA that contains global variables accessible from any module entry point). This provides an experience for the programmer that’s closest to compiling the application as an FF8 or E1F. It’s possible to persuade C to not use an app slot for its memory, but it involves a bit of assembler, and you use lose facilities of the C run-time environment that you’d otherwise have. |
Terje Slettebø (285) 275 posts |
Thanks a lot for your comprehensive explanation, now I understand. |