• 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 #ifdef STXXL_BOOST_CONFIG
00017  #include <boost/config.hpp>
00018 #endif
00019 
00020 #ifndef BOOST_MSVC
00021 // mmap call does not exist in Windows
00022 
00023 #include <cmath>
00024 #include <sys/mman.h>
00025 
00026 #include <stxxl/bits/io/ufs_file.h>
00027 
00028 
00029 __STXXL_BEGIN_NAMESPACE
00030 
00033 
00034  #define AVERAGE_SPEED (15 * 1024 * 1024)
00035 
00036 class DiskGeometry : private noncopyable
00037 {
00038     struct Zone
00039     {
00040         // manufactured data
00041         //    int last_cyl;
00042         //    int sect_per_track;
00043         // derived data
00044         int first_sector;
00045         int sectors;
00046         double sustained_data_rate;             // in Mb/s
00047         inline Zone(int _first_sector) : first_sector(_first_sector)
00048         { }                                     // constructor for zone search
00049 
00050         inline Zone(
00051             //int _last_cyl,
00052             //int _sect_per_track,
00053             int _first_sector,
00054             int _sectors, double _rate) :
00055             //last_cyl(_last_cyl),
00056             //sect_per_track(_sect_per_track) ,
00057             first_sector(_first_sector),
00058             sectors(_sectors),
00059             sustained_data_rate(_rate)
00060         { }
00061     };
00062     struct ZoneCmp
00063     {
00064         inline bool operator () (const Zone & a, const Zone & b) const
00065         {
00066             return a.first_sector < b.first_sector;
00067         }
00068     };
00069 
00070 protected:
00071     int nsurfaces;
00072     int bytes_per_sector;
00073     double cmd_ovh;                     // in s
00074     double seek_time;                   // in s
00075     double rot_latency;                 // in s
00076     double head_switch_time;            // in s
00077     double cyl_switch_time;             // in s
00078     double revolution_time;             // in s
00079     double interface_speed;             // in byte/s
00080     std::set<Zone, ZoneCmp> zones;
00081 
00082     void add_zone(int & first_cyl, int last_cyl,
00083                   int sec_per_track, int & first_sect);
00084 
00085 public:
00086     inline DiskGeometry()
00087     { }
00088     double get_delay(stxxl::int64 offset, size_t size);                // returns delay in s
00089 
00090     inline ~DiskGeometry()
00091     { }
00092 };
00093 
00094 
00095 class IC35L080AVVA07 : public DiskGeometry              // IBM series 120GXP
00096 {
00097 public:
00098     IC35L080AVVA07();
00099 };
00100 
00101 class sim_disk_request;
00102 
00105 class sim_disk_file : public ufs_file_base, public IC35L080AVVA07
00106 {
00107 public:
00113     inline sim_disk_file(const std::string & filename, int mode, int disk) : ufs_file_base(filename, mode, disk)
00114     {
00115         std::cout << "Please, make sure that '" << filename <<
00116         "' is resided on swap memory partition!" <<
00117         std::endl;
00118     }
00119     request_ptr aread(void * buffer, stxxl::int64 pos, size_t bytes,
00120                       completion_handler on_cmpl);
00121     request_ptr awrite(void * buffer, stxxl::int64 pos, size_t bytes,
00122                        completion_handler on_cmpl);
00123     void set_size(stxxl::int64 newsize);
00124 };
00125 
00126 
00128 class sim_disk_request : public ufs_request_base
00129 {
00130     friend class sim_disk_file;
00131 
00132 protected:
00133     inline sim_disk_request(sim_disk_file * f, void * buf, stxxl::int64 off,
00134                             size_t b, request_type t,
00135                             completion_handler on_cmpl) :
00136         ufs_request_base(f,
00137                          buf,
00138                          off,
00139                          b,
00140                          t,
00141                          on_cmpl)
00142     { }
00143     void serve();
00144 
00145 public:
00146     inline const char * io_type()
00147     {
00148         return "simdisk";
00149     }
00150 };
00151 
00153 
00154 __STXXL_END_NAMESPACE
00155 
00156 #endif // #ifndef BOOST_MSVC
00157 
00158 #endif // !STXXL_SIMDISK_FILE_HEADER

Generated by  doxygen 1.7.1