Introduction to Real time database<br />Transaction It is said to be set of read or write operations<br />QueryA Transaction is said to be a query if it contains either a read or update operation<br /> Commit is a point of no return, once a transaction is commited we are certain that, the changes to the database are permanent<br /> <br />
Introduction to Real time database<br />ACID Properties of a General Purpose Databases<br />Atomicityn action is said to be atomic, if it either completely done or not at all.<br />ConsistencyA transaction transforms the database from one consistent state to another consistent state. A state is said to be a set of transactions.<br />IsolationUntil and unless a transaction is committed, the actions of it are not visible to any other transactions<br />DurabilityAfter commit, the changes made to the databases are permanent<br />Conventional Databases will follow the ACID properties and it never violates<br />
Real time vs general purpose database<br />The queries associated with a Real time databases are associated with a deadline, there may be some response after the queries passed the deadlines.<br />The data returned in response to a query must have absolute and relative consistency.<br />Absolute Vs Relative ConsistencyAbsolute consistency is accuracy. The data returned in response to a query must be close to the results expected. If temperature or pressure is interrogated in a chemical vessel, we want the data returned to be close to the current temperature or pressure.<br />Relative consistency means that for multiple data, the data must have been collected reasonably close to one another.<br />
Real time vs general purpose database<br />Need for Response Time predictability<br /><ul><li>The requirement to meet the ACID properties will entail a overhead.
Transactions may be aborted one or more times to avoid deadlock and to maintain serialization consistency. So transaction abortion leads to a delay.
Databases are often quite large to fit in the main memory and therefore rely mainly on the disk based systems. Page faults are the problem creators if the requested record is not in the main memory.
Transaction access are data dependent. The transaction to deduct an amount from a database which has lower balance is faster whereas the higher balance leads to slowness.
Transaction may suffer with a delay in accessing a data which is being locked by some other transactions.</li></li></ul><li>Real time vs general purpose database<br />General purpose databases always obey the ACID properties, but Real Time databases often relaxing the ACID properties or even sometime violates the ACID properties<br />
Real time vs general purpose database<br />In Machine tool Control System, the current tool position is not regarded as durable data and is discarded after it become outdated. In such an application, data durability is not worth maintaining if new measurements are frequently collected.<br />
Main memory databases<br />The entire database is residing on the main memory is the concept behind main memory databases. But there are some problems like data backups and storing logs. So Main memory databases are to rely on Disk based systems to store logs and backups.<br />Size<br />General purpose databases are really huge to sit in to the main memory and they just rely on disk based systems, but real time databases are small and even if it is moderate size, it still sits on the main memory because of speed and cheaper solution.<br />Logging<br />Main memory can be used to write log once a transaction commits. The entire log is huge to sit in the main memory, so it is necessary to store logs in the disks at batch mode or by transaction by transactions. In the former case (batch mode), the buffer store upto a volume of logs, then at a stretch it will store in the disks.<br />
Main memory database<br />Access to database<br />Pointers are used to access record or data in main memory Databases because of cheaper solutions and speed. If there are multiple copies of the same data available, then only one copy of the item is stored and have pointers to it (for accessing multiple copies).<br />Indexing scheme <br />in the disk systems are B trees and B+ Trees. In these mechanisms, the deeper levels are slowly indexed because of the disk accesses and other time consuming parameters. Hence Indexing scheme in Main memory databases uses T trees which are very faster even at the deeper level indexing<br />Failure<br />In disk based systems, if single disk unit fails, then the data on the other units are not affected and even sometimes RAID arrays are used in Disk systems to take multiple backups of same data. But if a main memory DB fails, then it should be powered down and the entire main memory restored.<br />
Transaction priorities<br />Transaction Priorities<br />Transactions are granted access to the processors based on their priorities.<br />All the transactions in the real time DB are associated with a deadline, hence Earliest Deadline First (EDF) algorithm finds a greater solution to schedule those transactions. But EDF algorithm will be working efficiently if the number of transactions are moderate. But usually the DB transactions are huge in a systems and EDF may not be suitable which leads to congestion.<br />To avoid the above solution an algorithm Adaptive Earliest Deadline (AED) algorithm which uses congestion control and also can process huge number of transactions. It uses two groups HIT and MISS group.<br />All the transactions in the HIT group will be meeting their deadlines, if by chance any transaction does not meets its deadline, then that transaction will be aborted.<br />
Transaction priorities<br />Operation of AED<br />When a transaction arrives, the system randomly inserts it in a list of pending transactions, if the assigned transaction is in the list 1…..H (H is any parameter), then it will be put in the HIT list else MISS group.<br />The objective is to try to meet all the deadlines of the HIT group and if any time left over, then the MISS group transaction may be executed.<br />Transactions within the HIT group are scheduled using EDF. If a transaction is completed, it will be removed from the list.<br />The transaction from one Group won’t move to other groups.<br />The H value can be set adaptively according to the following algorithms<br />
Transaction priorities<br />Success (HIT) = the ratio of Number of Transactions in HIT class that meet their deadlines to Total number of transactions in the HIT class.<br />Success (ALL) = the ratio of Number of Transactions that meet their deadlines to Total number of transactions.<br />The above parameters are measured repeatedly.<br />
Database for soft real time systems <br />Disk Based Scheduling<br />In disk based scheduling, the disks are located and traced by traversing the sectors and tracks. Tracks are concentric circles and sectors are just originating from the center of the disks.So, disk scheduling algorithms are slower when compared with the memory based scheduling. Under disk based schedulingTa=Tw+Tp+TtTa is the access timeTw is the time spent in queueTp is the time to position the arm to locate the sectors and trackTt is the time taken to transfer the block of data.Since Tp is in the order of few milliseconds, but CPU time is hardly around 50nano seconds, so disk based scheduling algorithms are not suitable for hard real time systems. However these algorithms, can be made useful for soft real time systems. Disk based scheduling will be useful for Soft Real time system based on the following algorithms<br />
Database for soft real time systems <br />First Come First Serve (FCFS)<br />The task or transaction which comes first will be scheduled and then the next, here the main problem is if the requests are huge then this algorithm is not suitable.<br />
Database for soft real time systems <br />Elevator or Scan policy<br />Scans in one direction and serves the requests, if not then comes to starting position and runs again from the beginning. <br />In the above diagram, the requests are dark lines and servings are given in dotted arrow lines. <br />In the first method, the order of servings will be 3,4,5,9,1,1,2 (as 3,4,5,9 are over, it comes back to its position and starts from 1 and 1 and then 2) the other method will be scans in one direction and serves the requests, if not reverse the direction and serves the request and comes to starting position and then starts for the next cycle . <br />In the second method the order of serving will be 3,4,5,9,2,1,1 (after 3,4,5 and9, the servings are reversing, so that 2,1,1)<br />In the third method allocation of priority to requests fix the schedule. But how to fix priority and who is responsible for allocating the priority is the issue.<br />