C代写|C语言代写|C++代写- System Programming

C代写|C语言代写|C++代写: 这是一个利用C语言处理ppm文件的问题,是一个训练I/O操作的代写
Write a C program to create a binary ppm file with 1000 by 1000 pixels. It uses five input
colors to draw a picture. See sample runs. The input colors can be: red, green, blue, yellow,
orange, cyan, magenta, ocean, violet. The corners of the central part should use the 250th and
750th row/column.
Restrictions on the file format:
• no comment line after the file type specification
• width (number of columns) and height (number of rows) formatted in ASCII decimal in
the second line, separated by a space
• maximal value of color components given in the third line
Requirements on parallel execution:
• The original process should write the header information into the image file.
• Use fork() to create 10 child processes. Each child process can use about 300KB of
memory to calculate 100 rows and write the data into the image file.
• The original process does not work on the pixels. It creates the 10 child processes to do
so. To avoid having multiple child processes simultaneously accessing the image file,
the parent process simply waits for one child process to terminate before creating the
next.
Other requirements:
• You are not allowed to use standard I/O library functions or graphics related libraries.
• The command line arguments include the following in order: (i) the name of the image
file; (ii) color for center; (iii) color for top-left corner; (iv) color for top-right corner; (v)
color for bottom-left corner; (vi) color for bottom-right corner.
Advanced requirements (optional):
• The numbers of rows and columns of the image are not fixed numbers. They are also
command line arguments.
• The number of child processes is not a fixed number. It is also a command line
argument.
Marking scheme:
• 0.5 logically clear
• 0.5 follow the instructions and correctly use fork() etc.
• 0.5 successfully compile
• 0.5 pass all tests
60-256 System Programming Dr. Chen
Sample runs:
>>>>> kindergarten drawing.ppm blue green red yellow magenta
>>>>> gimp drawing.ppm
>>>>> kindergarten drawing.ppm orange ocean yellow violet cyan
>>>>> gimp drawing.ppm

发表评论

电子邮件地址不会被公开。 必填项已用*标注