Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
3 views

Assignment 1

The document outlines a lab assignment for CSE 321 Operating Systems, consisting of five tasks related to system calls and process management. Tasks include writing C programs for file handling, creating parent-child-grandchild processes, managing process IDs, sorting arrays, and checking odd/even status of numbers. The total marks for the assignment are 10, with each task contributing to the overall score.

Uploaded by

shayonto.rayhan
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Assignment 1

The document outlines a lab assignment for CSE 321 Operating Systems, consisting of five tasks related to system calls and process management. Tasks include writing C programs for file handling, creating parent-child-grandchild processes, managing process IDs, sorting arrays, and checking odd/even status of numbers. The total marks for the assignment are 10, with each task contributing to the overall score.

Uploaded by

shayonto.rayhan
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

CSE 321 Operating Systems

Lab Assignment 1
Total Marks: 10

The following questions are related to system call [5X2= 10 marks]

Task-1:

Write a c program that will open a file given from the command line argument and then it will
ask the user to input strings that will be written to that file. It will continue to ask the user to
enter a string as long as the user enters “-1”. If the given file does not exist in the directory, then
your program will automatically create the file.

Task-2:

Write a program that will create a child and another grandchild process. Every process will print
a line.

The parent process will print, “I am parent”

Child process will print, “I am child”

The grandchild process will print, “I am grandchild”

Now, write the program in such a way that the following output will be shown -

I am grandchild

I am child

I am parent
Task-3:

Consider the following code snippet in your main function -

a = fork();

b = fork();

c = fork(); ​

Now, write the full program, that will check the children’s PID and if it is odd then the process
will create another child process. Lastly, print how many processes have been created
considering the first parent process.

Task-4:

Write a program named “sort.c” where you will give some number from the command line
argument and the program will print the sorted array in descending order. Then, write another
program named “oddeven.c” which will take some numbers from the command line, then check
and print whether the numbers in the array are odd or even.

Now, you have to write a program that will create a child process and the child process will first
sort the array that you have declared in this program. And then, the parent process will print the
odd/even status for each number in the array.

oddeven
Task -5:

Write a program in c that the parent process will create one child process and 3 grandchild
processes and print their IDs

Output: 1. Parent process ID : 0


​ 2. Child process ID: ….
​ 3. Grand Child process ID: …
​ 4. Grand Child process ID: ….
5. Grand Child process ID: ….

You might also like