Advanced Programming in the UNIX® Environment

(lily) #1
ptg10805159

750 ADatabase Library Chapter 20


located with only two disk accesses (see Litwin[ 1980 ]or Fagin et al.[ 1979 ]for details).
B-trees have the advantage of traversing the database in (sorted) key order (something
that we can’t do with thedb_nextrecfunction using a hash table.)

20.5 Centralized or Decentralized?


Given multiple processes accessing the same database, we can implement the functions
in two ways:


  1. Centralized. Have a single process that is the database manager,and have it be
    the only process that accesses the database. The functions contact this central
    process using some form of IPC.

  2. Decentralized. Have each function apply the required concurrency controls
    (locking) and then issue its own I/O function calls.
    Database systems have been built using each of these techniques. Given adequate
    locking routines, the decentralized implementation is usually faster,because IPC is
    avoided. Figure20.4 depicts the operation of the centralized approach.


IPC I/O kernel

index file data file

db access
library

user process

db access
library

user process
centralized
db manager

user process

Figure 20.4Centralized approach for database access
Free download pdf