Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!wuarchive!texbell!texsun!newstop!sun!imagen!ram From: ram@imagen.UUCP (M.V.S. Ramanath) Newsgroups: comp.windows.x Subject: Porting to X Message-ID: <4494@imagen.UUCP> Date: 5 Oct 89 14:25:42 GMT Reply-To: ram@imagen.COM (M.V.S. Ramanath) Distribution: na Organization: Imagen Corporation, Santa Clara, CA Lines: 41 I've got a bitmap editor which reads ASCII text commands from stdin and executes them. For example: | Draw a circle with a 10 pixel radius centered at pixel 100:100 circle 100:100 rad=10; | Execute further commands in file 'abc.e' execute 'abc.e'; As can be expected, some commands are extremely CPU- and memory- intensive, especially when large bitmaps are involved. They can also be file-system intensive when, for example, lots of 'execute' commands (possibly nested) are involved or when large bitmaps are read from or written to files. I'd like to port it to X so that it reads commands from a subwindow and displays the resulting bitmap in another window with scrollbars (so I'll be shipping bitmaps to the X server). My question: What's the best way of porting this beast to X ? I'd like the response time to window events (move, resize, scroll) to be fast, so I can't spin in the usual loop waiting for the next event since that would mean very slow response when a CPU intensive command is invoked by the user. Two methods occur to me and I would greatly appreciate any comments or suggestions: 1. Scatter event dispatching calls throughout all the CPU intensive parts of the code, or: 2. Set up a timer to go off every so often and have the signal handler dispatch events. I'd prefer (2) because it means minimal changes to the code but the man page for signals warns that system calls may be interrupted. So, Is the standard I/O library careful to restart read and write calls if interrupted by signals, or do I have to write my own 'signal safe' version ? Is malloc() (which presumably uses sbrk) safe in the presence of signals ? Since I value reliability more than anything else, I'd rather not use signals if there is the possibility that there might be data loss when reading/writing from/to the file system. imagen!ram@sun.com