Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!rutgers!mit-eddie!uw-beaver!tektronix!tekig!tekig4!brianr From: brianr@tekig4.TEK.COM (Brian Rhodefer) Newsgroups: comp.sys.amiga Subject: Task Spawning Difficulties Message-ID: <1592@tekig4.TEK.COM> Date: Thu, 18-Jun-87 21:29:56 EDT Article-I.D.: tekig4.1592 Posted: Thu Jun 18 21:29:56 1987 Date-Received: Mon, 22-Jun-87 01:10:41 EDT Organization: Tektronix Inc., Beaverton, Or. Lines: 69 Keywords: task spawn crash guru debug manx A few days ago, I posted a plea for help with the problem I had trying to spawn a new task from a Manx Aztec C program (compiled with ver 3.40a) on the Amiga: the Amiga would crash during the AddTask library function call. Although Ali Ozer (sp?) very kindly sent me a working example of task spawning, no one suggested what my difficulty was. Is it possible then, that the solution merits posting? With apologies to millions of detective story fans: "DeBUGGER DID IT!" Since I had never created a new task before, I ran my program under the Manx debugger, "db", so I could watch what went on very closely. I followed my program's execution to a point just prior to its call on "CreateTask" (A Manx c.lib routine). I then set a breakpoint on the instruction following the call, and another breakpoint on the first instruction of the task I was adding. (It was merely a subroutine in the code already loaded, so it was already resident). The new task was being "Create"d at priority 22, higher than anything else in the system, because I wanted to ensure that it started immediately. I expected, when I told the debugger to "go", that the breakpoint at the beginning of the new task would be hit; instead, the Amiga crashed (Gurued). Repeating the proceedure, but single-stepping through "CreateTask" disclosed that the crash came somewhere in the middle of "CreateTask"s call on "AddTask". Was something wrong in the Task structure that "CreateTask" sets up? I re-ran the program, stopping short of "AddTask", and dumped out the contents of the structure to a log file. Since Ali's program ran OK, I ran the debugger on IT, so I could dump ITS Task structure for comparison. It was virtually identical to mine. Puzzled, I hit "go", AND THE AMIGA CRASHED AGAIN! I ran my test program by itself, (without the debugger) and it worked fine. Further experimentation suggested that the crash occurred BECAUSE I SET A BREAKPOINT IN A DIFFERENT TASK THAN THE ONE THE DEBUGGER HAD STARTED UP ON. Right about then, I figured that a thorough reading of the debugger manual was in order. While I could find no explicit caution against the perils of setting breakpoints in other tasks, I DID find commands described for opening new debugger windows, "..to allow debugging of multiple tasks..". Using these hitherto ignored commands ("an" and "as"), I was able to debug my newly created task without crashing. I don't know how Manx' debugger works, but It BEHAVES like the in-circuit emulators I'm familiar with. To an in-circuit emulator, a breakpoint is a breakpoint, in fine egalitarian fashion. In "db", though, breakpoints and tasks are interrelated somehow. I don't mind having to use multiple windows, even if I don't understand why it's necessary, except that it seems like the code between the start of a new task and the first time it does a Wait is irrevocably inaccessible to the debugger. Summarizing (with an apology for longwindedness): *** ONLY DEBUG ONE TASK PER DEBUG WINDOW! *** Brian Rhodefer ....tektronix!tekig4!brianr