davidc%yak@gatech.edu (Dave Corbin) (11/09/87)
Okay. I'm having problems using CreateProc. I've created this small example that easily demonstrates my problem. The two files, test.c and ldr.c are both compiled and linked into their own separate runtime modules. (Using Manx 3.4a). The Problem: 'test' works just fine. When I execute 'ldr', it completes normally, but 'test' does not. If I look at the system's list of TASKs, then I find that there is a new task called TEST that is WAITING. Can anyone tell me what I am doing that is wrong? Also, what is it that a Process has that a Task doesn't that allows it to access AmigaDos. test.c: main() { Delay(100L); kprintf("Testing\n"); } ldr.c: #include <exec/types.h> main() { ULONG seg,LoadSeg(); seg = LoadSeg("test"); if (seg == 0) { printf ("Can't Load 'seg'\n"); exit(1); } if (CreateProc("TEST",0L,seg,500L) == 0) { printf ("Can't CreateProc()\n"); exit(1); } printf("done\n"); }
dillon@CORY.BERKELEY.EDU (Matt Dillon) (11/09/87)
>Can anyone tell me what I am doing that is wrong? >Also, what is it that a Process has that a Task doesn't that allows it to >access AmigaDos. Yah, this is an easy one. There are two problems. (A) no arguments are passed to test, (B) there is no CLI attached to test (look in the process structure). The result is that the startup code for TEST thinks it's being executed from the workbench, and thus Wait()'s for the workbench packet. You can get around both problems by creating a custom startup. With Aztec C, execution starts at the .begin label, so you simply write a little assembly module to overide the link library's .begin label. I believe the source to the standard Aztec C startup module is on your Aztec C master disks somewhere. It is called crt0.asm or something like that. >Can anyone tell me what I am doing that is wrong? >Also, what is it that a Process has that a Task doesn't that allows it to >access AmigaDos. Take a look at a Task structure. Now take a look at the Process structure. DOS uses most of the fields in the Process structure, but most importantly it uses the message port in the Process structure to talk to the packet oriented DOS device drivers. You don't need a CLI entry to use DOS, just a Process. test.c: main() { Delay(100L); kprintf("Testing\n"); } ldr.c: #include <exec/types.h> main() { ULONG seg,LoadSeg(); seg = LoadSeg("test"); if (seg == 0) { printf ("Can't Load 'seg'\n"); exit(1); } if (CreateProc("TEST",0L,seg,500L) == 0) { printf ("Can't CreateProc()\n"); exit(1); } printf("done\n"); }
cmcmanis%pepper@Sun.COM (Chuck McManis) (11/09/87)
In article <4407@pyr.gatech.EDU> davidc%yak@gatech.edu (Dave Corbin) writes: >Okay. I'm having problems using CreateProc. I've created this small example >that easily demonstrates my problem. The two files, test.c and ldr.c are both >compiled and linked into their own separate runtime modules. (Using Manx 3.4a). > >The Problem: 'test' works just fine. When I execute 'ldr', it completes >normally, but 'test' does not. If I look at the system's list of TASKs, >then I find that there is a new task called TEST that is WAITING. I had a similar problem with Lattice, until I figured out that the C startup code from Lattice thought I had been 'launched' from the workbench and was waiting for the Workbench startup message. A quick edit to customize the .o file fixed it. As for the difference between a Process and a Task, the Process can access dos functions whereas Tasks can't. Also their structures are different as well. Check out the appropriate include files for differences. --Chuck McManis uucp: {anywhere}!sun!cmcmanis BIX: cmcmanis ARPAnet: cmcmanis@sun.com These opinions are my own and no one elses, but you knew that didn't you.
ewhac@well.UUCP (Leo 'Bols Ewhac' Schwab) (11/10/87)
In article <8711090253.AA25686@cory.Berkeley.EDU> dillon@CORY.BERKELEY.EDU (Matt Dillon) writes: >>Can anyone tell me what I am doing that is wrong? >>Also, what is it that a Process has that a Task doesn't that allows it to >>access AmigaDos. > >With Aztec C, >execution starts at the .begin label, so you simply write a little assembly >module to overide the link library's .begin label. I believe the source to >the standard Aztec C startup module is on your Aztec C master disks somewhere. >It is called crt0.asm or something like that. > It's easier than that. Just do the following to your code: Change: >test.c: > main() > { To: >test.c: > _main() > { This trick only works with Manx. Some further comments: -------- Delay(100L); kprintf("Testing\n"); } ldr.c: #include <exec/types.h> main() { ULONG seg,LoadSeg(); seg = LoadSeg("test"); if (seg == 0) { printf ("Can't Load 'seg'\n"); exit(1); } if (CreateProc("TEST",0L,seg,500L) == 0) { printf ("Can't CreateProc()\n"); exit(1); } printf("done\n"); /* * No, you're not. You should hang around and wait for * your created process to finish executing, and then * UnloadSeg() it. Otherwise, you'll have a memory leak. */ }