Starting from:

$30

Operating Systems Assignment 1 Solved

1 Process creation and termination system calls

The first exercise deals using process creation system call, fork(). You need to write a program that spawns a child process, using the fork() system call. The child process reads a CSV file, presented with the assignment, that has (fake) student IDs and grades of various assignments. This child process computes the average score of each assignment across students of section ‘A’, and thereafter prints the details of these assignments (of section ‘A’, i.e.). The parent process does the same operation, on the same CSV file but for assignments given to students of section ‘B’.
The parent process must wait for the child process to terminate, by using the system call waitpid(). The child process must call the exit() system callonce its execution ends.

Now create a separate program which repeats exactly the same steps as above, but uses threads using pthread create() and pthread join(). For the program that uses threads, once the averages are computed, also compute the average score of each assignment across the sections by reusing the result obtained by the two threads.

You would require to refer to the manpages for various system calls mentioned.

Note: You are expected to use read and read system calls, to read and write to the file.


1. Write a program with three functions A(), B() and C().

2.A() should call B() passing a 64-bit integer as an argument.

3.B() should interpret that as a 8-byte ASCII string and print individual characters on screen. You need to call the write() system call from assembly language using the syscall instruction, passing appropriate arguments.

4.Modify the stack in the function B() in such a way that when B() executes the ret instruction, it jumps to a third function C(). C() must also be written in C. This MUST happen without an explicit call to function C(). A mere ret from B, should pass the control to function C() instead of A(). Finally, the function C() needs to terminate the program by using the exit() system call.

5.You ofcourse also need a main() function from where the program starts. The C file with the main() function could also have the function A() (i.e., main() could call A()).

6. The functions A(), B() and C() need to be in three different files. You may use printf() or write() functions to display which function you are in.

More products