Embedded real-time database management system
Embedded real-time database system is a layer of software between users and real-time operating system, which is composed of many program modules. Its function is to effectively organize, manage and access the shared data in the database, and its structure is shown in Figure 4. Among them, storage space management module, security integrity control module, transaction concurrency control module, real-time data dump module and running log management module are several problems that need to be solved in developing real-time database system in embedded environment: (1) storage space management module. Because the embedded real-time database system adopts memory database technology, it is bound to involve the memory management of embedded operating system. Therefore, users must understand the memory allocation mechanism of the system and design their own memory management programs. When the system is running, the module applies to the system for a memory buffer as a shared memory data area through the real-time operating system. After that, the initialization data in the historical database is transferred to the memory area to initialize these blank memories. For the application of memory space, users can use static allocation method, which is simple to realize and does not need complex index structure. The disadvantage is that the flexibility is lost, and the required memory must be known in advance and allocated at the design stage. Or dynamic allocation is adopted, which is flexible and can expand data nodes as needed, but an appropriate index structure must be established to speed up data retrieval time. The module should be designed according to the specific real-time operating system; (2) Data security and integrity control module. The design of real-time database must consider data security. On the one hand, it refers to the legitimacy of users accessing data, on the other hand, it refers to the security of the system. Integrity means that users' operations on real-time data or historical data must conform to certain semantics and can be realized through integrity constraints; (3) Transaction concurrency control module. Real-time database is a shared resource, which allows multiple tasks to be used together. If you don't control concurrent transactions, it may cause tasks to read or store data incorrectly and destroy the consistency of data. Therefore, a good concurrency control mechanism must be implemented in the real-time database system. Traditional databases generally adopt locking mode, which is similar to semaphores in real-time operating systems. The size of lock granularity should be determined according to the specific application system. The cost of acquiring locks in traditional databases is low, so lock units with small granularity are usually selected to increase the parallelism of the system. However, in the real-time database system, the cost of acquiring locks by transactions is equivalent to the cost of processing data, and too small blocking granularity will reduce the performance of the system. Therefore, the block granularity in real-time database usually chooses a relational table as the unit (such as simulating relational table as the block unit), which reduces the complexity of concurrency control mechanism, reduces system overhead and improves the overall performance of transaction processing. (4) Real-time data dump module. The function of this module is to store real-time data as historical data. Usually, the module first saves the historical data in the memory buffer, and then writes it to the disk once the buffer is full. When reading historical data, first get the data from the buffer, and then read and write files when the data is unavailable. This method can reduce the number of disk I/O operations. And only the changed data is stored, thus saving the external storage space and not affecting the system performance; (5) Run the log management module. Log file plays a very important role in database recovery, which can be used for transaction fault recovery and system fault recovery. The log buffer is dedicated to storing records of database operations. Traditional database log records include record name, old value recorded before updating, new value recorded after updating, transaction identification, operation type and so on. In the embedded real-time database system, in order to reduce the system overhead, the log record does not contain the old and new record values, and the log record is written only in the buffer. When the buffer is full, the log file is written through the disk write operation.