SeminarsLibraryServicesSupportLinksE-StoreProductsAbout UsHome

Multitasking Operating System Provides
Real-Time Support
"OS/2" improves upon previous operating systems by using interrupt-driven I/O, priority scheduling, and protected memory

MOST DESCRIPTIONS of IBM's new personal computer operating system ("OS/2") are based on specifications provided by IBM or Microsoft—not on actual experience with the system.  Having recently converted a real-time data acquisition and control software package to operate with this system, we have acquired extensive experience with OS/2 in a real-time context. Briefly, OS/2 successfully supports data  acquisition and control, is more reliable than MS-DOS (or PC-DOS, or just DOS), and provides our applications with significant benefits compared to the DOS versions.

OS/2 was designed to run on IBM's "PS/2 Micro  Channel" bus computers, but also will run on "AT"-compatible bus computers. The AT bus is the current standard for data acquisition due to the availability of numerous data acquisition and control adapter cards for it.  Many  people are apprehensive about using OS/2 because they have the impression that they will need a new computer. Those concerns are unfounded, since most 640-kbyte AT-compatible personal computers can be upgraded to use OS/2 for the cost of a 1.5-Mbyte memory card.  DOS is neither a real-time nor a multitasking operating system. Despite this, many popular data acquisition applications use DOS. These applications were created because DOS is a simple  operating system that functions without any memory protection. It does not prevent applications from gaining direct access to the PC's realtime clock.

Thus, developers built real-time functionality and multitasking  into their applications by circumventing DOS. Some applications have realtime schedulers built in, while others use real-time operating systems that run parallel with DOS.  The primary problem with DOS real-time applications is the lack of multitasking capabilities. This shortcoming surfaces when the user wants to run more than just the data acquisition or control application.  DOS multitasking "shells," such as Microsoft Windows, use the same "tricks" that real-time applications do, and they generally are incompatible. Our products allow one DOS application to multitask with them, but this arrangement is flawed since the two applications cannot transmit data to a disk at the same time, due to restrictions imposed by MS-DOS for reentering data.

OS/2 data acquisition, control

Our experience reveals that OS/2 has several design characteristics that are well  suited for data acquisition: it supports true multitasking; time-critical processes are supported by preemptive, priority-driven scheduling; it has interrupt-driven I/O; it supports a protected memory environment; it supports a  16-Mbyte physical memory space ("swapping" of applications to disk is optional); and applications have direct access to high-bandwidth peripherals—both real time I/O devices and high-speed graphics screens. Of all these characteristics, only the last is typical of DOS. True multitasking is necessary for data acquisition applications. These always have a real-time acquisition/ control task and service tasks such as writing data to a disk,  displaying data on the CRT, and interacting with the operator. OS/2's multitasking capability is excellent since, for two or more programs to run concurrently, no extra programming is necessary. The operating system automatically  time slices the tasks. The CRT and keyboard may be devoted to one of these running programs ("screen groups") at a time, and the user can switch between different screen groups with a "hot-key" sequence.

This scheme  is easy for software developers and users to implement since the user interface is exactly the same as it is in DOS when the program's screen group is active. The program that is interacting with the C RT and keyboard is  automatically allocated a higher priority by the operating system, so the speed of user interaction with the machine is similar to DOS. Response time degradation due to running programs is negligible.

We set up  multitasking within an application without any problems and used the OS/2 developer's toolkit for effective debugging. Additional tasks can be created with very little processor overhead, which enables good modular code. Another attribute of a multitasking system is the capability of multiple programs to simultaneously gain access to the disk system. Our OS/2 software can continuously log data to disk without any time restriction, even while it is in the  background for long periods of time.

Real-time functionality

The pre-emptive priority-driven scheduling of OS/2 makes real-time response possible. It is absolutely necessary that the data acquisition and  control I/O events occur at precisely defined time intervals. It is important that the data acquisition/control task execute on time, without any appreciable delay. It also is unacceptable for any data points to be missed. This is essential in control applications because the control algorithms require process data that are equally spaced in time. Data that are not equally spaced in time could cause a critical process loop to be poorly controlled.

