程序代写 System Programming (Section 3174, 3176)

System Programming (Section 3174, 3176)
Project #1 Find the minimum number using multi-process (Due date: 11/06 11:59pm, Hard Deadline, No Extension)
– Project Objective
– Students can write a Makefile to compile the source codes for their program.

Copyright By PowCoder代写 加微信 powcoder

– Students can make a program using system calls related to multi-process, signals, and
IPC (Inter-Process Communication).
– Project Description
The main goal of this project is to find a minimum value of given integer arrays using multi-process. Please implement details of the functions in the proj1.c. You can find the functions as they mark with the comment “FIX ME”. Also, please implement the main function in the main.c file. You may follow the comments that explain what you implement.
0. The provided skeleton codes are written in C. You have to submit one Makefile and two source codes written in C (proj1.c, main.c). Please do not modify the proj1.h file. I will not consider the changes in proj1.h file.
1. Write a Makefile
Please write a Makefile script to compile the provided sourcde code. Your Makefile must
satisfy the following conditions:
1) If you type make in the shell, your source codes have to be compiled. – The name of the binary file should be proj1
– The compiler is gcc
2) If you type make clean, the object file (*.o) and the binary file (proj) should be removed from your working directory.
2. Write a program
1) The following information is provided by the arguments of the program that the user
– 1st argument : Number of inputs (number of integers) – 2nd argument : Number of processes.
2) Create a shared memory, and the parent process first creates a random integer array that the number of an element is equal to the number of inputs (1st argument of the program). Please use the generate_input function to create an integer array. Also, please implement details of the following function

The parent process should be paused after creating all child processes. The lastly created child process sends a process to the parent process to resume the parent process.
The parent process sends the signals to the child processes to resume the child processes.
The integer array is divided into chunks that have the same size. Each chunk will be assigned to each child process. Each child process should find the minimum value of the given chunk. Please implement the details of the following function
– Function that you have to implement: child_find_min_value()
The child process stores the minimum value in the shared memory region. As you know, the original integer array is stored in the shared memory region, so the value should be stored after the array. The minimum values in shared memory should be sorted by the id of the child process. Please implement the details of the following function
– Function that you have to implement: put_value()
The parent process waits for the child processes to reap. After that, traverse the minimum values that the child processes stored. And the parent process finds the minimum values.
The parent process prints the minimum value. After that, the parent process unlinks the shared memory region.
– Function that you have to implement: sets_shared_memory()
3) Create child processes. The number of child processes should be equal to the second argument of the program. The process ids of the child processes are stored in the array of process ids. Please refer to the following example:
– pid_t *pid_arr = malloc(sizeof(pid_t)*n_process);
– Do not add the new function to the proj1.h file.
You can modify the value of BILLION macro to test your code.
– Do not modify the arguments of the functions in proj1.c
– Do not make your code publicly available. It makes your score for this project 0.
– Please add –lrt flag to compile your source code. Example) gcc –o hello a.o b.o –lrt
– In WSL, POSIX shared memory is highly recommended.
– To pause the process, use the pause system call().

4. Submission
Please use ecampus and upload *.c files (proj1.c, main.c) and Makefile.
5. Question
Please use ecampus only.

程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com