XML

kent logo

CO631 Anonymous Questions and Answers Keyword Index

This page provides a keyword index to questions and answers. Clicking on a keyword will take you to a page containing all questions and answers for that keyword, grouped by year.

To submit a question, use the anonymous questions page. You may find the keyword index and/or top-level index useful for locating past questions and answers.

Keyword reference for flush

2004

Question 51 (2004):

I have started Q5 and was wondering if you could give any tips on how to convert a character to upper case. And also what you mean on flushing and how to do this.

Answer 51:

Just as a side-note, Q5 is not for assessment -- but doing it anyway yourself is useful! There are essentially two ways to convert between lower and upper case characters. The first is to do it arithmetically (since `BYTE's can be treated as regular values):

    upper.char := (lower.char - 'a') + 'A'

Of course, you'd better check that `lower.char' really is in the range `a' to `z' first. The second method is more cunning, and relies on the way ASCII characters are assigned:

    upper.char := lower.char /\ #DF

For flushing, see the answer to Question 91 (2000).

Keywords: q5 , flush

2003

Question 114 (2003):

Hi,

I dont quite understand when we should use `flush(out)'. Should this be after every time we make a statement like:

    out.string ("Philosopher ", 0, out)

or after each set of changes such like:

    out.string ("Fork ", 0, out)
    out.int (n + 1, 0, out)
    flush (out)

Answer 114:

After each set of changes. See the answer to Question 91 (2000).

Keywords: q7 , flush

2001

Question 23 (2001):

What is the difference between:

  out ! FLUSH

and:

  flush (out)

Answer 23:

None! As you can see by looking at the source code in /usr/local/work/co516/libsrc/utils.occ:

  PROC flush (CHAN OF BYTE out)
    out ! FLUSH
  :

Keywords: flush

2000

Question 91 (2000):

A friend told me that I should be using:

    out ! FLUSH

after every single output. My program works perfectly well without them. Do I need to include them for safety?

Answer 91:

Not for safety reasons. Unix flushes characters written to its standard output whenever the associated memory buffer gets full or when it gets a new line character. In addition, KRoC forces Unix to flush its buffer when the FLUSH character is sent.

You should flush your animation output after each completed update of the screen (but not, of course, after each character). If you did not and action was progressing slowly in your animation, you would not see anything until the Unix buffer became full when, suddenly, you would see everything that had happened since the last time the buffer was flushed. This is because individual animation updates would not usually include a new line character. If your animation is very active, you will be continually filling the Unix buffer and, so, would see things happening all the time.

However, if your animation is very active but includes a user freeze command and you haven't sent a FLUSH, the animation would freeze but you would not see the latest updates. Of course, you could respond to a freeze by sending a FLUSH ...

But if there are other ways of interacting with the animation (see a7-1997 and a7-1998 in the answers directory on raptor), you will need those FLUSHes. Otherwise you may run into latency problems: what you see on the screen might be the state of the animation a while back - the latest updates are buffered up somewhere and have not been sent to your screen yet!

Keywords: flush , animation

Referrers: Question 51 (2004) , Question 114 (2003)

Valid CSS!

Valid XHTML 1.0!

Last modified Mon May 15 17:39:45 2006
This document is maintained by Fred Barnes, to whom any comments and corrections should be addressed.