Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!rutgers!cbmvax!phillip From: phillip@cbmvax.cbm.UUCP (Phillip Lindsay) Newsgroups: comp.sys.amiga Subject: Re: MANX bugs with Tasking (the fix) Message-ID: <1150@cbmvax.cbmvax.cbm.UUCP> Date: Fri, 19-Dec-86 08:14:56 EST Article-I.D.: cbmvax.1150 Posted: Fri Dec 19 08:14:56 1986 Date-Received: Sat, 20-Dec-86 02:03:08 EST References: <2226@bacall.UUCP> <865@ulowell.UUCP> <1146@cbmvax.cbmvax.cbm.UUCP> <1149@cbmvax.cbmvax.cbm.UUCP> Organization: Commodore Technology, West Chester, PA Lines: 126 > >>Has anybody gotten tasking to work with MANX? [...cut] > >>-- Marco Papa This is a problem related to the A4 register used as a base register, I believe the problem is apparent in the small-code/data models and not in large code/data models. (ie. "cc +cd foo.c" will compile using large models) In the interest of people screaming about Manx and tasks I make the following re-posting from well!crunch: (I don't think crunch and manx will mind...) AMIGA-MANX-FIX -------------- From: crunch@well.UUCP (John Draper) I got permission from Jim Goodnough from Manx to publish the following information. Manx C has some problems when spawning tasks. It appears that the A4 register is improperly set. Below is some code that you need to add to get multi-tasking to work properly. Before calling the "AddTask" function, it is necessary to call the sava4() function which is listed below. Then, in your Task, you need to call geta4(). The code below can be included in your source or be seperately compiled and linked into your program. ----------------- cut here ---------------- /*==================================================================== Get and Save A4 Regs to fix a manx bug =====================================================================*/ #asm a4sav dc.l 0 public _sava4 _sava4 lea a4sav,a0 move.l a4,(a0) rts public _geta4 _geta4 move.l a4sav,a4 rts #endasm Another problem with the Manx system is in the debug program. It is not possible to set a breakpoint in a separate task. The "db" program will only call the "guru". Manx also doesn't have a "kprintf" function, so using intermediate print statements to debug code is a royal pain. Jim cooked up a "kprintf" routine, and it's listed below. The "kprintf" function only works if you connect an external terminal to the serial port or another computer. Then all your debug diagnostic printing can take place on the external computer. I use the Macintosh as an external computer and use the ImageWriter cable connected to the serial port on the Amiga. I use MacTerminal because it has an extra large capture buffer and send all my debug messages over to the Mac screen. It works very well. I also hacked up the "avail.c" program and modified it to use "kprintf" so I can keep track of memory allocations so I can make sure I release it when done. It works very well and painlessly. My only problem seems to be that I forget to cast the sizeof's to (long)'s. Which really messes things up. The "kprintf" code is listed below. ----------------- cut here ----------------- /* * This is a debug library which interacts directly with the Serial * port. * * Functions are: * kprintf(fmt, arg1, arg2,....); * kputchar(char); * kputs(string); */ kprintf(fmt, args) char *fmt; int args; { int kputchar(); return(format(kputchar, fmt, &args)); } kputs(str) char *str; { while (*str) kputchar(*str++); kputchar('\n'); } #asm public _LVORawPutChar public _kputchar _kputchar move.l 4,a6 move.w 4(sp),d0 ;make the 'w' an 'l' if using c32.lib cmp.b #$a,d0 bne.s .1 jsr _LVORawPutChar(a6) move.l #$d,d0 .1 jmp _LVORawPutChar(a6) #endasm -------------- cut here ---------------- I hope this makes your programming effort easier. It sure has made it better for me. Regards: John Draper Programmers Network ( A programmers Guild) "The place where we all live and learn" .....ihnp4!ptsfa!well!crunch /* EOF */ -- ============================================================================== Phillip Lindsay - Commodore Business Machines - Amiga Technical Support UUCP: {ihnp4|seismo|caip}!cbmvax!phillip - Phone: (215) 431-9180 No warranty is implied or otherwise given in the form of suggestion or example. Any opinions found here are of my making. /* eof */