Real Time databases
Introduction to Real time databaseTransaction It is said to be set of read or write operationsQueryA Transaction is said to be a query if it contains either a read or update operation Commit is a point of no return, once a transaction is commited we are certain that, the changes to the database are permanent 
Introduction to Real time databaseACID Properties of a General Purpose DatabasesAtomicityn action is said to be atomic, if it either completely done or not at all.ConsistencyA transaction transforms the database from one consistent state to another consistent state. A state is said to be a set of transactions.IsolationUntil and unless a transaction is committed, the actions of it are not visible to any other transactionsDurabilityAfter commit, the changes made to the databases are permanentConventional Databases will follow the ACID properties and it never violates
Real time vs general purpose databaseThe queries associated with a Real time databases are associated with a deadline, there may be some response after the queries passed the deadlines.The data returned in response to a query must have absolute and relative consistency.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.Relative consistency means that for multiple data, the data must have been collected reasonably close to one another.
Real time vs general purpose databaseNeed for Response Time predictabilityThe 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.Real time vs general purpose databaseGeneral purpose databases always obey the ACID properties, but Real Time databases often relaxing the ACID properties or even sometime violates the ACID properties
Real time vs general purpose databaseIn 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.
Main memory databasesThe 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.SizeGeneral 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.LoggingMain 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.
Main memory databaseAccess to databasePointers 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).Indexing scheme 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 indexingFailureIn 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.
Transaction prioritiesTransaction PrioritiesTransactions are granted access to the processors based on their priorities.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.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.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.
Transaction prioritiesOperation of AEDWhen 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.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.Transactions within the HIT group are scheduled using EDF. If a transaction is completed, it will be removed from the list.The transaction from one Group won’t move to other groups.The H value can be set adaptively according to the following algorithms
Transaction prioritiesSuccess (HIT) = the ratio of Number of Transactions in HIT class that meet their deadlines to Total number of transactions in the HIT class.Success (ALL) = the ratio of Number of Transactions that meet their deadlines to Total number of transactions.The above parameters are measured repeatedly.
Database for soft real time systems	Disk Based SchedulingIn 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

Rt databases vs general purpose tsp

  • 1.
  • 2.
    Introduction to Realtime databaseTransaction It is said to be set of read or write operationsQueryA Transaction is said to be a query if it contains either a read or update operation Commit is a point of no return, once a transaction is commited we are certain that, the changes to the database are permanent 
  • 3.
    Introduction to Realtime databaseACID Properties of a General Purpose DatabasesAtomicityn action is said to be atomic, if it either completely done or not at all.ConsistencyA transaction transforms the database from one consistent state to another consistent state. A state is said to be a set of transactions.IsolationUntil and unless a transaction is committed, the actions of it are not visible to any other transactionsDurabilityAfter commit, the changes made to the databases are permanentConventional Databases will follow the ACID properties and it never violates
  • 4.
    Real time vsgeneral purpose databaseThe queries associated with a Real time databases are associated with a deadline, there may be some response after the queries passed the deadlines.The data returned in response to a query must have absolute and relative consistency.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.Relative consistency means that for multiple data, the data must have been collected reasonably close to one another.
  • 5.
    Real time vsgeneral purpose databaseNeed for Response Time predictabilityThe requirement to meet the ACID properties will entail a overhead.
  • 6.
    Transactions may beaborted one or more times to avoid deadlock and to maintain serialization consistency. So transaction abortion leads to a delay.
  • 7.
    Databases are oftenquite 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.
  • 8.
    Transaction access aredata dependent. The transaction to deduct an amount from a database which has lower balance is faster whereas the higher balance leads to slowness.
  • 9.
    Transaction may sufferwith a delay in accessing a data which is being locked by some other transactions.Real time vs general purpose databaseGeneral purpose databases always obey the ACID properties, but Real Time databases often relaxing the ACID properties or even sometime violates the ACID properties
  • 10.
    Real time vsgeneral purpose databaseIn 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.
  • 11.
    Main memory databasesTheentire 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.SizeGeneral 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.LoggingMain 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.
  • 12.
    Main memory databaseAccessto databasePointers 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).Indexing scheme 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 indexingFailureIn 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.
  • 13.
    Transaction prioritiesTransaction PrioritiesTransactionsare granted access to the processors based on their priorities.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.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.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.
  • 14.
    Transaction prioritiesOperation ofAEDWhen 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.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.Transactions within the HIT group are scheduled using EDF. If a transaction is completed, it will be removed from the list.The transaction from one Group won’t move to other groups.The H value can be set adaptively according to the following algorithms
  • 15.
    Transaction prioritiesSuccess (HIT)= the ratio of Number of Transactions in HIT class that meet their deadlines to Total number of transactions in the HIT class.Success (ALL) = the ratio of Number of Transactions that meet their deadlines to Total number of transactions.The above parameters are measured repeatedly.
  • 16.
    Database for softreal time systems Disk Based SchedulingIn 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
  • 17.
    Database for softreal time systems First Come First Serve (FCFS)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.
  • 18.
    Database for softreal time systems
  • 19.
    Database for softreal time systems Elevator or Scan policyScans in one direction and serves the requests, if not then comes to starting position and runs again from the beginning. In the above diagram, the requests are dark lines and servings are given in dotted arrow lines. 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 . 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)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.