|
CS 322 Fall 2013
Project 1 |
Process Tree
|
/Shared/cs322/submit/proj1Include your *.c files in a directory named with your two first names and include a readme with
ecdfourq@bivector:~$ pstree -aG
init
+-NetworkManager
+-acpid -c /etc/acpi/events -s /var/run/acpid.socket
+-apache2 -k start
| +-apache2 -k start
| +-apache2 -k start
| +-apache2 -k start
| +-apache2 -k start
| +-apache2 -k start
+-atd
+-automount
| +-2*[{automount}]
+-avahi-daemon
| +-avahi-daemon
+-console-kit-dae --no-daemon
| +-63*[{console-kit-da}]
+-cron
+-cupsd -C /etc/cups/cupsd.conf
+-dbus-daemon --system --fork
+-exim4 -bd -q30m
+-getty -8 38400 tty4
+-getty -8 38400 tty5
+-getty -8 38400 tty2
+-getty -8 38400 tty3
+-getty -8 38400 tty6
+-getty -8 38400 tty1
+-modem-manager
+-mysqld
| +-13*[{mysqld}]
+-portmap
+-rpc.statd -L
+-rsyslogd -c4
| +-2*[{rsyslogd}]
+-sshd -D
| +-sshd
| | +-sshd
| | +-ksh
| +-sshd
| +-sshd
| +-ksh
| +-pstree -aG
+-udevd --daemon
| +-udevd --daemon
| +-udevd --daemon
+-upstart-udev-br --daemon
+-winbindd
| +-winbindd
+-wpa_supplicant -u -s
+-ypbind -no-dbus
| +-2*[{ypbind}]
+-zmdc.pl -wT /usr/bin/zmdc.pl startup
+-zmaudit.pl -wT /usr/bin/zmaudit.pl -c
+-zmfilter.pl -wT /usr/bin/zmfilter.pl
+-zmwatch.pl -wT /usr/bin/zmwatch.pl
In this project you will write a C program that creates a
binary tree of Unix processes and prints the binary tree as it is
created. Given a height of 3, the tree can be thought of as this binary tree, where the parent-child links are not explicitly stored by your program but are part of the Unix process hierarchy. While the graphical representation would look like this:
your program's processes should print out the information about the tree, as follows:
> ./processtree 3 [1] pid 81142, ppid 48569 [1] pid 81142 created left child with pid 81143 [1] pid 81142 created right child with pid 81144 [2] pid 81143, ppid 81142 [3] pid 81144, ppid 81142 [2] pid 81143 created left child with pid 81145 [3] pid 81144 created left child with pid 81146 [3] pid 81144 created right child with pid 81147 [4] pid 81145, ppid 81143 [2] pid 81143 created right child with pid 81148 [6] pid 81146, ppid 81144 [7] pid 81147, ppid 81144 [5] pid 81148, ppid 81143 [3] right child 81147 of 81144 exited with status 7 [3] left child 81146 of 81144 exited with status 6 [2] right child 81148 of 81143 exited with status 5 [2] left child 81145 of 81143 exited with status 4 [1] right child 81144 of 81142 exited with status 3 [1] left child 81143 of 81142 exited with status 2To obtain this result, your program's processes should produce output in the following format.
This project is graded out of 20 points.