CS 3733 Operating Systems, Spring 1999 Assignment 5 Comments


Warning: This is not for the current semester.


Assignment 5 notes: Spring 1999

  1. Part 1: There are a number of ways to store the reuired information. See my solution in usr/local/courses/cs3733/spring99/assign05/hfilter.c for one method.
  2. Part 2: A design decision must be made as to where to put the signal handler. The signal handler must distinguish between upstream and downstream data so it should go in the filter module. Make the info buffers used for the upstream and downstream data static (linkage class) global variables so that the handlers can access them.
  3. Part 2: The filter module should not know about the method used for storing information in the info buffer. Use methods in the header_filter module that take an info buffer as a parameter to retrieve the number of bytes and lines.
  4. The program should exit when it has received the two signals back. The easiest way to handle this safely is to put a pause in an infinite loop and exit from the signal handler. Each signal handler would set a flag after it has been called and exit if the other flag has been set.

Here is what the testasst5 program does:
Each time it sends a string it waits for a short time and sends a SIGUSR1 signal.
It then waits for both a SIGUSR1 and SIGUSR2 signal before sending the next string (no string terminator).
The strings are:
  1. "This is a test\n"
  2. "Partial line"
  3. " and rest of file\n"
  4. "First line\nSecond line\n"
  5. "First line\005Second line\n"
  6. "First part\005Second part\nFull OK line\n"
  7. "First part\005Second part\nPartial OK line\n"
  8. " and the rest.\n"

Here is the output that could have been generated from the test program.
Two numbers are givin on each line. The second number has the initial value subtracted out so that the "Open upstream" is not counted.
% testasst5 6775 pipe1
Getting initial data
Number of data bytes is 14 0
Number of data lines is 1 0

Sending full line
Number of data bytes is 29 15
Number of data lines is 2 1

Sending partial line
Number of data bytes is 41 27
Number of data lines is 2 1

Sending rest of line
Number of data bytes is 59 45
Number of data lines is 3 2

Sending 2 lines
Number of data bytes is 82 68
Number of data lines is 5 4

Sending line with nonprinting character
Number of data bytes is 105 91
Number of data lines is 5 4

Sending line with nonprinting character and OK line
Number of data bytes is 141 127
Number of data lines is 6 5

Sending nonprinting line then partial line
Number of data bytes is 179 165
Number of data lines is 6 5

Sending rest of line
Number of data bytes is 194 180
Number of data lines is 7 6
Here is sample output from pipe3:
% cat < pipe3
!Open upstream
This is a test
Partial line and rest of file
First line
Second line
Full OK line
Partial OK line and the rest.
Close upstream
Here is sample output from pipe5 (some lines have imbedded nonprinting characters:
% cat < pipe5
This is a test
Partial line and rest of file
First line
Second line
First lineSecond line
First partSecond part
Full OK line
First partSecond part
Partial OK line and the rest.