STXXL  1.4-dev
 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 
34 
35 //! \weakgroup fileimpl
36 //! \{
37 
39 {
40  struct Zone
41  {
42  // manufactured data
43 #if 0
44  int last_cyl;
45  int sect_per_track;
46 #endif
47  // derived data
49  int sectors;
50  double sustained_data_rate; // in MiB/s
51  inline Zone(int _first_sector) : first_sector(_first_sector)
52  { } // constructor for zone search
53 
54  inline Zone(
55 #if 0
56  int _last_cyl,
57  int _sect_per_track,
58 #endif
59  int _first_sector,
60  int _sectors,
61  double _rate)
62  :
63 #if 0
64  last_cyl(_last_cyl),
65  sect_per_track(_sect_per_track),
66 #endif
67  first_sector(_first_sector),
68  sectors(_sectors),
69  sustained_data_rate(_rate)
70  { }
71  };
72  struct ZoneCmp
73  {
74  inline bool operator () (const Zone& a, const Zone& b) const
75  {
76  return a.first_sector < b.first_sector;
77  }
78  };
79 
80 protected:
81  int nsurfaces;
83  double cmd_ovh; // in s
84  double seek_time; // in s
85  double rot_latency; // in s
86  double head_switch_time; // in s
87  double cyl_switch_time; // in s
88  double revolution_time; // in s
89  double interface_speed; // in byte/s
90  std::set<Zone, ZoneCmp> zones;
91 
92  void add_zone(int& first_cyl, int last_cyl,
93  int sec_per_track, int& first_sect);
94 
95 public:
97  { }
98  double get_delay(file::offset_type offset, file::size_type size); // returns delay in s
99 
101  { }
102 
103  static const double s_average_speed;
104 };
105 
106 class IC35L080AVVA07 : public simdisk_geometry // IBM series 120GXP
107 {
108 public:
109  IC35L080AVVA07();
110 };
111 
112 //! Implementation of disk emulation.
113 //! \remark It is emulation of IBM IC35L080AVVA07 disk's timings
115 {
116 public:
117  //! Constructs file object.
118  //! \param filename path of file
119  //! \attention filename must be resided at memory disk partition
120  //! \param mode open mode, see \c stxxl::file::open_modes
121  //! \param queue_id disk queue identifier
122  //! \param allocator_id linked disk_allocator
123  //! \param device_id physical device identifier
125  const std::string& filename,
126  int mode,
127  int queue_id = DEFAULT_QUEUE,
128  int allocator_id = NO_ALLOCATOR,
129  unsigned int device_id = DEFAULT_DEVICE_ID)
130  : file(device_id),
131  ufs_file_base(filename, mode),
132  disk_queued_file(queue_id, allocator_id)
133  {
134  std::cout << "Please, make sure that '" << filename <<
135  "' is resided on swap memory partition!" <<
136  std::endl;
137  }
138  void serve(void* buffer, offset_type offset, size_type bytes,
139  request::request_type type);
140  void set_size(offset_type newsize);
141  const char * io_type() const;
142 };
143 
144 //! \}
145 
147 
148 #endif // #if STXXL_HAVE_SIMDISK_FILE
149 
150 #endif // !STXXL_IO_SIMDISK_FILE_HEADER
Zone(int _first_sector, int _sectors, double _rate)
Definition: simdisk_file.h:54
sim_disk_file(const std::string &filename, int mode, int queue_id=DEFAULT_QUEUE, int allocator_id=NO_ALLOCATOR, unsigned int device_id=DEFAULT_DEVICE_ID)
Constructs file object.
Definition: simdisk_file.h:124
std::set< Zone, ZoneCmp > zones
Definition: simdisk_file.h:90
Implementation of disk emulation.
Definition: simdisk_file.h:114
request::size_type size_type
the size of a request
Definition: file.h:62
Defines interface of file.
Definition: file.h:56
#define STXXL_BEGIN_NAMESPACE
Definition: namespace.h:16
Implementation of some file methods based on serving_request.
static const double s_average_speed
Definition: simdisk_file.h:103
Zone(int _first_sector)
Definition: simdisk_file.h:51
static const size_t bytes
number of bytes in uint_pair
Definition: uint_types.h:96
Base for UNIX file system implementations.
Definition: ufs_file_base.h:33
request::offset_type offset_type
the offset of a request, also the size of the file
Definition: file.h:60
#define STXXL_END_NAMESPACE
Definition: namespace.h:17