Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2003
    Posts
    3

    Unanswered: Program to implement binary teree of processes

    hi,
    Write a program which takes a single integer argument n from the command line and creates a binary tree of processes, of depth n. When the tree is created , each process should display the phrase "I am process x" and then terminate. The nodes of the tree should be numbered in the breadth-first traversal order. Make sure that that the original parent process does not terminate until all of its children have terminated. This is so that you can terminate the parent and all of the children from the terminal with a Control-C.

    thanks

  2. #2
    Join Date
    Aug 2003
    Location
    Argentina
    Posts
    780

    Re: Program to implement binary teree of processes

    Originally posted by supong
    hi,
    Write a program which takes a single integer argument n from the command line and creates a binary tree of processes, of depth n. When the tree is created , each process should display the phrase "I am process x" and then terminate. The nodes of the tree should be numbered in the breadth-first traversal order. Make sure that that the original parent process does not terminate until all of its children have terminated. This is so that you can terminate the parent and all of the children from the terminal with a Control-C.

    thanks
    Hi,
    Use the command 'trap'


    Gustavo.

  3. #3
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    12
    2 methods :-

    1. Use the /usr/proc/bin/ptree command in solaris

    2. Get a list of the following type
    ps -ef | awk '{print $2 " " $3"}'
    This gives you the PID and PPID list of all the processes. Create a binary tree from this using one of the binary tree algorithms.
    Thanks and Regards
    Karthik R

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •