0% found this document useful (0 votes)
10 views2 pages

Process Managment

This document provides instructions for 13 programming exercises involving process management in Linux: 1. Write programs to sequentially execute the ls, pwd, and cal commands using either system() or exec() with fork(). 2. Write a program to execute commands and arguments passed via the command line. 3. Write an observation program to print process IDs before and after fork() calls to demonstrate process generation. 4. Write a program to pass and execute multiple commands separated by a delimiter via the command line. 5. Write a program to execute multiple commands from the command line using either system() or exec() to match the number of processes to commands. 6. Write a program to create 3

Uploaded by

Mayu kale
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views2 pages

Process Managment

This document provides instructions for 13 programming exercises involving process management in Linux: 1. Write programs to sequentially execute the ls, pwd, and cal commands using either system() or exec() with fork(). 2. Write a program to execute commands and arguments passed via the command line. 3. Write an observation program to print process IDs before and after fork() calls to demonstrate process generation. 4. Write a program to pass and execute multiple commands separated by a delimiter via the command line. 5. Write a program to execute multiple commands from the command line using either system() or exec() to match the number of processes to commands. 6. Write a program to create 3

Uploaded by

Mayu kale
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Process Management

------------------------------------------------------------------------------------------------------------------------

1. Write a program to execute ls , pwd & cal sequentially


a) Using system( )
b) Using exec( )
Hint : use fork().

2. Write a program to execute a command with its arguments given at command line.
i/p : ./a.out ls –l
./a.out cal 2011.

3. Observation program :
main()
{
printf(“before %d and %d\n”,getpid(),getppid());
fork();
printf(“1: %d and %d\n”,getpid(),getppid());
fork();
printf(“2: %d and %d\n”,getpid(),getppid());
fork();
printf(“3: %d and %d\n”,getpid(),getppid());
}
Observe the o/p of this above programme and draw its process generation diagram with
its instruction ,processed, parent process id of the new process which is generated and
compare with output.

4. Write a program to pass num of commands each seperated by delimiter(,) through command
line.
I/p : ./a.out ls,pwd,cal,date

5. Write a program to execute the no of commands from command line


a) using system( )
b) using exec()
Note : no of new process create must be euql to no of cmd given at command line)

6. Write a program to creat 3 new jobs , in such a manner that all the 3 new jobs should have
common parent.
x------bash
x+1 --- x
x+2----x
x+3---x

7. Modify the above program .So that no two jobs have the common parent.
{each job have different parent).
x------bash
x+1 --- x
x+2----x+1
x+3---x+2
8. In the above given prog execute ls, pwd ,cal ,date command by x,x+1,x+2,x+3 respectively.
9. In the above program the o/p sequence must be date->pwd->cal->ls

10. In the above program do not use sleep but o/p sequence must be child first & then parent.

11. Write a program to create a three child process from the common parent use random delay
between 1to 10 sec in each child. Use the exit value in such a manner so that parent should
know the sequence of the child exits.
Hint : while(wait(&status)!=-1)
{
;
}
12. Modify the above program so that parent will wait uptp child -2 exit.sp after child-2 parent
will laso exit and another child become may be in Zombie or Orphan.

13. Write a program to i/p 2 small(1 to 50) integers from command line and add two interger in
child process and print the sum in parent process.

--------------------------------------------------------END----------------------------------------------------------

Dear students, If any mistakes found, kindly inform to me.

Siddiq Shaik
Email: [email protected]

You might also like