Skip to content

All operating system tasks that help you to prepare yourself for the interviews.

Notifications You must be signed in to change notification settings

fazeelkhalid/Operating-System-real-life-problems-and-solution

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

49 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Operating-System-real-life-problems-and-solution

LAB - 1

Task1 Question 1:

See the usage of the following commands online. Also run them on the terminal.

  1. pwd
  2. ls
  3. cd
  4. cp
  5. mkdir & rmdir
  6. man
  7. sudo
  8. apt-get
  9. kill
  10. ping
  11. grep
  12. mount
  13. unmount

Task1 Question 2:

a. Create a function removeNonAlphabets(char * inputFileName, char * outputFileName) in C or C++ that is passed as parameters: an input file name and an output file name. The function then reads the input file using read system call and removes all non-alphabets. It then writes the data to output file using write system call. You will need to see open, read, write, and close system calls. https://www.geeksforgeeks.org/input-output-system-calls-c-create-open-close-read-write/
b. Place the signature of the function in a header file named util.h, and place the implementation of the function in a cpp file named util.cpp
c. Now create a main.cpp file containing the main function which calls the function created previously. (For input file, create a random text file containing alphanumeric characters)

Task2:

Write a C++ which perform following tasks.
Create a parent and child process using the fork command where the child tells if the number is odd or not and parent process will write the number on screen.




LAB - 2

Question 1:

Write a C++ which performs following tasks.
Create a parent and child process using the fork command where the child process will calculate
the first 15 numbers in Fibonacci series and parent process will write those numbers on screen

Question 2:

Create a program named stat that takes an integer array as command line argument (deliminated by some character such as $). The program then creates 3 child processes each of which does exactly one task from the following:

  1. Adds them and print the result on the screen. (Done by child 1)
  2. Shows average on the screen. (Done by child 2)
  3. Prints the maximum number on the screen. (Done by child 3)