Create New Process taglist
  • Priest of the Order of the Butterfly
    Priest of the Order of the Butterfly
    ausPPC
    Posts: 543 from 2007/8/6
    From: Pending...
    I'm starting to regret giving away my RKMs... Can anyone recommend a good discussion or primer on process initialisation as it applies to MorphOS? My goal is to create a new process that doesn't have to initialise itself any differently to a 'normal', user-started process.

    I'm particularly interested to know how to initialise the following tags marked with a '*'. Is it acceptable for the parent process to simply copy certain fields from its own process structure to pair with these tags?

    Code:
    NP_Seglist
    NP_FreeSeglist
    NP_Entry
    NP_Input *
    NP_Output *
    NP_CloseInput *
    NP_CloseOutput *
    NP_Error *
    NP_CloseError *
    NP_CurrentDir *
    NP_StackSize
    NP_Name
    NP_Priority
    NP_ConsoleTask * (How is this different to NP_Cli ?)
    NP_WindowPtr * (Just out of curiousity, can a parent and child process draw to the same window?)
    NP_HomeDir *
    NP_CopyVars * (How is this used?)
    NP_Cli *
    NP_Path *
    NP_CommandName
    NP_Arguments * (Is this just a string pointer?)

    NP_NotifyOnDeath
    NP_Synchronous
    NP_ExitCode
    NP_ExitData

    NP_SeglistArray
    NP_UserData
    NP_StartupMsg
    NP_TaskMsgPort * (Does the parent create this or is it handled by process creation?)
    NP_TaskFlags

    NP_CodeType
    NP_PPC_Arg1
    NP_PPC_Arg2
    NP_PPC_Arg3
    NP_PPC_Arg4
    NP_PPC_Arg5
    NP_PPC_Arg6
    NP_PPC_Arg7
    NP_PPC_Arg8
    NP_PPCStackSize
    PPC assembly ain't so bad... ;)
  • »07.03.16 - 23:00
    Profile Visit Website
  • MorphOS Developer
    itix
    Posts: 1520 from 2003/2/24
    From: Finland
    Quote:

    ausPPC wrote:
    I'm starting to regret giving away my RKMs... Can anyone recommend a good discussion or primer on process initialisation as it applies to MorphOS? My goal is to create a new process that doesn't have to initialise itself any differently to a 'normal', user-started process.



    RKRMs never covered any dos.library calls... I dont know why, I always found it weird.

    To create new process just call:

    struct Process *proc = CreateNewProcTags(NP_Entry, MyProcessFunc, NP_Name, "My Child Process", NP_CodeType, CODETYPE_PPC, TAG_DONE);

    You may want to pass additional parameters to your entry. Lets say your process call is like this:

    void MyProcessFunc(struct Data *data, CONST_STRPTR path) { /.../ }

    You just add NP_PPC_Arg1, data, NP_PPC_Arg2, "RAM:MyPath" to tag list.

    Quote:


    I'm particularly interested to know how to initialise the following tags marked with a '*'. Is it acceptable for the parent process to simply copy certain fields from its own process structure to pair with these tags?


    Just let the OS copy those fields for you.

    Quote:


    NP_Input *
    NP_Output *
    NP_CloseInput *
    NP_CloseOutput *
    NP_Error *
    NP_CloseError *



    If you want to pass your own filehandles for input, output and error you can Open() one yourself. CloseInput/Output/Error is just a boolean flag to indicate if the launched process should close those handles automatically when the launched process ends.

    Quote:


    NP_CurrentDir *



    You can pass your own lock here... but it is not necessary.

    Quote:


    NP_ConsoleTask * (How is this different to NP_Cli ?)



    Dont worry about this one...

    Quote:


    NP_WindowPtr * (Just out of curiousity, can a parent and child process draw to the same window?)



    This is used as a reference pointer for DOS requesters. You dont have to worry about this either...

    Quote:


    NP_HomeDir *



    You can set homedir here but it is not necessary.

    Quote:


    NP_CopyVars * (How is this used?)



    This mean local environment variables.

    Quote:


    NP_Cli *
    NP_Path *



    Too low level to me. I have never used, never needed, never had to understand.

    Quote:


    NP_Arguments * (Is this just a string pointer?)



    Yes it is, however, I prefer using NP_PPC_Arg tags.

    Quote:


    NP_TaskMsgPort * (Does the parent create this or is it handled by process creation?)



    This is handled by process creation. You can use this tag to get TaskMsgPort of newly created process:

    struct MsgPort *port;

    NP_TaskMsgPort, &port

    This can be used for interprocess communication and its advantage is that you can avoid usual handshaking mechanism with parent and child process.

    [ Edited by itix 08.03.2016 - 11:56 ]
    1 + 1 = 3 with very large values of 1
  • »08.03.16 - 09:55
    Profile
  • Paladin of the Pegasos
    Paladin of the Pegasos
    Intuition
    Posts: 1110 from 2013/5/24
    From: Nederland
    This is probably the best book for dos.library info.

    http://www.bombjack.org/commodore/amiga/books/pdf/The_AmigaDOS_Manual_Third_Edition.zip
    1.67GHz 15" PowerBook G4, 1GB RAM, 128MB Radeon 9700M Pro, 64GB SSD, MorphOS 3.15

    2.7GHz DP G5, 4GB RAM, 512MB Radeon X1950 Pro, 500GB SSHD, MorphOS 3.9
  • »08.03.16 - 10:34
    Profile
  • Priest of the Order of the Butterfly
    Priest of the Order of the Butterfly
    ausPPC
    Posts: 543 from 2007/8/6
    From: Pending...
    Thank you both for your helpful replies.

    Child processes seem to have a zeroed pr_CLI and, from what I've observed, that typically results in the assumption that the program must then have been started from Ambient - after which WaitPort() and GetMsg() are typically called by the program on its own pr_MsgPort in anticipation of an initialisation message.

    If a parent process creates such a child process, do I assume that the parent has to send this initialisation message to the child?
    PPC assembly ain't so bad... ;)
  • »09.03.16 - 04:12
    Profile Visit Website
  • Priest of the Order of the Butterfly
    Priest of the Order of the Butterfly
    BSzili
    Posts: 559 from 2012/6/8
    From: Hungary
    pr_Cli points to a struct CommandLineInterface, while pr_ConsoleTask is the message port of the console handler. If you want to check where your program was started from, you should do it from the main task, and pass the info to the sub-tasks.
    From the top of my head HomeDir is PROGDIR:, while CurrentDir is the current working directory.
    This is just like television, only you can see much further.
  • »09.03.16 - 07:07
    Profile Visit Website
  • MorphOS Developer
    itix
    Posts: 1520 from 2003/2/24
    From: Finland
    Quote:


    If a parent process creates such a child process, do I assume that the parent has to send this initialisation message to the child?



    Nope. Only if you are trying to emulate Ambient launch but for this purpose you can use wbstart.library.

    If the subprocess is your own it is up to you... you can use WaitPort()/GetMsg() mechanism to send a message to your subprocess if deemed useful.
    1 + 1 = 3 with very large values of 1
  • »09.03.16 - 08:58
    Profile