In the next part of the test tp ttyeotct and tp ttymin are compared In

In the next part of the test tp ttyeotct and tp

This preview shows page 42 - 44 out of 140 pages.

In the next part of the test, tp->tty_eotct and tp->tty_min are compared. In canonical mode both of these variables refer to complete lines of input, and in noncanonical mode they refer to characters. Tp->tty_eotct is incremented whenever a "line break'' or a byte is placed in the input queue and is decremented by in_transfer whenever a line or byte is removed from the queue. In other words, it counts the number of lines or bytes that have been received by the terminal driver but not yet passed on to a reader. Tp->tty_min indicates the minimum number of lines (in canonical mode) or characters (in noncanonical mode) that must be transferred to complete a read request. Its value is always 1 in canonical mode and may be any value from 0 up to MAX_INPUT (255 in MINIX 3) in noncanonical mode. The second half of the test on line 14429 causes in_transfer to return immediately in canonical mode if a full line has not yet been received. The transfer is not done until a line is complete so the queue contents can be
Image of page 42
modified if, for instance, an ERASE or KILL character is subsequently typed in by the user before the ENTER key is pressed. In noncanonical mode an immediate return occurs if the minimum number of characters is not yet available. [Page 343] A few lines later, tp->tty_inleft and tp->tty_eotct are used to control the main loop of in_transfer. In canonical mode the transfer continues until there is no longer a complete line left in the queue. In noncanonical mode tp->tty_eotct is a count of pending characters. Tp->tty_min controls whether the loop is entered but is not used in determining when to stop. Once the loop is entered, either all available characters or the number of characters requested in the original call will be transferred, whichever is smaller. Characters are 16-bit quantities in the input queue. The actual character code to be transferred to the user process is in the low 8 bits. Fig. 3-40 shows how the high bits are used. Three are used to flag whether the character is being escaped (by CTRL-V), whether it signifies end-of-file, or whether it represents one of several codes that signify a line is complete. Four bits are used for a count to show how much screen space is used when the character is echoed. The test on line 14435 checks whether the IN_EOF bit (D in the figure) is set. This is tested at the top of the inner loop because an end-of-file (CTRL-D) is not itself transferred to a reader, nor is it counted in the character count. As each character is transferred, a mask is applied to zero the upper 8 bits, and only the ASCII value in the low 8 bits is transferred into the local buffer (line 14437). Figure 3-40. The fields in a character code as it is placed into the input queue. 0 V D N c c c c 7 6 5 4 3 2 1 0 V: IN_ESC, escaped by LNEXT (CTRL-V) D: IN_EOF, end of file (CTRL-D) N: IN_EOT, line break (NL and others) cccc: count of characters echoed 7: Bit 7, may be zeroed if ISTRIP is set 6-0: Bits 0-6, ASCII code There is more than one way to signal the end of input, but the device-specific input
Image of page 43
Image of page 44

You've reached the end of your free preview.

Want to read all 140 pages?

  • One '20
  • ASCII

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern

Stuck? We have tutors online 24/7 who can help you get unstuck.
A+ icon
Ask Expert Tutors You can ask You can ask ( soon) You can ask (will expire )
Answers in as fast as 15 minutes
A+ icon
Ask Expert Tutors