JAVA is used for the top ten advantages of embedded systems

xiaoxiao2021-03-06  47

The advantage of the Java language is that it is originally designed by a small and focus of understanding and trusting network computing dreams. Although the initial implementation of the language is a little defect, they have little technically compromise. Results have born a kind of communication as the main point of communication

The language designed for equipment. There are many technologies that can guide embedded system developers to choose Java.

1. Unrelated to the processor

The first advantage of Java is that it has nothing to do with the processor. This advantage seems to have no coherence with the embedded system. Traditionally, the embedded procedure is designed for specific microprocessors and runs them, while the portability of the C language program can be guaranteed by compiling or cross-compiling.

But in Sun's model, a program may be stored on a system, and downloaded and run on another completely different system; the device may download some programs from different places to run on one processor, or different The processor runs a program that passes the data between each other through the network. Using Java, an embedded system may become a generic communication device that can download and run programs that can complete specific tasks.

For embedded systems, this is a new model, and some developers are being close to it. For example, the supplier of TV set-top box has announced incorporated into JVM to enable users to support some of the TV programs through Java Applets while watching TV. In this way, when you watch the football match, you can see the technical statistics for the player. If you are watching a movie, you can be the background information of the actor. JVM is also ported to mobile phones so users can receive stock quotation information, competition scores, and other instant information.

This is an appropriate design and implementation model, first it can make the development platform more flexible, there is no need to develop on the same platform as the target, nor does it need to care for cross-compilation, because Java bytecod can be in any JVM Operating in the operating system. Second, another advantage of this model is that almost all detection and commissioning can be done independently of the target device. However, some data inputs and hardware interactions require tests on the target (or a good simulation system). Since individual JVMs sometimes have compatibility issues, you should test it on all platforms that will use the program. But in general, don't be advanced and expensive, equipped with logical probes, ICE, and other debugging tools for development environments for the target platform.

2. Object-oriented increase development speed and maintainability

Java is a purely object-oriented language. All code and data are part of a class, no global variables or code exists independently, an object is an instance of a class, the object is by calling the operation method, or the function is operated, and these methods or The function is also part of the class, and the object's method operates on the data of the object. The Java class is organized into a level hierarchy, a subclass can inherit its superclass behavior, and some unique functions that can be used to extend its superclability. The object model is that you can define the data structure of the true thing, so that the tasks of the program and how the tasks are implemented between the two becomes substantially transparent.

There are six major classes in the Java class (twenty-three classes) becomes package. To apply any object in any package, you only need to declare that package. You also have a full inheritance in the class level, and any level of deep objects can take all methods defined in the hierarchy.

The advantage of object-oriented design and programming is that the development speed and code of the code, many object-oriented development can be done by using and changing the existing class library, not create a new structure. This makes the development accelerated, and the developers of Sun's Java Workshop (a completely use of Java) can establish a functional graphical IDE in a few months is a good evidence. Object-oriented methods also try to use natural structures, making it highly readable and can be easily changed and strengthened. 3. Height

Because of the JVM, a Java application is completely isolated from the operating system or hardware, so computer viruses or other code-making code is difficult to obtain control of the device. A virtual machine is a protective layer between host devices and software that may be difficult to determine their quality and reliability.

In addition, Java designers remove the concept of pointer variables from this language. Java cannot arbitrarily accessing memory and can only read and write objects created by the Java memory assignment management system. Due to the rigorous classification mechanism for Java compiler, it is impossible to access memory areas that are not assigned to procedures in theory. This limit makes the program to write malicious code very difficult. Of course, this protection is not perfect, some people have found a vulnerability in the Java security model, some of which have been processed by SUN. Some programmers who have causing but unscrupulous programming may write some programs, intentionally, but not directly change the contents of memory, or obtain passwords or other information from the host. However, JVM does provide certain protection, making it almost impossible to run code directly on the hardware.

The restrictions applied to Java Applet are more stringent. Since the Java Applet is designed to download from the Internet, it is considered an untrustful code unless it includes digital fingerprints you have identified as trusted hosts. The JVM is called a region of SANDBOX in a region of memory such as Applet. Untrustful code. It assigns resources and privileges for each applet and defines it in these assigned area. In addition to these restrictions, the Sandbox model also applies the following limit: prohibiting reading and writing a local computer file system; network operation is limited, there is no trusted code to establish a network connection with any computer, except for the computer downloaded, there is no On any port number of any less than 1024 (the port range reserved for the Standard Network Protocol is used) listening and accepting the connection; access or create threads are disabled outside of the thread group that is not trusted by trusted code.

4. Memory management is simple

Java's memory management is much simpler than other languages ​​because it does not use pointers. When the object is instantiated, the memory is dynamically allocated. As we analyzed earlier, access to individual memory addresses is considered a potential danger of security by Java designers, and therefore, access is also disabled. Moreover, Sun's network model has assumed that you may not know the target processor, and reference dedicated memory addresses becomes unnecessary. The result of removing the pointer not only improves security, but also simplifies programming, the error is also reduced.

