STXXL  1.4.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
simdisk_file.h
Go to the documentation of this file.
1 /***************************************************************************
2  * include/stxxl/bits/io/simdisk_file.h
3  *
4  * Part of the STXXL. See http://stxxl.sourceforge.net
5  *
6  * Copyright (C) 2002-2003 Roman Dementiev <[email protected]>
7  * Copyright (C) 2008 Andreas Beckmann <[email protected]>
8  * Copyright (C) 2009 Johannes Singler <[email protected]>
9  *
10  * Distributed under the Boost Software License, Version 1.0.
11  * (See accompanying file LICENSE_1_0.txt or copy at
12  * http://www.boost.org/LICENSE_1_0.txt)
13  **************************************************************************/
14 
15 #ifndef STXXL_IO_SIMDISK_FILE_HEADER
16 #define STXXL_IO_SIMDISK_FILE_HEADER
17 
18 #include <stxxl/bits/config.h>
19 
20 #ifndef STXXL_HAVE_SIMDISK_FILE
21 // use mmap call
22 #define STXXL_HAVE_SIMDISK_FILE STXXL_HAVE_MMAP_FILE
23 #endif
24 
25 #if STXXL_HAVE_SIMDISK_FILE
26 
27 #include <set>
28 #include <cmath>
29 
32 
33 
35 
36 //! \weakgroup fileimpl
37 //! \{
38 
39  #define AVERAGE_SPEED (15 * 1024 * 1024)
40 
42 {
43  struct Zone
44  {
45  // manufactured data
46 #if 0
47  int last_cyl;
48  int sect_per_track;
49 #endif
50  // derived data
52  int sectors;
53  double sustained_data_rate; // in MiB/s
54  inline Zone(int _first_sector) : first_sector(_first_sector)
55  { } // constructor for zone search
56 
57  inline Zone(
58 #if 0
59  int _last_cyl,
60  int _sect_per_track,
61 #endif
62  int _first_sector,
63  int _sectors,
64  double _rate) :
65 #if 0
66  last_cyl(_last_cyl),
67  sect_per_track(_sect_per_track),
68 #endif
69  first_sector(_first_sector),
70  sectors(_sectors),
71  sustained_data_rate(_rate)
72  { }
73  };
74  struct ZoneCmp
75  {
76  inline bool operator () (const Zone& a, const Zone& b) const
77  {
78  return a.first_sector < b.first_sector;
79  }
80  };
81 
82 protected:
83  int nsurfaces;
85  double cmd_ovh; // in s
86  double seek_time; // in s
87  double rot_latency; // in s
88  double head_switch_time; // in s
89  double cyl_switch_time; // in s
90  double revolution_time; // in s
91  double interface_speed; // in byte/s
92  std::set<Zone, ZoneCmp> zones;
93 
94  void add_zone(int& first_cyl, int last_cyl,
95  int sec_per_track, int& first_sect);
96 
97 public:
99  { }
100  double get_delay(file::offset_type offset, file::size_type size); // returns delay in s
101 
103  { }
104 };
105 
106 
107 class IC35L080AVVA07 : public simdisk_geometry // IBM series 120GXP
108 {
109 public:
110  IC35L080AVVA07();
111 };
112 
113 //! Implementation of disk emulation.
114 //! \remark It is emulation of IBM IC35L080AVVA07 disk's timings
116 {
117 public:
118  //! Constructs file object.
119  //! \param filename path of file
120  //! \attention filename must be resided at memory disk partition
121  //! \param mode open mode, see \c stxxl::file::open_modes
122  //! \param queue_id disk queue identifier
123  //! \param allocator_id linked disk_allocator
124  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)
125  {
126  std::cout << "Please, make sure that '" << filename <<
127  "' is resided on swap memory partition!" <<
128  std::endl;
129  }
130  void serve(const request* req) throw (io_error);
131  void set_size(offset_type newsize);
132  const char * io_type() const;
133 };
134 
135 //! \}
136 
138 
139 #endif // #if STXXL_HAVE_SIMDISK_FILE
140 
141 #endif // !STXXL_IO_SIMDISK_FILE_HEADER
Zone(int _first_sector, int _sectors, double _rate)
Definition: simdisk_file.h:57
std::set< Zone, ZoneCmp > zones
Definition: simdisk_file.h:92
Implementation of disk emulation.
Definition: simdisk_file.h:115
request::size_type size_type
the size of a request
Definition: file.h:66
#define STXXL_BEGIN_NAMESPACE
Definition: namespace.h:16
Implementation of some file methods based on serving_request.
Zone(int _first_sector)
Definition: simdisk_file.h:54
sim_disk_file(const std::string &filename, int mode, int queue_id=DEFAULT_QUEUE, int allocator_id=NO_ALLOCATOR)
Constructs file object.
Definition: simdisk_file.h:124
Base for UNIX file system implementations.
Definition: ufs_file_base.h:34
request::offset_type offset_type
the offset of a request, also the size of the file
Definition: file.h:64
Request with basic properties like file and offset.
Definition: request.h:39
#define STXXL_END_NAMESPACE
Definition: namespace.h:17