• 沒有找到結果。

Real-Time System

Chapter 3 Software Introduction

3.3 Real-Time System

It is usually defined as those systems in which the correctness of the system depends not only on the logical result of computation, but also on the time at which the results are produced.

A real-time system usually has a time-critical mission to achieve, and a typical real-time system consists of a controlling system, a controlled system, and the environment as shown in Figure3.5. Firstly, the sensors collect data from operating environment, then the controlling system uses the data to compute, and uses the computed results to adjust the actuators properly. Because a mismatch between the state of the environment as perceived by the controlling system and the actual state of the environment can lead to disastrous results, periodic monitoring of the environment as well as timely processing of the sensed information is necessary. Thus, time is the most precious resource to be managed in real-time systems..

3.3.1 Real-Time Tasks

Computations occurring in a real-time system that have timing constraints are called real-time tasks. The computer should execute the real-time tasks so that each task will meet its timeliness requirement. In other words, a real-time task should be finished before a certain time, called the deadline [6].

In the discussion of real-time system, the deadline is usually used as the dimension to define real-time system. Real-time systems are broadly classified into three categories based on the nature of their task deadlines:

(1) Hard real-time system, in which the consequences of not executing a task before its deadline may be catastrophic

(2) Firm real-time systems, in which the result produced by a task causes to be useful as soon as the deadline expires, but the consequences of not meeting the deadline are not very severe.

(3) Soft real-time systems, where the utility of results produced by as task decreases over time after the deadline expires.

Figure3.6 depicts the relationship between value and time for different types of deadline.

3.3.2 Solve the Real-time

To solve the real issues can be categorized in two directions, both directions is to proceed with real-time system. 1. Hardware, 2. Software

◎ Hardware real-time

as shown Figure 3.7, to make their computing core. Due to the hardware computing speed is very fast just like the double CPU systems. That can greatly reduce the CPU burden on the computer. The computer's CPU can concentrate on man-machine interface display, enabled perfecting, and the DSP CPU can deal with the motion control part of the system to address the real time issues.

◎Software real-time

Reached from the real time needs of the software required to start from the operating system, now more commonly used in industry quite a lot of real-time system, shown in Table 3.1, there VxWork, PowerTV OS, Java OS, Lino, Microware's David OS9, WinCE with plug-in Windows NT, Ardence (VenturCom) RTX ,and so on. This paper uses RTX to achieve real time.

RTX that develop by the U.S. Ardence (VenturCom) company establish Microsoft Windows operating systems in real-time subsystem.

The Microsoft Windows operating system kernel provide a real-time multitasking application program development environment. RTX on the Microsoft Windows operating system adds a powerful real-time architecture subsystem (RTSS), like the other subsystems. RTSS provides an execution environment and relative API, does not use the Microsoft Windows Scheduler, using their own Scheduler. Let the scheduling of all threads are better than the original operating system scheduling priority to ensure that the real time of RTSS.

3.3.3 Windows NT Operating System

Windows NT operating system is a multitasking system [7], as shown Figuer3.8. It’s multitasking managed by the system Kernel. The multitasking structure that is good or not is depend on the real-time performance. Operating system allow the multiple applications to run concurrently, there must use the scheduler to pre-define task for scheduling. Windows NT applications cell process. But the smallest execution unit of the scheduler is not process, is the thread. Scheduling the multitasking system starts from the Micro-kernel module of the Kernel Mode to perform. The multitasking scheduling rules is to set each scheduling unit (ie, thread) the priority value and the time slice. Thread’s priority value is higher with higher implementation priority. If the implementation priority is same, judge by the time slice.

The CPU take turns to those with the highest weights of thread service. In addition, Windows NT uses the dynamic priority to balance the execution time of the user input of process currently (and foreground process, and only one) and not to accept the user input of the process (background process, can be the majority). Basically, Windows NT divided the priority into 32 levels value of 0 to 31, where 0 ~ 15 known as the dynamic range, while 16 to 31 is called the real-time range.

Interrupt latency is the important indicator to evaluate the system real time performance. Interrupt in terms of the real-time system is a very important function, it represents the system capacity to handle external events. And the interrupt latency is the time when the system interrupt signals received from the hardware to begin implementation of an

interrupt service routine (ISR), but does not include the implementation of the ISR end time.

Windows NT manage the ISR by the preemptive multitasking framework. When the interrupt with higher priority occur, the lower priority interrupt will hand over the right to use the CPU until the implementation of ISR of the higher priority interruption end.

