The source code shows a call to printf but this is not the same printf used by

The source code shows a call to printf but this is

This preview shows page 34 - 36 out of 140 pages.

to exercise the output system and kick anything that does not get initialized until first use. The source code shows a call to printf, but this is not the same printf used by user programs, it is a special version that calls a local function in the console driver called putk. The main loop on lines 13764 to 13876 is, in principle, like the main loop of any driverit receives a message, executes a switch on the message type to call the appropriate function, and then generates a return message. However, there are some complications. The first one is that since the last interrupt additional characters may have been read or
Image of page 34
characters to be written to an output device may be ready. Before attempting to receive a message, the main loop always checks the tp->tty_events flags for all terminals and handle_events is called as necessary to take care of unfinished business. Only when nothing demands immediate attention is a call made to receive. [Page 335] The diagram showing message types in the comments near the beginning of tty.c shows the most often used types. A number of message types requesting specialized services from the terminal driver are not shown. These are not specific to any one device. The tty_task main loop checks for these and handles them before checking for device-specific messages. First a check is made for a SYN_ALARM message, and, if this is the message type a call is made to expire_timers to cause a watchdog routine to execute. Then comes a continue statement. In fact all of the next few cases we will look at are followed by continue . We will say more about this soon The next message type tested for is HARD_INT. This is most likely the result of a key being pressed or released on the local keyboard. It could also mean bytes have been received by a serial port, if serial ports are enabledin the configuration we are studying they are not, but we left conditional code in the file here to illustrate how serial port input would be handled. A bit field in the message is used to determine the source of the interrupt. Next a check is made for SYS_SIG. System processes (drivers and servers) are expected to block waiting for messages. Ordinary signals are received only by active processes, so the standard UNIX signaling method does not work with system processes.A SYS_SIG message is used to signal a system process. A signal to the terminal driver can mean the kernel is shutting down (SIGKSTOP), the terminal driver is being shut down (SIGTERM), or the kernel needs to print a message to the console (SIGKMESS), and appropriate routines are called for these cases. The last group of non-device-specific messages are PANIC_DUMPS, DIAGNOSTICS, and FKEY_CONTROL. We will say more about these when we get to the functions that service them. Now, about the continue statements: in the C language, a continue statement short- circuits a loop, and returns control to the top of the loop. So if any one of the message types mentioned so far is detected, as soon as it is serviced control returns to the top of the main loop, at line 13764, the check for events is repeated, and receive is called again to await a new message. Particularly in the case of input it is important to be ready to
Image of page 35
Image of page 36

You've reached the end of your free preview.

Want to read all 140 pages?

  • One '20

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