5.3 Debugging under multitasking
*terminal-io*, which has a global default value. This arrangement occasionally has undesirable results. For example, if two processes send output simultaneously to a standard stream, the two outputs can be intermingled on the screen.
A more confusing situation occurs when two processes are simultaneously waiting for input; then any input line that you type is passed to one of the processes at random. This condition arises most often when a process that generally does not require input or output ends up in the Debugger. When you are in this situation, Debugger commands have unpredictable results. For example, typing
:b might not produce the same backtrace in successive attempts; sometimes it might just print
:B rather than backtracing. You can verify this problem by checking the value of the variable
If you find that two processes are using the same stream, you should try to disable one process so that you can interact with the other without interference. For example, assume you had a reading function called
my-reading-function that took a stream and a process argument. If you wanted the process
my-process to read from the stream
*stream*, but another process was also reading from
*stream*, you could isolate the interaction to
my-process with the following code:
(with-scheduling-inhibited (clear-input *stream*) (my-reading-function 'my-process *stream*))In this case, no other processes can be scheduled while
my-processreads from the stream.
If you need more than one process to be running at a time, you cannot disable the scheduler. If there are only two competing processes and you know the name of each, you could use this method to isolate the reading to
(unwind-protect (progn (deactivate-process 'other-process) (clear-input *stream*) (my-reading-function 'my-process *stream*)) (activate-process 'other-process))In either case, you should clear the stream before reading from it.
Generated with Harlequin WebMaker