Lab 5 – Source-Filter-Sink: Concurrent Processes

Download Solution: Click to Download Solution
Solution File Name: CSampleSourceFilterSinkProgram.docx
Unzip Password: prestobear.com

Problem:
The program will include:

• The Source program obtains a source text-file filename from its commandline, opens the file,
and reads and copies the file contents one character at a time directly to standard output
(stdout). When the source file has been copied, Source terminates (closing all of its open file
handles).
• The Filter program does not utilize any filename commandline parameters. Instead, Filter
reads a text file from standard input (stdin) and writes to standard output (stdout) a copy of the
input with all lower-case vowel letters (a, e, i, o, u) converted to upper-case and other
characters remaining the same. Filter specifically must be designed to read one character,
convert it, output it, and then loop until the incoming data is finished (EOF on stdin).
• The Sink program obtains a destination text-file filename from its commandline, opens the file
for writing, and then reads characters one at a time from the standard input file (stdin) and
writes each incoming character directly to the destination sink file.
• Design each of the Source, Filter, and Sink applications to simulate doing “more work” by
delaying (e.g., using a busy-loop such as DELAY_A_WHILE() ) inside their copy loop, so that
the copy operations proceed more slowly. The busy-loop iteration count can be adjusted to an
appropriate value so that each application takes a few seconds to complete and you can
visually observe the applications starting and stopping. Note that “busy-looping” is not the
same as “SLEEP( )ing”, which will cause a process to become “not ready” and force an O/S
scheduling event.
• You can test each of the Source, Filter, and Sink applications individually by themselves
running from the commandline.


1.lab5.c
#include < ctype.h >
#include < stdio.h >
#include < windows.h >
#include < winbase.h >
#include < stdlib.h >

int main(int argc, char *argv[]) {

}

2.source.c
#include < stdio.h >
#define DELAY_A_WHILE() {volatile int j; for(j=0; j<1000; ++j);}

int main(int argc, char *argv[]){

}

3.filter.c
#include < stdio.h >
#include < ctype.h >
#define DELAY_A_WHILE() {volatile int j; for(j=0; j<1000; ++j);}

int main(){

}

4.sink.c
#include < stdio.h >
#define DELAY_A_WHILE() {volatile int j; for(j=0; j<1000; ++j);}

int main(int argc, char *argv[]){

}

Add Comment