Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!husc6!rutgers!cbmvax!carolyn From: carolyn@cbmvax.cbm.UUCP (Carolyn Scheppner CATS) Newsgroups: comp.sys.amiga Subject: Re: Posting of CSNEWS 'AMIGA' discussion, entry #193. Message-ID: <1875@cbmvax.cbmvax.cbm.UUCP> Date: Thu, 14-May-87 18:59:14 EDT Article-I.D.: cbmvax.1875 Posted: Thu May 14 18:59:14 1987 Date-Received: Sat, 16-May-87 12:52:32 EDT References: <48CSNEWS@MAINE> Reply-To: carolyn@cbmvax.UUCP (Carolyn Scheppner CATS) Organization: Commodore Technology, West Chester, PA Lines: 178 In article <48CSNEWS@MAINE> CSNEWS@MAINE.BITNET (CSNEWS CSBB Processor) writes: >[] >The documented call AddTask() in the RKM v.1 does not work properly >on my machine. AddTask() requires a bit of setup. I suggest using CreateTask() or at least looking at the CreateTask() source in the RKM (appendix D in A-W Exec manual or appendix after .i's in our 1.1 RKM Vol. II). In addition, if you are using Manx, you are going to need some inline assembler to fix the registers. > As a matter of fact, CreateProc() doesn't work either. >In the case of the AddTask() call, I get a Guru alert. In >the case of the CreateProc() call, aboslutely nothing happens. CreateProc() requires even more setup. For instance, if you are CreateProc'ing inline code rather than LoadSeg'd code, you must provide a dummy seglist. If you have LoadSeg'd a standalone program with normal startup code, you must create a port, build a WBenchMsg, and send it to the new process whose startup code is Wait'ing for that message. > After the CreateProc() goes to completion with a non-zero >return, the associated task state is 8, not defined in the RKM. >Anybody know what state this is? Got me. I could look at the source, but I don't have time. > Is or has anybody had any luck using either of these two >functions? Does anyone know for a fact that the RKM is in >error? (I got my set of manuals way back when Commodore first >released them, not the later Addison-Wesley publications) I've used CreateTask(). I've seen CreateProc() used. Again, see the Appendix. And the example at the end of this message. > Also, does LoadSeg return the address of the first instruction >of the loaded program, or does it return something else? If it >returns something else, how do you get the first instruction from >that. No. LoadSeg returns a BPTR to the initial Segment (a longword Bpointing to the next segment). Multiply the BPTE by 4 (or shift left twice) then add 4. Now it is a C pointer to the first instruction. > Lastly, an observation -- the call FindTask() returns a pointer >to a struct Process. The first element of a Process is a struct >Task, but the Process information is all there for you to look at. This is only true for Processes. If what you find is just a Task then the additional Process info is not there. ---------------------------------------------------------------------- Here's an example using CreateTask. Phil Lindsay helped me straighten out the conditional inline assembler code that I added for Manx users. It has been tested with Lattice and Manx. ---------------------------------------------------------------------- /* * Task.c - a cheap sub-task example by cs * Cheap = shared data for communication rather than MsgPorts * If using Aztec, #define AZTEC_C */ #include #include extern VOID subTaskRtn(); struct Task *CreateTask(), *subTaskPtr = 0L; char *subTaskName = "SubTask"; /* Data shared by main and subTaskRtn */ ULONG GfxBase = 0L; ULONG Counter = 0L; LONG PrepareToDie; /* If using Aztec, #define AZTEC_C * * Note: Aztec C v3.4a has built in functions that do the following * for you: geta4() and sava4(). */ #ifdef AZTEC_C #asm cseg public _a4sav _a4sav lea.l _a4tmp,a0 move.l a4,(a0) rts public _a4get _a4get lea.l _a4tmp,a0 move.l (a0),a4 rts public _a4tmp _a4tmp dc.l 0 #endasm #endif main() { int k; ULONG ct; if(!(GfxBase=OpenLibrary("graphics.library",0))) cleanexit("Can't open graphics.library"); PrepareToDie = FALSE; #ifdef AZTEC_C a4sav(); #endif subTaskPtr = CreateTask(subTaskName,0,subTaskRtn,2000); if (!subTaskPtr) cleanexit("Can't create subTask"); for (k=0; k<10; k++) { Delay(50); /* main is a process and can call Delay() */ ct = Counter; printf("Counter = %ld\n",ct); } cleanup(); } cleanexit(s) char *s; { if(*s) printf("%s\n",s); cleanup(); exit(0); } cleanup() { if(subTaskPtr) { PrepareToDie = TRUE; while(PrepareToDie); DeleteTask(subTaskPtr); } if(GfxBase) CloseLibrary(GfxBase); } /* subTaskRtn increments Counter every 1/60 second */ VOID subTaskRtn() { #ifdef AZTEC_C a4get(); #endif while(!PrepareToDie) { WaitTOF(); Counter++; } PrepareToDie = FALSE; /* Signal ready to die */ Wait(0L); /* Wait while ax falls */ } -- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Carolyn Scheppner -- CBM >>Amiga Technical Support<< UUCP ...{allegra,caip,ihnp4,seismo}!cbmvax!carolyn PHONE 215-431-9180 =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=