CSCI 620 process management Project
{`New york Institute of technology School of Engineering and Technology Department of Computer Science CSCI-620 Process Management `}
Project 1
Tasks
In a new Linux virtual machine within VMPlayer:
- To obtain process information for the UNIX or Linux system, use the command ps -ael. Use the command man ps to get more information about the ps command. Describe what this command does.
- Construct a process tree similar to Figure 1. Look up the Linux command pstree –p and describe what it does. Then type in the command the capture the output.
Figure 1
- Create a process in the background ( such as (date;sleep 10; date) >date.out & ), and run ps –ael and identify the added processes running now.
- Verify the job is running by typing the command jobs. Describe what this command does.
- Type the following program in a textfile called three_forks.c. Compile it using gcc and then run it in the background.
- Describe what the fork() call does.
- Including the initial parent process, how many processes are created by the program shown? Verify your answer by running ps –ael.
- Kill the processes created in this part one by one and terminate them by the kill command. Show each is killed by running ps –ael.
{` #include#include // Note that fork() returns a pid - it returns a 0 to the child process... int main() { pid_t mypid, pid; printf("Start: pid = %d\n", getpid()); /* fork a child process */ pid = fork(); if (pid == 0) printf("Child - "); else printf("Parent - "); printf("After 1st fork: pid = %d\n", getpid()); /* fork another child process */ pid = fork(); if (pid == 0) printf("Child - "); else printf("Parent - "); printf("After 2nd fork: pid = %d\n", getpid()); /* and fork another */ pid = fork(); if (pid == 0) printf("Child - "); else printf("Parent - "); printf("After 3rd fork: pid = %d\n", getpid()); while (1); return; } `}