Priority support for time-critical processes means that data acquisition/control tasks that are extremely time critical will interrupt the computer at the scheduled time for data acquisition, and the CPU will be  completely devoted to data acquisition and control at that time. The interrupt latency of an operating system is a measure of the task switching time and a quantitative measure of the appreciable delay. For Microsoft's implementation of OS/2, this latency is designed to be <450 msec on a 6-MHz Intel 30286 processor (or <100 msec on 25-MHz lnt& 30386 processors).

This time latency is short enough for most data acquisition applications,  and will steadily decrease as faster processors become available. If a smaller latency value for data acquisition is required, such as for high-speed signal recording for impact testing, it can be managed within OS/2 by direct  memory access (DMA).

The OS/2 scheduler is strictly priority based, and high-priority tasks can command exclusive control of the CPU for as long as necessary. Most ordinary OS/2 processes run in a "general priority"  category, with a "time critical" priority reserved for such items as data acquisition and control events which absolutely cannot be delayed. The OS/2 documentation discourages developers from using the time critical category.

There are subtleties in extracting real-time performance from OS/2. I do not recommend that end users try to write these types of applications because of the complexity of the system and the extensive testing needed  to verify that a given degree of real-time performance is achieved.

I/O Support

Interrupt-driven I/O is important for freeing the CPU while the peripherals are working. For RS-232 communications, DOS does  not have interrupt-driven I/O, and real-time applications have to implement their own interrupt handlers. This requires circumventing the operating system and communicating directly with the I/O hardware and interrupt system. It is prohibitive to support more than a few RS-232 ports in this manner, since there is neither DOS support nor a standard for the hardware ports. OS/2 allows simple support of large numbers of serial I/O ports (which users need in many  applications) because of the interrupt-driven operating system support. DOS is known for its optimized code for moving data to and from disk devices. It operates very near to the theoretical capacity of the disk I/O channel.

Our tests of data-throughput rates to disk show that OS/2 achieves similar rates to DOS. OS/2's disk accesses can simultaneously keep two disk drives running at maximum speed. This could not be done without interrupt-driven I/O. OS/2 is faster in 1/0 than other multitasking operating systems we have seen that use the Intel processors. Application noninterference Protected memory is important because it greatly enhances system reliability, which is especially important in many control and data acquisition applications. Memory is protected by hardware built into the system CPU that prevents one application from interfering with another application, or  with the operating system. This protection is implemented with a system of four privilege levels, or "rings."

AT-compatible PCs have memory protection built in, but DOS does not use it since it operates in an 8088/ 8086 emulation mode. Without protection, if a "bug" exists in an application, it can "crash" the entire operating system. With protection, the "bug" generates a protection fault, and the operating system and other applications  continue running. In DOS systems, access to >640 kbytes is achieved by a bank-switching scheme, called the LIM (LotusIntel-Microsoft expanded memory specification). The OS/2 method of accessing large amounts of memory is far superior to the DOS method.

OS/2 provides for direct addressing of the large memory space from the processor, while the LIM method only allows the mapping of small chunks of memory into the 1-Mbyte space addressable  by the 8088/8086 processors. Thus, the software must manage the mapping in and out of whatever memory it might need, thereby slowing down the software. OS/2 supports 16 Mbytes of memory. This is important for real-time applications  since the features needed for general-purpose data acquisition necessitate large programs and large data storage capacities. Many DOS application programs, including our own, have grown to the point where new features cannot be  added due to the 640-kbyte DOS limitation. OS/2 also supports virtual memory. This means that if more memory is needed than the amount of physical memory in the system, the operating system automatically "swaps" chunks of memory to  and from the disk.

