If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > Program to implement binary teree of processes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-07-03, 22:50
supong supong is offline
Registered User
 
Join Date: Oct 2003
Posts: 3
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
Reply With Quote
  #2 (permalink)  
Old 10-16-03, 08:01
gurey gurey is offline
Registered User
 
Join Date: Aug 2003
Location: Argentina
Posts: 780
Re: Program to implement binary teree of processes

Quote:
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.
Reply With Quote
  #3 (permalink)  
Old 10-17-03, 05:03
karthi_tvr karthi_tvr is offline
Registered User
 
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
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On