1
0
mirror of https://github.com/Interlisp/maiko.git synced 2026-01-13 15:18:14 +00:00
Nick Briggs 377a6f3f47
Rewrite keyboard and async I/O handling to improve performance and reduce dependency on async I/O signals (#392)
* Rewrite keyboard and async I/O handling to improve performance and reduce dependency on async I/O signals

Replaces the SIGIO handler, which used to process X events in the interrupt context, with
a stub routine that sets a flag to signal processing is required.
Actual event processing is moved to the main dispatch loop where Lisp periodic interrupts
are handled.

Removes the X connection file descriptor from the set of fds contributing to SIGIO events
and moves the processing of X events to where the Lisp periodic interrupt is handled in
the main dispatch loop.  This code is already guarded by a check for XPending() so can
be called regardless of whether any file descriptors are known to be ready.

Actual processing of async I/O events and X events are handled by procedures
process_io_events() and process_Xevents() respectively.  For the most part these are
a renaming of getsignaldata() and getXsignaldata().

The Lisp periodic timer (VTALRM) was set to operate with a 25000 us period (40 Hz),
but on modern hardware it is possible to run this timer with a period of 10000 us (100 Hz)

Incidentally, a bug was noted (and fixed) in the X event handling code for motion events:
Mouse motion without any keyboard activity should not add an entry to the keyboard event
ring buffer as these events do not represent a key state change.
Since the ring buffer is of limited size, when it is filled new events are ignored
until the buffered events are processed.  This resulted in the loss of a key/mouse button
transition (up or down) if the mouse was moved about "too much" between keyboard events.

A few incidental cleanups were also made:
  - KBDEventFlg initialization fixed (wrong semantic type)
  - Event_Req renamed to IO_Signalled (more appropriate name)
  - int_io_open() sets up process (self) to handle SIGIO generated by O_ASYNC operations
  - LOCK_X_EVENTS turned off since X library calls can no longer happen in an interrupt context

* Use of O_ASYNC must depend on the symbol being defined (looking at you, Cygwin)

* Add SA_RESTART flag to sigaction for SIGVTALRM periodic interrupt

* LOCK_X_UPDATE is no longer needed and should not be defined by default for Solaris in version.h
2021-09-02 12:42:51 -07:00
2020-12-29 11:00:24 -08:00

Maiko

Maiko is the implementation of the Medley Interlisp virtual machine, for a byte-coded Lisp instruction set and some low-level functions for connecting with Lisp for access to display (via X11) and disk etc.

For an overview, see Medley Interlisp Introduction.

See the Medley repository for

Bug reports, feature requests, fixes and improvements, support for additional platforms and hardware are all welcome.

Development Platforms

We are developing on FreeBSD, Linux, MacOS, and Solaris currently on arm7l, arm64, PowerPC, SPARC, i386, and x86_64 hardware.

Building Maiko

Building requires clang, make, X11 client libraries (libx11-dev). For example,

$ sudo apt update
$ sudo apt install clang make x11dev
$ cd maiko/bin
$ ./makeright x
  • The build will (attempt to) detect the OS-type and cpu-type. It will build binaries lde and ldex in ../ostype.cputype (with .o files in ..ostype.cputype-x. For example, Linux on a 64-bit x86 will use linux.x86_64, while MacOS 11 on a (new M1) Mac will use darwin.aarch64.
  • If you prefer using gcc over clang, you will need to edit the makefile fragment for your configuration (makefile-ostype.cputype-x) and comment out the line (with a #) that defines CC for clang and uncomment the line (delete the #) for the line that defines CC for gcc.
  • There is a cmake configuration (TBD To Be Described here).

Building For MacOS

  • Running on MacOS requires an X server, and building on a Mac requires X client libraries. An X-server for MacOS (and X11 client libraries) can be freely obtained at https://www.xquartz.org/releases

Building for Windows 10

Windows 10 currently requires "Docker for Desktop" or WSL2 and a (Windows X-server). See Medley's README for more.

Languages
C 95.6%
Assembly 3.4%
CMake 0.5%
Shell 0.3%
sed 0.2%