標題: 分散式與即時系統上的先進 Java-Based 中介軟體之研究
Advanced Java-Based Middleware for Distributed and Real-Time Systems
作者: 焦信達
Hsin-Ta Chiao
Dr. Shyan-Ming Yuan
關鍵字: Java;執行緒同步機制;監督器;IP 多點投射;Java 訊息服務;訊息導向中介軟體;Java 即時計算標準;非同步事件處理;Java;thread synchronization mechanism;monitor;IP multicast;Java message service (JMS);message-oriented middleware (MOM);Real-Time Specification for Java (RTSJ);asynchronous event handling
公開日期: 2002
摘要: Java 本身是一種為網路的存在所設計的技術。因為它提供了平台獨立性、安全性、網路上的物件移動性、動態的類別載入、以及內建的並行與網路程式設計的支援,Java 是目前開發分散式軟體的最佳選擇。此外,由於 Internet 的快速成長,各種不同的嵌入式系統都會慢慢的以無線或有線的方式連上 Internet。這種趨勢將會刺激嵌入式系統的開發社群開始使用 Java,並刺激它們使用 Java 來開發即時控制軟體。Middleware 是一種系統軟體,位於應用程式與底下的作業系統、低階軟體、與低階硬體之間。它的主要功能是簡化應用程式設計師所要解決的某些程式開發問題、加快應用程式開發的 cycle、以及改進軟體的重用性。本博士論文的目的是,提出三個不同的 middleware 來分別解決三個使用 Java 來開發分散式與即時控制軟體時,所會遇上的問題。 第一個是並行程式設計的問題。它是開發許多系統軟體時,所需要的基本功能,尤其是分散式系統。Java 內建的執行緒同步機制是 monitor,它有以下的四點問題: 一、它屬於一種叫 no-priority monitor 的分類,二、每個 monitor 只提供了一個 condition queue,三、monitor 缺乏對排程的支援,四、可能會在發生 inter-monitor nested call 時產生 deadlock。在本篇論文裡,我們將會提出一個改良的 monitor - EMonitor,來解決前述的四個問題。 本論文所要解決的第二個問題是 network IPC 的問題。Message-oriented middleware (MOM) 是一種新的網路程式設計的 paradigm。它比較容易使用,而且也因為它的實作比較簡單,而會有比較好的效能。Java message service (JMS) 是目前 Java 上的 MOM 的標準。然而,目前大多數的 JMS implementation 都是 server-based 的架構,集中式的 server 可能會增加訊息傳送的 latency、成為 scalaility 的瓶頸、也會有 single-point failure 的問題。因此,我們提出了一個 IP-multicast-based 的 JMS implementation。它實作了 JMS 的 publish-subscribe API,目的是提供一個 LAN 內、或 Intranet 內的 Java 程式的快速訊息交換機制。 本篇論文所要解決的第三個問題是使用 Java 來開發即時控制程式的問題。Real-Time Java Specification (RTSJ) 是 real-time Java 的標準。作者在 1999 年第四季,參與了一個使用 Java 來開發塑膠射出成形機上的控制程式的研究計畫。然而,當時,RTSJ 的標準尚未定案,也沒有符合 RTSJ 標準的 JVM 可供使用。因此,我們在不支援 RTSJ 的 JVM 上,實作了一個即時擴充程式庫,讓我們的合作單位可以使用 Java 來開發即時控制程式。這個擴充程式庫具有以下的幾個特點: 一、它實作的是 RTSJ 0.9 版的標準的子集合。所以,使用它開發的即時控制程式,可以很容易地被移植到未來的 RTSJ-compliant 的 JVM 上。二、它實作時不需要修改下層的 JVM,所需的下層支援機制也不多,所以,它可以很容易地被移植到各種不同的 RTOS 上。因為 RTSJ 的標準相當複雜,不易移植,目前只有少數的主流 RTOS 有 RTSJ-compliant 的 JVM。因此,這個即時擴充程式庫,可以被看作是一個小型的、容易被移植的 RTSJ 的子集合。
Java inherently is a network-centric technology. Because it supports platform independence, security, network-wide object mobility, dynamic class loading, and built-in mechanisms for concurrent and network programming, Java is the best choice for developing distributed system software currently. Besides, due to the explosive growth of Internet, various kinds of embedded systems will connect to Internet gradually. This trend pushes the embedded system community to embrace Java, and inspires the requirement of using Java to develop real-time control software. Middleware is a category of software situated between applications and the underlying operating systems, low-level software and low-level hardware. Its main purpose is for simplifying the task of application programmers, accelerating application development cycles, improving the reusability of software. The purpose of this thesis is to present three problems of using Java to develop distributed systems and real-time control software, and to propose three different middleware for helping application programmers to solve them. The first problem is concurrent programming. It is an elementary building block for developing various kinds of systems software, especially for distributed systems. The built-in thread synchronization mechanism of Java is a simplified version of monitor, and it suffers the following four drawbacks. First, it belongs to a category of no-priority monitor. Second, it offers only one condition queue in a monitor. Third, it lacks the support for building more elaborate scheduling programs. Fourth, during nested monitor invocations, deadlock may occur. In this thesis, a refined version of monitor, EMonitor, is proposed to solve the forementioned four problems. The second problem to solve in this thesis belongs to the network IPC problems. Message-oriented middleware (MOM) is a new paradigm for network programming. In comparison to the traditional networking middleware, it is much easier to use, and can achieve better performance due to its light-weight implementation. Java Message Service (JMS) is the MOM standard of Java. However, most implementations of the JMS standard are server-based. The centralized JMS server may introduce more latency of message delivery, may become the bottleneck of scalability, and may induce the single-point failure. Hence, instead of the server-based one, here we propose an IP-multicast-based JMS implementation - the FJM (Fast Java Messaging). FJM implements the publish-subscribe messaging APIs of the JMS standard, and it is designed for efficient message exchange within a LAN or an Intranet. The third problem to solve in this thesis is using Java to develop real-time control software. Real-Time Specification for Java (RTSJ) is the official standard of real-time Java. Since the fourth quarter of 1999, the author engaged in a project where Java was employed to build the real-time control program inside a plastic-injection-molding machine. However, at that time, since the RTSJ standard was still under development, no RTSJ-compliant JVM was available. To satisfy the project requirement, we designed and implemented a real-time extension library on a non-RTSJ JVM. This extension library has the following advantages: First, since the library API is derived from the subset of the RTSJ public draft (version 0.9), the real-time control programs developed on it can be easily moved to a forthcoming RTSJ-compliant JVM. Second, the implementation of this extension library does not modify the underlying JVM, and only requires few underlying software and hardware resources. Hence, it can be easily ported to other RTOS. Because porting an RTSJ-compliant JVM is difficult, currently it is available only on few well-known RTOS. Our extension suggests the minimal implementation of the RTSJ, and its portability can help the developers to build Java-based control programs on an RTOS without the RTSJ-compliant JVM.