How to execute a child process in dos, without closing the parent.

This is a discussion on How to execute a child process in dos, without closing the parent. within the A Brief History of Cprogramming.com forums, part of the Community Boards category; Is it possible to access functions created in a parent process, from a child process in dos. Example, I have ...

  1. #1
    Unregistered
    Guest

    How to execute a child process in dos, without closing the parent.

    Is it possible to access functions created in a parent process, from a child process in dos.

    Example, I have a gui that I have written, and the only way, so far, for me to run a program within it, is to hard code it. I would like to beable to make programs that will run simultaeously with it
    and likewise access the functions and variables within the parent process. I have tried exec.. and spawn... maybe I am using them incorrectly.

    If this has anything to do with it, I am currently using Borland C++ 4.52 to create my dos program.

    Also I am using the graphics library SVGACC.LIB from zephyr
    software.

    Any help is greatly apprecitated.

  2. #2
    Disagreeably Disagreeable
    Join Date
    Aug 2001
    Posts
    711
    If you want to run other DOS programs within your GUI like Windows can, then you'll have no choice but to hardcode this functionality.

    If you will be using DOS programs, then you might want to look up FreeDOS because you will need to use emulation.

    If you will be using your own type of program, then there are a few libraries out there for implementing multitasking in DOS.

  3. #3
    Unregistered
    Guest

    I GOT IT!!

    Thank you very much,

    QUOTE:

    If you will be using your own type of program, then there are a few libraries out there for implementing multitasking in DOS.


    my own type of program, that gave me the idea to create a main
    program that runs ALL of the gui functions and to run scripts.

    much like a Web Browser parsing html tags, I will write my main
    program to parse text files for the appropriate functions and then
    implement them inside the main program.

    I appreciate your help very much.

  4. #4
    Unregistered
    Guest

    This is gonna suck!

    I am now learning that parsing commands in a text file is more difficult than I thought it was going to be, but when I get it working

    I think it will be worth it.

  5. #5
    Disagreeably Disagreeable
    Join Date
    Aug 2001
    Posts
    711
    Yeah, parsing commands takes some thinking. Don't worry though; it's possible!

  6. #6
    Registered User Unimatrix139's Avatar
    Join Date
    Jun 2002
    Posts
    55

    parsing....

    Ugh, I hate parsing....
    Kree'ta Tau'ri! Chaapa'ai!

  7. #7
    Unregistered
    Guest
    You don't need to multitask.!!!

    There's another way to do this...TSR programming(just like a dos driver think of the mouse driver)

    Let your child program generate an interrupt and exit the program with the keep() function, if you do this you program remains resident..

    Now, if you call the interrupt within the parent program you can call the interrupt generated by the child program.

    Good luck with it, because it wil be hard to learn but if it works it works allmost like multitsking!

    GrtZ

  8. #8
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,586
    I would not recommend using the keep() function to program TSRs. Rather I would use pure assembly code and call DOS to terminate and stay resident. You must make sure your code is extremely small and only make what is necessary be resident - the rest should be transient code.

    But there is no need for this. There is a DOS function that will allow you to load and run a child process. When the child process terminates, control is passed back to the parent. However you cannot have two processes running at the same time with this function. In order to do that you will have to setup some type of co-call system. There is way to implement co-calls in C using setjmp and some other functions that I can't recall at this time. Sorry but my references are all packed away right now.

    I would not recommend coding TSRs as they introduce a lot of new and not so easy to solve problems - chiefly re-entrancy.

    A simple way to implement lightweight multi-tasking is to hook the clock tick interrupt. Find out how many processes are asking for processor time, prioritize them with some type of system, and then give each process on the queue a slice of time. Upon the clock tick interrupt, check the ticks against the number of time slices allotted to the current task - if it is time to switch tasks you must save the current state of the CPU and also determine if it is safe to switch tasks. For instance if process A is inside of an interrupt or disk access you would not want to switch to process B - doing so would mean disaster in the first situation and corrupted data in the second. You can place locks on resources called semaphores to test whether or not a resource is in use by a certain process or not. You can also lock resources or even use a system by which the program asks the processes if they can be switched or not. It is totally up to you but it is not easy and it can introduce a lot of headaches. Simple principle, not so simple application.

    Also if you wish to call a function in a parent from a child you will have to develop your own kind of DLL. You can load the DLL in memory quickly in asm and then keep track of the offsets of each of the functions in it in a header. Simply look up the function that is being called and jump to the correct offset in memory to execute the function. There is much more to this but that is the general idea.

    Most of this is very advanced code and assumes that you have a fair knowledge of the OS, assembly, and C. If its too advanced try to solve your problem some other way.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. create a child process that creates a child process
    By cus in forum Linux Programming
    Replies: 9
    Last Post: 01-13-2009, 01:14 PM
  2. Child process status
    By paraglidersd in forum C Programming
    Replies: 8
    Last Post: 07-24-2008, 10:51 AM
  3. Problem with forking a process
    By Unitedroad in forum C Programming
    Replies: 10
    Last Post: 10-04-2007, 01:43 AM
  4. Creating Child with parent of Child
    By SilkySmooth in forum Windows Programming
    Replies: 3
    Last Post: 06-28-2003, 12:15 PM
  5. shared int between parent and child
    By rotis23 in forum C Programming
    Replies: 1
    Last Post: 02-07-2003, 07:54 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21