5.1 About multitasking

5.1.3 A multitasking example

Assume that you had a window system and an editor that interact with each other through the Multitasking Facility. Whenever you invoke the editor with the functioneditor, the window system is initialized to contain the main editor window and a Lisp top-level window.

With this model, a call to the functioneditor creates the following processes:

This process runs the editing functions in response to keyboard input.

This process handles events that are signaled by the operating system, such askey-down andmouse-clicked. It also queues characters and runs methods associated with active regions.

For each top-level buffer, there is a Lisp buffer process that runs the top-level read-eval-print loop.

When you type the characterb as a single keystroke, the following sequence of events could occur:

1. Before the keystroke is acknowledged, the Multitasking Facility is in an idle state. The Lisp process has indicated to the operating system that it wants to pause, and the scheduler has no processes to run.

2. When the key goes down, the Lisp process runs a very short interrupt handler, which sets a flag called*window-wakeup*. The setting of this flag causes the window process to wake up and look for an event. It receives thekey-down event and queues that event as input to the editor process. Once the event is queued, the window process blocks and waits for another wake-up request.The scheduler then invokes the editor process because a keystroke is available.

3. The editor process reads the characterb from its input stream and looks it up in a command table. If the top-level buffer is current and ifb is a self-inserting character, the editor process insertsb into the buffer. It then waits for another character to become available.

4. The scheduler now looks at the Lisp buffer process, which is inside the Common Lisp functionread-char; this process is waiting for a new character to appear at the end of the buffer. Sinceb has appeared, the Lisp buffer process is able to run, and the scheduler invokes it. After reading the character, the Lisp buffer process blocks to wait for the next character.

5. Since all processes are now blocked, the scheduler returns to an idle state.


The Advanced User's Guide - 9 SEP 1996

Generated with Harlequin WebMaker