16
REAL TIME DATABASES

Rt databases vs general purpose tsp

Embed Size (px)

Citation preview

Page 1: Rt databases vs general purpose  tsp

REAL TIME DATABASES

Page 2: Rt databases vs general purpose  tsp

INTRODUCTION TO REAL TIME DATABASE• Transaction 

It is said to be set of read or write operations

• QueryA 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

Page 3: Rt databases vs general purpose  tsp

INTRODUCTION TO REAL TIME DATABASE• ACID Properties of a General Purpose Databases

• Atomicityn 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 transactions

• DurabilityAfter commit, the changes made to the databases are permanent

• Conventional Databases will follow the ACID properties and it never violates

Page 4: Rt databases vs general purpose  tsp

REAL TIME VS GENERAL PURPOSE DATABASE• The 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.

Page 5: Rt databases vs general purpose  tsp

REAL TIME VS GENERAL PURPOSE DATABASE• Need for Response Time predictability

• 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.

Page 6: Rt databases vs general purpose  tsp

REAL TIME VS GENERAL PURPOSE DATABASE• General purpose databases always obey the ACID properties, but Real Time databases

often relaxing the ACID properties or even sometime violates the ACID properties

Page 7: Rt databases vs general purpose  tsp

REAL TIME VS GENERAL PURPOSE DATABASE

• 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.

Page 8: Rt databases vs general purpose  tsp

MAIN MEMORY DATABASES• 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.

Size

• 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.

Logging

• 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.

Page 9: Rt databases vs general purpose  tsp

MAIN MEMORY DATABASEAccess to database

• 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).

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 indexing

Failure

• 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.

Page 10: Rt databases vs general purpose  tsp

TRANSACTION PRIORITIES• Transaction Priorities

• Transactions 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.

Page 11: Rt databases vs general purpose  tsp

TRANSACTION PRIORITIES• Operation of AED

• 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.

• 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

Page 12: Rt databases vs general purpose  tsp

TRANSACTION PRIORITIES

• Success (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.

Page 13: Rt databases vs general purpose  tsp

DATABASE FOR SOFT REAL TIME SYSTEMS• Disk Based Scheduling

• 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

Page 14: Rt databases vs general purpose  tsp

DATABASE FOR SOFT REAL 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.

Page 15: Rt databases vs general purpose  tsp

DATABASE FOR SOFT REAL TIME SYSTEMS

Page 16: Rt databases vs general purpose  tsp

DATABASE FOR SOFT REAL TIME SYSTEMSElevator or Scan policy

• Scans 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.