Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!apple!rutgers!cbmvax!cbmehq!cbmger!kbsaar!fjrei From: fjrei@kbsaar.UUCP (Franz-Josef Reichert) Newsgroups: comp.sys.amiga.programmer Subject: Re: General questions regarding Tasks Message-ID: Date: 27 May 91 03:36:14 GMT References: <1991May24.160440.374@m.cs.uiuc.edu> Organization: Private Amiga Site Lines: 38 In article <1991May24.160440.374@m.cs.uiuc.edu> schwager@m.cs.uiuc.edu (Michael Schwager) writes: > >Hi, >I'm looking for guidelines about using tasks within C programs. C code >examples would help. I've got Aztec C 5.0d, and their little beep.c >example only goes so far. For example, I wonder: Can I call other >functions from within my task? What do I need to be careful of (besides >changing system variables)? Also, can I pass variables to a Task, like >this: > > CreateTask ("Name", 0, func3 (var0, var1, var2), BIGSTACK); No, you can't do that. But you may pass arguments on the task's stack before calling exec's AddTask(). So you can't use plain CreateTask() as given by the library. Do the following modification to drop your arguments (assuming they are ULONG's): *(--((ULONG*)newTask->tc_SPReg)) = var2; *(--((ULONG*)newTask->tc_SPReg)) = var1; *(--((ULONG*)newTask->tc_SPReg)) = var0; >I'm getting random (I think) address error Guru's when I try to get too >fancy with Tasks. Too fancy means: I want to call another function from >within it. No problem at all. Provide a synchronisation between parent and child because parent task has to wait for the child task to complete. Otherwise, it will unload the child's code and data space on parent's exit, which will probably make your program fail. Any global data must be accessed properly. Use absolute adressing or 'geta4()' on function entry. >-Mike Schwager | Machine: Amiga 500, 3 MB RAM/30 HD -- Best regards, Franz-Josef Reichert VOICE: +49 6805 7417 Kuchlingerstrasse 13 UUCP: ...uunet!cbmvax!cbmehq!cbmger!kbsaar!fjrei D-6601 Kleinblittersdorf GERMANY