& Assignment InformationThis program shall be written in C, compiled with the following options: -Wall -Wextra-std=c99, and display no errors and no warnings. Do not submit executable files (only C source files).In this assignment, you are to implement a program that copies a large file from its standard input (stdin) to the standard output (stdout) using semaphores and shared memory.The program shall create an array of M shared memory segments of size N each, where M and N are positive integer numbers and the only command line parameters. If there are fewer or more command line parameters, the program shall report an error message and terminate. Use functions shmget, shmat, shmdet, and shmctl to operate the shared memory.The program shall then create three semaphores (use functions semget, semop, and semctl) and fork a child process. The shared memory segments and the semaphores will be inherited by the child.The program shall execute an M-buffer producer-consumer algorithm, as explained in class. The producer process shall read up to N bytes from stdin into the first available shared memory segment, while the consumer process shall write up to N bytes from the first available shared memory segment tostdout. Since the last read operation is likely to result in fewer than N bytes, there must be a way for the producer to provide the length of the used part of each buffer to the consumer (hint: allocate N+sizeof(int) bytes for each buffer).The child process shall terminate upon writing the buffer that has fewer than N bytes. The parent process shall wait4 for the child, then destroy all semaphores and shared memory segments, print the total elapsed time to stderr and terminate itself.Test your program by copying the large file from the “Explore a Big File” project. The source and the target files must be identical (command diff source.file target.file must not display anything).Once you know the program is correct, run it each value of M on the list 1,2,4,8, and 16, and each value of N on the list 100, 1kB, 10kB, 100kB, and 1MB (the total of 25 runs; you may want to automate the process by writing a shell or Python script). Submit a tabular file with 25 rows and three columns: M, N, and elapsed time.本团队核心人员组成主要包括BAT一线工程师,精通德英语!我们主要业务范围是代做编程大作业、课程设计等等。我们的方向领域:window编程 数值算法 AI人工智能 金融统计 计量分析 大数据 网络编程 WEB编程 通讯编程 游戏编程多媒体linux 外挂编程 程序API图像处理 嵌入式/单片机 数据库编程 控制台 进程与线程 网络安全 汇编语言 硬件编程 软件设计 工程标准规等。其中代写编程、代写程序、代写留学生程序作业语言或工具包括但不限于以下范围:C/C++/C#代写Java代写IT代写Python代写辅导编程作业Matlab代写Haskell代写Processing代写Linux环境搭建Rust代写Data Structure Assginment 数据结构代写MIPS代写Machine Learning 作业 代写Oracle/SQL/PostgreSQL/Pig 数据库代写/代做/辅导Web开发、网站开发、网站作业ASP.NET网站开发Finance Insurace Statistics统计、回归、迭代Prolog代写Computer Computational method代做因为专业,所以值得信赖。如有需要,请加QQ:99515681 或邮箱:99515681@qq.com 微信:codehelp
网友评论