Real-time Java, part 3rd

Source: Internet
Author: User
Tags execution inheritance posix thread thread class

Threading and synchronization are the core features of the Java programming language, which are described in the Java Language Specification (JLS). RTSJ extends the core functions of JLS in a variety of ways. (See Resources for links to JLS and RTSJ.) For example, RTSJ introduces some new real-time (RT) thread types that must adhere to a more stringent scheduling strategy than normal Java threads. Another example is priority inheritance, which is a locking policy that defines how lock synchronization is managed when the lock is competitive.

Understanding the management of priority and priority sequences helps to understand RTSJ changes to threading and synchronization. Priority is also an important tool used by RT applications. This article describes RTSJ threading and synchronization by discussing how to manage thread precedence and priority sequences. Discusses some of the aspects you should consider when developing, deploying, and executing RT applications, including applications developed using IBM websphere®real time, see Resources.

Understanding Normal Java Threads

The threads defined in JLS are called normal Java threads. A normal Java thread is an instance of the Java.lang.Thread class that has 10 priority levels from 1 to 10. To accommodate a large number of execution platforms, JLS provides a great deal of flexibility in how to implement, dispatch, and manage the priorities of ordinary Java threads.

WebSphere VMs on linux® (including WebSphere real time) uses the local threading service provided by the Linux operating system. You can learn Java threading and synchronization by understanding the threading and synchronization of Linux.

Linux Threading and synchronization

Linux operating system development has so far provided a different user-level threading implementation. The Native POSIX thread Library (NPTL) (see Resources) is a strategic threading implementation of the latest Linux version, used by WebSphere VMs. The advantage of NPTL compared to its predecessor is POSIX compatibility and performance. The POSIX service can be obtained from the system's header file at compile time. The POSIX service can be obtained at runtime through the libpthread.so dynamic library and the underlying Linux core support. The Linux core can perform thread scheduling based on static controls, such as thread priority level, and some dynamic conditions for threads that are executing in the system.

POSIX allows you to create POSIX threads (pthreads) with different thread scheduling policies and priorities to meet the needs of different applications. The following are three of these scheduling policies:

Sched_other

Sched_fifo

Sched_rr

The Sched_other policy is used for traditional user tasks such as program development tools, Office applications, and Web browsers. SCHED_RR and Sched_fifo are primarily used for applications with higher certainty and time requirements. The main difference between SCHED_RR and Sched_fifo is that the SCHED_RR executes threads on a time slice, while Sched_fifo is not. The Sched_other and SCHED_FIFO policies are used for WebSphere real time and are described in more detail below. (We do not introduce the SCHED_RR policy, and WebSphere real time does not use it.) )

POSIX provides locking and synchronization support through the Pthread_mutex data type. Pthread_mutex can be created using a different locking policy. Locking policies often affect execution behavior when multiple threads need to acquire the same lock at the same time. The standard Linux version supports a single default policy, while the RT Linux version also supports priority inheritance locking policies. We will give a more detailed description of the priority inheritance strategy in the synchronization Overview section of this article.

Linux scheduling and locking is used to manage first-in first out (FIFO) queues.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.