Starting from:
$30

$24

Operating System Lab Assignment 2 Solution

Instructions:




All the assignments should be completed and uploaded by 5 pm. Marks will be deducted for the submissions made after 5 pm.



Markings will be based on the correctness and soundness of the outputs. Marks will be deducted in case of plagiarism.



Proper indentation and appropriate comments (if necessary) are mandatory.



You should zip all the required files and name the zip file as roll_no .zip ,eg.



1501cs11.zip.




There will be 3 files per question. Eg. q1.c, q1_output.txt, q1_explaination.txt.
Upload your assignment ( the zip file ) in the following link:



https://www.dropbox.com/request/EooNODXaqzUL15Il9EPg










Questions:




Write a program in C to create a child process using “ fork ” system call and display the child process id from parent process and parent process id from the child process. Explain the output.






Write a program in C to show that a function call before and after a fork makes the return value of the function different. (consider a function which will ask for an input integer n and return it’s factorial). Explain the output.
Write a program in C to show that a variable initialized globally is affected differently while changing the variable value inside the parent and child process. Explain the output.



Write a program in C which takes an argument, a number of seconds (t) from the command prompt. The program creates a child process. The child waits for t seconds and die. The parent process waits for the child process to die and then it dies. Also, display the list of processes inside both parent and child process. Explain the output.



A text file pipe1.txt consists of the following passage:



“This is an example file testing the use of peeps on the command line. peeps provide the user with a synchronized means of interprocess communication. Two kinds of peeps exist: named or unnamed.”




Use the cat command on pipe1.txt . Pipe the result to a sed command and change all instances of the word "peeps" to "pipes". Store the results in a file called pipenew.txt. Record the command that you used to do this. Save this command in a comment on the first line of your code.

More products