Operating Systems / Chapter 1: The Shell / The Shell

Keypress Handling

If the following is true at time t:

  • interrupts -> keyboard is true
  • pressed_key is not the Enter key

then the following is true at time t + 1:

  • Pressed key is appended into shell -> user_input
  • Pressed key is also appended into shell -> buffer.
  • shell -> buffer is copied to display_io -> data.
  • display_io -> signal is set to true, which will interrupt the display.
  • interrupts -> keyboard is reset to false.

LWOS resets interrupts -> keyboard so that this step is not repeated.

For example, when a user presses the "k" key, the keyboard will interrupt LWOS as follows:

  • hostname: "computer_1"
  • status: "idle"
  • interrupts
    • keyboard: true
  • pressed_key: "k"
  • shell
    • user_input: ""
    • buffer: "> "
  • display_io
    • data: "> ",
    • signal: false

In response, LWOS updates the interrupts, shell, and display_io maps as follows:

  • hostname: "computer_1"
  • status: "idle"
  • interrupts
    • keyboard: false
  • pressed_key: "k"
  • shell
    • user_input: "k"
    • buffer: "> k"
  • display_io
    • data: "> k"
    • signal: true

The computer records the pressed key and asks the display to print the shell buffer (which includes the new key).

Quiz: Check All That Apply (1 point)

Please check all statements that are true:

   
   
   
   
   
Become a subscriber to save your progress, see the correct answer, and more!
Previous Lesson Next Lesson

Comments

Please log in to add comments