d89-rbn@sm.luth.se (Robert Buren) (03/18/91)
I'm learning how to use multitasking in my programs, but I seem to have run into a problem here. I made a very simple program that opens up a window and attaches some menus to it, and everything worked just fine. The next step was to make an About routine that just opens up another window and writes my name in it.. Still no problems. But(!) then I wanted the Aboutroutine to run as a childtask. Hello Guru. The program works just fine up to this line: AboutTask = CreateTask("About",0,AboutCode,5000); where AboutCode was declared earlier as extern VOID AboutCode(); It works just fine if I replace the CreateTask line with just AboutCode(); , but no multitasking, of course. I've been following the multitasking example code in "The Kickstart guide to the Amiga", but I cannot find anything pointing me to the bug. HELP -- Robert Buren d89-rbn@sm.luth.se
d88ricwe@odalix.ida.liu.se (Rickard Westman) (03/18/91)
d89-rbn@sm.luth.se (Robert Buren) writes: >I'm learning how to use multitasking in my programs, but I seem to have >run into a problem here. I made a very simple program that opens up a >window and attaches some menus to it, and everything worked just fine. >The next step was to make an About routine that just opens up another >window and writes my name in it.. Still no problems. But(!) then I wanted >the Aboutroutine to run as a childtask. Hello Guru. > The program works just fine up to this line: >AboutTask = CreateTask("About",0,AboutCode,5000); Could it be that you're using the small code/data model with your compiler? In that case, most references to global data are made through a base register (usually a4). This will not be correctly initialized if one of your functions get called from an interrupt routine or from the scheduler. If you are using Manx, the single line geta4(); added at the very start of your AboutCode() could solve your problem. Lattice/SAS use something similar, I think. Check it with the manual. -- Rickard Westman, University of Linkoping, Sweden
barnettj@pookie.crd.ge.com (Janet A Barnett) (03/27/91)
In article <1511@tau.sm.luth.se> d89-rbn@sm.luth.se (Robert Buren) writes: > >I'm learning how to use multitasking in my programs, but I seem to have >run into a problem here. The method of spinning off a task from a loaded program depends heavily on the compiler you are using. If you have a late model SAS/C compiler, be sure to use the -y option so that the Global data pointer is reloaded into register a4 when your "subroutine" is invoked. (Since the spawned task executes in a different context from the parent task, there is no guarentee that this register is still pointing to the global data area.) Oh, you can also declare your routine as: void __saveds routinename(); (or possibly __saveds void routinename()) then you don't have to have every routine do the a4 reload. I do not know what facilities other C compilers may provide for this kind of thing. AB