Familiarization of System Calls
To create a parent and child process using the fork() system call and compute the sum of even and odd numbers separately.
Algorithm
Step 1: Initialize Data
- Declare and initialize an array with 10 integers.
- Initialize variables to store the sum of even and odd numbers.
Step 2: Create a Child Process
- Call the fork() system call to create a new process.
Step 3: Parent Process Execution
- If fork() returns a positive value, the process is the parent.
- Traverse the array.
- Add all even numbers.
- Display the sum of even numbers.
Step 4: Child Process Execution
- If fork() returns zero, the process is the child.
- Traverse the array.
- Add all odd numbers.
- Display the sum of odd numbers.
Step 5: Terminate Program
- End execution of both parent and child processes.