Hello, if you have any need, please feel free to consult us, this is my wechat: wx91due
Pipe-Sort
Learning Objectives
New mechanisms you will see and use include:
NAME
pipesort – An exercise in plumbing
pipesort [n:s:l:]
-n count Count is the number of sorters (default 1)
-s short Words must have more than “short” letters
-l long “long” is the maximum number of letters in a word.Letters beyond that are discarded
pipesort reads text from standard input and writes the unique words to standard output sorted in alphabetic order, using “count sorters”.
More than 1 sorter is an Extra Credit option, a good deal more difficult than the one sorter assignment. As before, don’t attempt it unless the basic assignment is perfect. You will get no points for the extra credit unless both are perfect, and could lose points if the multi-sorter code induces an error in the single sorter case.
pipesort returns 0 on success and 1 on failure
DISCUSSION
Internally, the program must be organized into 3 types of processes. A single process reads the input parsing the lines into words, a group of processes does the sorting, and a single process suppresses and counts duplicate words and writes the output. You should organize the processes so that every parent waits for its children, and if any process exits in error the main process returns the error code in its exit.
NOTES:
- You must use the system sort command (/usr/bin/sort) with no arguments to do the actual sorting, Created in Master PDF Editor
- You must not use any disk files, or large amounts of memory. There is NO LIMIT on how large the input may be, and you should test with large input files.
- If there is more than one sorter, Parse distributes the words round robin to the sorts
- All the I/O is done using the buffered I/O library (fget, fputc, etc), you will need fdopen for attaching to the pipes.
- Words are all alphabetic and case insensitive with the parser converting all alphabetic characters to lower case. Any non-alphabetic characters delimit words and are discarded.
- The “short” and “long” parameters affect the parsing. Words with “short” characters or less are discarded, words with “long” characters or greater are truncated to “long” characters.
- The output MUST have the count left justified in a 10 character field followed immediately by the word.