In order to understand how Java allocates memory, we will compare with the C language. In C language, data can be accessed by values ​​or references. In fact, non-raw data types are accessed by reference for flexibility and control considerations. Therefore, the differences and references have become very clear, especially if you have to use different symbols (* and &) to access data. To use these two different ways, you must understand what they are and why you should use this one, not the one.

In Java, storage is seamless by values ​​and references, especially because their symbols are. The only difference between the two is that the data type itself: all raw data types are always accessed by values; all objects, arrays, and file streams, are always accessed by reference. Declare that the original data variable type contains the value of the variable, declares that the variable of the object contains a reference to the object (ie, the address of the object), not the object itself. Just declares that an object variable does not assign memory to an object, you must use the "New" keyword to allocate memory and create objects. The most fundamental differences between these two methods are: impossible to make pointer arithmetic or other operations as Java memory addresses as in C. The address of the object in Java is relatively (or virtual), which is allocated by the virtual machine, so you have no reason to want the pointer address.

5. Garbage collection function

Garbage collection automatically collects memory untruritable in memory and returns to the empty memory list. JVM Use this feature that will not be used by memory. When the Java program illustrates and instantiates an object or array, it only makes a JVM request, access the following system memory (usually through the host operating system) and allocates the memory, Java's garbage collection system passes the memory, then check They reference chains. Java's garbage collection system is generally an object in memory and then checks their reference tables. How many variables in its computing program are currently being referenced each object. If the number of references is zero, it knows that this object is no longer used, and its memory can be recovered. As a result, it is not necessary to manually release the allocated memory as you do in the C language. In C, release memory is a necessary, time consuming, and error-free detail. Java automatically and precisely handles this process, and removes the common mistakes in the C / C program.

6. Convenient network

Since today's embedded systems are usually network-oriented, the language supported by built-in networks saves a lot of time and efforts to implement network protocols and communication programs. In Java, network classes include TCP / IP streams and data reports that use TCP and UDP, for HTTP and URL services, and error check code and recovery. Although it is also possible to implement networks, such as C language, but those language require special accessories software package, DLL, or other program modules that must be provided by the operating system, or third-party sales, special accessories often require an operating system or Knowledge of tripartite tools, unlike Java, standard, built-in network support. Java includes the network to make it necessary because the designer cannot do any assumption to a network facility as a basis, they must include an integrated network library to ensure that the Java program works on all platforms.

7. Dynamic configuration

Dynamic configuration refers to the user to formulate configuration or reconfiguration at the time of system startup. Dynamic configuration is often used in a special hardware configuration, network parameter, or a system that supports specific purposes during boot. Java supports dynamic configuration with dynamic bundle. When you make a program's class files compiling into a zipper code, between your class files, or the class of the JVM package (such as graphics, network, and core language support), it has not been resolved. When JVM loads your program, it dynamically loads and bundles (ie links) all of your programs referenced. Therefore, to change the system configuration, everything you need to do is to fix the corresponding class file. When the next system, JVM automatically bundles new files into your program, and the new configuration will take effect.

8. Easy to trap and handle errors

Unlike many operating systems and procedures, restarting is often unacceptable to embedded systems, just like we don't want to call or watch TV. This means that all embedded systems must be strong enough to intercept errors to prevent them from crashing the entire device or worse. The cause of the program is caused by a lot. Relatively, few because inheritance logic errors, and most programs have caused accidental input, or because the program cannot call system resources to complete a particular operation. Therefore, these problems must be expected, and they must be attacked to avoid greater problems. Although it can be trapped and handled in almost any programming language, but if there is a built-in facility to do this, it will have great help like Java.

In Java, an exception is thrown (produced). Use statements designed specifically for exception (Keywords Try, Catch, and Finally), programs can arrange their error handling code to several centralized areas, and the TRY block is the normal process executed by the program. When an exception occurs in the TRY block (including each layer of subroutine in this nested block), the control is handed over to the CATCH block. No matter whether there is an abnormality, the code in the Finally block is always executed. Unreated exceptions transmit JVM from the call stack and terminate the program. No longer need to be programmed to return the error status to several layers of function calls. Instead, an exception is thrown directly from the code that is wrong by the error. This greatly simplifies the error handling code in the application, which in turn gains a better error handling effect and more solid and reliable code.

9. Provide linear support for thread management

Most operating systems give a process to generate and manage multiple threads, these threads complete different tasks independently. However, rarely provide linear support for thread management, usually needs to call operating system functions directly. On the contrary, Java is directly available, managed, and coordinated with synchronous threads directly in the language. As with other features of Java, this feature is necessary because the designer does not dare to determine if the underlying operating system supports multithreading.

Developers are increasingly using threads in programs, which uses a means of some tasks that meet one program that cannot be completed. Since Java has built-in language support for threads, you can create multi-threads with Java more simple and natural.

10. Powerful graphics

JVM includes a huge graphics and window support packages called Abstract Windowing Toolkit (AWT). With AWT, you can easily create a delicate and powerful graphical user interface in your application. For embedded systems that require fine user interfaces, AWT saves a lot of development time, making it faster to market.

转载请注明原文地址:https://www.9cbs.com/read-74526.html

New Post(0)