• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Classes
  • Files
  • Examples
  • File List

simdisk_file.h

00001 /***************************************************************************
00002  *  include/stxxl/bits/io/simdisk_file.h
00003  *
00004  *  Part of the STXXL. See http://stxxl.sourceforge.net
00005  *
00006  *  Copyright (C) 2002-2003 Roman Dementiev <[email protected]>
00007  *
00008  *  Distributed under the Boost Software License, Version 1.0.
00009  *  (See accompanying file LICENSE_1_0.txt or copy at
00010  *  http://www.boost.org/LICENSE_1_0.txt)
00011  **************************************************************************/
00012 
00013 #ifndef STXXL_SIMDISK_FILE_HEADER
00014 #define STXXL_SIMDISK_FILE_HEADER
00015 
00016 #ifndef STXXL_HAVE_SIMDISK_FILE
00017 #ifdef STXXL_BOOST_CONFIG
00018  #include <boost/config.hpp>
00019 #endif
00020 
00021 #ifndef BOOST_MSVC
00022 // mmap call does not exist in Windows
00023  #define STXXL_HAVE_SIMDISK_FILE 1
00024 #else
00025  #define STXXL_HAVE_SIMDISK_FILE 0
00026 #endif
00027 #endif
00028 
00029 #if STXXL_HAVE_SIMDISK_FILE
00030 
00031 #include <set>
00032 #include <cmath>
00033 #include <sys/mman.h>
00034 
00035 #include <stxxl/bits/io/ufs_file_base.h>
00036 #include <stxxl/bits/io/disk_queued_file.h>
00037 
00038 
00039 __STXXL_BEGIN_NAMESPACE
00040 
00043 
00044  #define AVERAGE_SPEED (15 * 1024 * 1024)
00045 
00046 class DiskGeometry : private noncopyable
00047 {
00048     struct Zone
00049     {
00050         // manufactured data
00051 #if 0
00052         int last_cyl;
00053         int sect_per_track;
00054 #endif
00055         // derived data
00056         int first_sector;
00057         int sectors;
00058         double sustained_data_rate;  // in MiB/s
00059         inline Zone(int _first_sector) : first_sector(_first_sector)
00060         { }                          // constructor for zone search
00061 
00062         inline Zone(
00063 #if 0
00064             int _last_cyl,
00065             int _sect_per_track,
00066 #endif
00067             int _first_sector,
00068             int _sectors,
00069             double _rate) :
00070 #if 0
00071             last_cyl(_last_cyl),
00072             sect_per_track(_sect_per_track),
00073 #endif
00074             first_sector(_first_sector),
00075             sectors(_sectors),
00076             sustained_data_rate(_rate)
00077         { }
00078     };
00079     struct ZoneCmp
00080     {
00081         inline bool operator () (const Zone & a, const Zone & b) const
00082         {
00083             return a.first_sector < b.first_sector;
00084         }
00085     };
00086 
00087 protected:
00088     int nsurfaces;
00089     int bytes_per_sector;
00090     double cmd_ovh;                     // in s
00091     double seek_time;                   // in s
00092     double rot_latency;                 // in s
00093     double head_switch_time;            // in s
00094     double cyl_switch_time;             // in s
00095     double revolution_time;             // in s
00096     double interface_speed;             // in byte/s
00097     std::set<Zone, ZoneCmp> zones;
00098 
00099     void add_zone(int & first_cyl, int last_cyl,
00100                   int sec_per_track, int & first_sect);
00101 
00102 public:
00103     inline DiskGeometry()
00104     { }
00105     double get_delay(file::offset_type offset, file::size_type size);                // returns delay in s
00106 
00107     inline ~DiskGeometry()
00108     { }
00109 };
00110 
00111 
00112 class IC35L080AVVA07 : public DiskGeometry              // IBM series 120GXP
00113 {
00114 public:
00115     IC35L080AVVA07();
00116 };
00117 
00120 class sim_disk_file : public ufs_file_base, public disk_queued_file, public IC35L080AVVA07
00121 {
00122 public:
00128     inline sim_disk_file(const std::string & filename, int mode, int queue_id = DEFAULT_QUEUE, int allocator_id = NO_ALLOCATOR) : ufs_file_base(filename, mode), disk_queued_file(queue_id, allocator_id)
00129     {
00130         std::cout << "Please, make sure that '" << filename <<
00131         "' is resided on swap memory partition!" <<
00132         std::endl;
00133     }
00134     void serve(const request * req) throw (io_error);
00135     void set_size(offset_type newsize);
00136     const char * io_type() const;
00137 };
00138 
00140 
00141 __STXXL_END_NAMESPACE
00142 
00143 #endif  // #if STXXL_HAVE_SIMDISK_FILE
00144 
00145 #endif  // !STXXL_SIMDISK_FILE_HEADER

Generated by  doxygen 1.7.1