kent logo

CO538 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 pause-process


Question 20 (2002):

Sir, could you explain the process below. Have been trying to figure it.

  PROC pause (CHAN OF BYTE in, interrupt, out)
      BYTE x :
      PRI ALT
        interrupt ? x
            x = 'Q'
              black.hole (interrupt)
              interrupt ? x
        in ? x
          out ! x

From my understanding, if data is pending in the interrupt channel, then it checks if it is the 'Q' char. If it is, it goes into a black.hole - otherwise it waits for data to enter though interrupt. So, when does it ever check the second guard?? Thanks.

Answer 20:

(This process is part of the model answer to Q3 on the exercise sheet.)

As you say, if data is pending in the interrupt channel, it inputs it and checks for 'Q'. If it got a 'Q', it goes into an infinite loop that just swallows anything else sent down that interrupt channel - and will never check that second guard (i.e. data will never flow through this device again from in to out, which is what we want).

If the value input from interrupt was not 'Q', it waits for a second character to arrive on interrupt - during which wait it never checks that second guard (i.e. data will not flow from in to out, which is also what we want). If and when it gets that second character on interrupt, it loops around and starts listening again on the in and interrupt channels - now data arriving on in will flow thorugh to out, which is what we want.

Keywords: pause-process , alternation


Question 15 (2001):

Can you give me a hint on how to implement the `PAUSE' method for part 4? I know how to do the quit function but need to be able to put this deadlock within the pause function.

Answer 15:

Implement a `PAUSE' in the same way as you did for question 3 (as discussed in your seminar groups). To cause deadlock as the response to a QUIT, the simplest way is to arrange for the process that manages the PAUSE effect to terminate - that leaves its upstream processes blocked all trying to output. Your keyboard monitor is still active - so your system is not yet deadlocked. But as soon as you type one of the characters to which it responds by outputting to the rest of your (now blocked) system, that output won't be taken and your keyboard monitor will block. Everything is now stuck and the run-time system will detect deadlock and quit.

Keywords: pause-process , q4

Question 14 (2001):

I have created the `pause' process to respond to `s' as step 4 of Q4 asks. But where does it go? Does it take input direct from the keyboard and then outputs to the monitor or does the monitor output to the pause process??

Answer 14:

It can't take input direct from the keyboard (as happened for question 3), since the keyboard is already connected to the monitor process. Channels may only connect to one process (at each end). So, I guess that monitor must output to the pause process!

Oh - I see what you were wondering: connect keyboard to the pause process along with the input/output channels whose traffic it's going to freeze ... and pass on keyboard input other than `s' to the monitor. Well, you could try that but I would advise against. There is a nasty deadlock lurking if you do this ... can you see it?

Keywords: pause-process , q4

Valid CSS!

Valid XHTML 1.0!

This work is licensed under a Creative Commons Attribution-Share Alike 3.0 Unported License.
Last modified Mon May 20 13:50:29 2013
This document is maintained by Fred Barnes, to whom any comments and corrections should be addressed.