Windows NT has the feature of multitasking, providing users to perform more tasks simultaneously (such as data acquisition, real-time control, procedures, etc.). Its own the management system of the disk files, provides users with different levels of competence to access files.

And the hardware abstraction layer architecture provide various types of the access interface on hardware drivers to the hardware and software.

3.3.4 RTX Real Time System

RTX developed by the VerturCom company is software as the real-time control subsystem under the Windows NT environment [8]. The real-time subsystem (RTSS) provides number of core functions and resource management programs. It can share the system under resources (including the Win32API, Memory, Hardware I / O, etc.), and support real-time control hardware features in the Windows NT operating systems.

RTX provides the own fixed thread priority scheduler belongs to the software, and all the thread priority is corresponds to the Win32 thread priority to ensure that the thread can implementation under the core mode in the system like the Windows NT device driver.

VenturCom expand the Windows NT hardware abstraction layer

architecture, making it real-time subsystem can not use Windows NT kernal, the programmer can direct control over the hardware by the API to develop the real-time applications, its respond can reach 50us, higher than the time of the Windows NT claimed 100 times more.

RTX in the hardware I / O provide a timer to allow users to deal with the planning process in a fixed period. The user can also use the RTX interrupt handler to accept an external device or the external hardware interrupt demand, combined with the timer and interrupt handlers to achieve real-time control purposes. In addition, RTX for threads also offers a number of functions, including synchronization control and four functions of inter-process communication (IPC) to be synchronized and the communication mechanism. RTX architecture is shown in Figure3.9.

3.3.5 Synchronization and Communication Mechanism

Four functions are synchronization control- mutex, semaphore, event and inter-process communication (IPC) of shared memory.

Mutex

If the system process many process, system process only one job once.

Do the next job until the previous job is completed. For example, a number of computer want to print, the printer just only accept the control of one computer.

Semaphore

System allows to deals with more processes once, but it has the restriction. When the workload reaches its restriction, the system will

temporarily stop the work. For example the elevator can only burden three passengers, when a fourth person want to enter the elevator, the elevator will send out a warning sound. Does not allow the next passengers to log in place, unless there is an passenger to leave.

Event

When the setting condition establishes, the interrupt event of actions is triggered off. For example, the temperature device is set, when the temperature reaches 80 degrees the equipment is a warning, to reach 95 degrees is shut off the device.

Share Memory

The internal data communicate each other by the share memory, as shown Figure3.10. Such as Win32 users in the man- machine interface that want to issue a command to pass a signal to the RTX system must use the way of the share memory. This command (data) saves the memory, then the RTX real-time operating system get out the by the command (data) by the memory. Share Memory is a bridge of the data transmission between Win32 and RTX.

3.3.6 RTX Timer

RTX is the most valuable parts of Timer in its very fast and accurate, this is stable of RTX Timer to do real time action.

This paper uses the clock_2, and change the timer value to 100 microseconds. The clock type is as shown in Table3.2.

3.3.7 Problems Encountered at RTX system

When I write the program at RTX has encountered some problems, if there are experiencing the same problem can be used as reference.

Error message: RTX NT Starvation Timeout (5000us)-AllRTSS processes stopped.Debug and/ or use "RTSSkill" command to unload all process images

(Proc:81CA3A8, Thread:81BE4008 )

Solve:Check whether you were clogging up the memory or not.

Error message:file failed to load and start as an RTSS proess

Solve:The problem here is a bad RTX installation. Since the Add/Remove Programs Wizard cannot run, RTX will need to be removed manually. First, stop the RTX subsystem through the RTX Properties utility (located in the Control Panel). The A3200/RTX directory will then need to be deleted. Also, all references to RTX will need to be removed from the PC's registry (including HKLM\SOFTWARE\Ardence, HKLM\SOFTWARE\Venturcom, and HKLM\SOFTWARE\VCI). After this is done the A3200 can be re-installed. Ensure that RTX unpacks and installs after the last

"Next" button is pressed

Error message:unhandle exception in sc.exe OX C0000005: Access Violation.

Error message:CXX0030: Error: expression cannot be evaluated.

Solve:Check how much memory you open. Do you have no access

out of range?

Sometimes your rtss program will shut down, even the computer will crash.

Solve:You can enter the Dos mode, and enter the ‘RTSSKILL’, as shown Figure3.11, to check whether the same rtss process was opened twice. The same process does not allow to open too many times. If you open too many same process, you should use

‘RTSSKILL’ to kill the process.

.

相關文件