Welcome, Guest. Please login or register.

Author Topic: passing arguments to a CreateNewProc process....etc.  (Read 4912 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline Noster

  • Sr. Member
  • ****
  • Join Date: Jan 2004
  • Posts: 375
    • Show all replies
Re: passing arguments to a CreateNewProc process....etc.
« on: August 03, 2005, 10:30:35 AM »
Hi,

1 - It is a C-style function pointer, NOT a BPTR.
2 - NO, the function prototype is: void(*)(void). But you could send a kind of startup-message to the messageport you get as result of the successfull CreateNewProc(). This message will be send to the new process's pr_MsgPort.
3 - I would program a timeout-timer and start the child process from your main program and I would create a public messageport for communication between the child process and your main program. The child would send a message to this public port when it has started successfully. Your main program has to Wait() for the signals of this public messageport and the timerequest after the child has been created. If the timerequest returns before the child has notified the success/result via the public messageport the child has failed.

Noster
DON\\\'T PANIC
    Douglas Adams - Hitch Hiker\\\'s Guide to the Galaxis
 

Offline Noster

  • Sr. Member
  • ****
  • Join Date: Jan 2004
  • Posts: 375
    • Show all replies
Re: passing arguments to a CreateNewProc process....etc.
« Reply #1 on: August 04, 2005, 10:06:07 AM »
DON\\\'T PANIC
    Douglas Adams - Hitch Hiker\\\'s Guide to the Galaxis
 

Offline Noster

  • Sr. Member
  • ****
  • Join Date: Jan 2004
  • Posts: 375
    • Show all replies
Re: passing arguments to a CreateNewProc process....etc.
« Reply #2 on: August 04, 2005, 10:21:26 AM »
Hi,

@Dietmar

> It's easier to pass AllocVec()'ed data in task->tc_UserData. NP_UserData should do the trick but I install it manually, with handshaking via signals.
> Tasks FreeVec()s the data when done with it.

This is hacking and might not work in future releases of the AmigaOS (or if you wish to release a MorphOS or AROS version of your program)..

Noster
DON\\\'T PANIC
    Douglas Adams - Hitch Hiker\\\'s Guide to the Galaxis
 

Offline Noster

  • Sr. Member
  • ****
  • Join Date: Jan 2004
  • Posts: 375
    • Show all replies
Re: passing arguments to a CreateNewProc process....etc.
« Reply #3 on: August 06, 2005, 01:15:32 PM »
Hi,

@Jose

Depending on the kind of data you want to pass you may pass them as string using NP_Arguments.
Poking tc_UserData is not much better code than using global variables in my opinion. Using messages protects from race conditions resp. you don't have to use Forbid()/Permit() (which should be avoided when ever possible).

Noster
DON\\\'T PANIC
    Douglas Adams - Hitch Hiker\\\'s Guide to the Galaxis
 

Offline Noster

  • Sr. Member
  • ****
  • Join Date: Jan 2004
  • Posts: 375
    • Show all replies
Re: passing arguments to a CreateNewProc process....etc.
« Reply #4 on: August 06, 2005, 01:21:52 PM »
Hi,

@Piru

> Anyway, the tag rules indeed. You get rid of that nasty sync/poking crap. Nice idea.

How is NP_UserData defined?

Noster
DON\\\'T PANIC
    Douglas Adams - Hitch Hiker\\\'s Guide to the Galaxis