This program demonstrates inter-process communication (IPC) using message queues, pipes, and signals in C. The manager process divides a list of numbers into smaller portions and assigns them to worker processes. Each worker computes the sum of its assigned portion, and the manager collects the results to compute the final total sum.
- Manager divides the list into smaller portions for workers.
- Workers compute partial sums and send the results back to the manager.
- Communication between processes is done using:
- Message queues for data distribution.
- Pipes for sending results.
- Signals (
SIGUSR1andSIGUSR2) for synchronization.
- The manager computes and displays the final total sum.
- C compiler (GCC or similar)
- Linux/Unix-based OS for process management and IPC features
-
Clone the repository:
git clone https://github.com/MoncefDrew/manager_workers_tp.git cd manager-worker-sum -
Compile the program:
gcc -o sum_program sum_program.c
-
Run the program:
./sum_program
btw yall can run it here : https://www.onlinegdb.com/online_c_compiler
Enter number of workers: 3 Enter numbers (end with -1): 12 12 3 5 2 -1 The list of numbers for worker number 0 is: [12, 12], the partial sum is 24 The list of numbers for worker number 1 is: [3, 5], the partial sum is 8 The list of numbers for worker number 2 is: [2], the partial sum is 2 Total sum: 34