Virtual memory is not desired for real-time work, since we do not want the application to wait until it can be swapped back into memory from the disk. Therefore, it is important that this feature can be  disabled and that performance is maintained when it is disabled. Protected memory supports software development, especially in the "C" language, which uses pointers heavily. If there is a problem in software under development,  instead of crashing, the operating system simply informs the operator of an attempt to violate protection and then terminates the program.  The operating system also indicates where the offending instruction came from, which assists in tracing and fix-

Networking a laboratory

NOT ONLY does a multitasking computer operating system allow different applications to run simultaneously, it also allows multiple copies of the  same application to be run together. As an example, consider the control and collection of data from reactors (chemical reaction chambers). Reactors typically run for extended lengths of time and are independently operated. One way  to provide computer control for these reactors is to have individual computers and peripherals for each reactor. However, this is very expensive, both in actual costs and in lab bench space. With OS/2, a single computer with a  single (multichannel) analog I/O interface and one copy of the software can perform the same function. Each control system can be started, stopped, and operated independently. Thus, a single computer system can provide all the  functionality of separate systems for each reactor.

Device accessibility

Direct access to high-bandwidth peripherals is important for access to high-speed data acquisition adapters and high-speed graphics displays. There are many data acquisition adapters available, and OS/2 makes it possible to use them efficiently.  Through device drivers, OS/2 allows software to have total access to these devices. OS/2 also supports DMA with these adapters, which is a common method for achieving high-speed data acquisition rates.  In DMA operation, the adapters clock high-speed data acquisitions with their own real-time hardware-based clocks, which are built into  the adapters. Since this type of hardware is commonplace, the interrupt latency does not prevent accurate high-speed data acquisition (i.e., >100 kHz).  In these cases, the interrupt latency is nonlimiting because  the CPU is not involved in the acquisition of data or the transfer of data into memory. OS/2 allows accessing of data acquisition adapter cards in the same manner as DOS does—with direct I/O instructions from the application. This is in contrast to other protected operating systems where access to the adapter cards is constrained by operating system device drivers, which are difficult to develop.  High-speed graphics also are important for data acquisition applications because collected data must be displayed at high speeds and with a user-friendly interface. OS/2 accomplishes this by allowing application programs to write directly into the graphics bitmaps for APA (all  point addressable) graphics.

Also important is the way that graphics standards are supported, such as the implementation of the virtual device interface (VDI) standard on OS/2. This graphics application program  interface provides total compatibility with the DOS implementation and is as fast or faster than the DOS version.  OS/2 and VDI also use virtual memory concepts to represent graphics for off-screen applications. When a graphics screen disappears from the CRT because a different screen group is brought into view, the application (now executing in the background) can continue to write graphics exactly as though they were still visible. Later, when  the application is selected to be on-screen again, the CRT is restored with all of the additional graphic information that was written while it was in the background.

DOS and OS/2 comparison

The OS/2 version of our "Labtech Notebook" has the same features and operates in the same manner as the DOS version, except for speed and channel capacity. While these versions are almost identical, the OS/2 version delivers some important  functionality that is unavailable in the DOS version.  The most important OS/2 functionality is that multiple copies of the software can be run in the same computer. This often is desirable in data acquisition and control  applications.  OS/2 also allows other large applications to run parallel with data acquisition software. Since all applications share simultaneous access to the same data (either through the disk or through interprocess communication), these applications can be integrated into the system in real time.

Typical examples of software that can operate parallel with data acquisition software are data analysis software, spreadsheets,  database management systems, expert systems, and neural networks. Another advantage of the OS/2 environment is that Notebook can be put in the background for long periods of time and continue to stream uninterrupted real-time data to disk. This cannot be performed with DOS. The OS/2 operating system has a complete set of features that is suited to real-time data acquisition and control. Our experience with it has been very good in that we have been able to translate the promised feature set of the operating system into applications software for data acquisition with good performance and functionalities that cannot be achieved with DOS.


 Frederick Putnam is president and founder of Laboratory Technologies Corp., Wilmington, MA. He has received several awards for his contributions to the test industry in the field of software and test workstations.

home | about | products | services | support | seminars | library | links