Lab Assignment_02
Lab Assignment_02
Lab Assignment # 02
Department of Computer Science
Part I [CLO-05]
1. save cpp file in a folder (e.g. myFirstProg.cpp)
2. run following command to create compile your program
a. g++ -Wall -o progExeFile myFirstProg.cpp
Note: install g++ and gcc using Ubuntu Software Center if it is missing
3. run executable
b. ./progExeFile
4. Take Screenshot of above program and paste it in a word file
5. Make following changes in a “myFirstProgram.cpp”
a. Print your name in a new line
b. Print your complete Registration Number (e.g. CIIT/FA19-BSE-047/WAH) in a new line
c. Compile and run this program with new name
d. Take Screenshot of above program and past it in a word file
Part II [CLO-07]
1. Read following and understand, process creation in linux and fork() system call.
a. http://www.yolinux.com/TUTORIALS/ForkExecProcesses.html
2. Compile and run following program
a. process_creation.cpp
3. Take Screenshot of above program and past it in a word file
4. Explain, how it works?
5. Make following modifications in process_creation.cpp
a. Display process id and parents process id using following system calls in parent
process and child process
i. getpid()
ii. getppid()
b. Take Screenshot of above program and past it in a word file
6. Make following modifications in process_creation.cpp
a. Display your name in a parent process, and mention that currently parent
process is running
b. Display your Complete Registration Number(e.g. CIIT/FA19-BSE-047/WAH ) in a
parent process, and mention that currently parent process is running
c. Run following shell command in terminal to show “Base Board Information” in a
terminal
i. sudo dmidecode | grep -A4 '^Base Board Information'
ii. you will get serial number and other information about your computer
iii. Display serial number and other information of your computer in a child
process.
d. Take Screenshot of above program and past it in a word file
Part IV [CLO-06]
Hint: Write a code for parent process in such a manner that after creating child the parent
terminates first.
******************End******************