?? dm_testsuite.c
字號:
/* diskmodel (version 1.0) * Authors: John Bucy, Greg Ganger * Contributors: John Griffin, Jiri Schindler, Steve Schlosser * * Copyright (c) of Carnegie Mellon University, 2001-2008. * * This software is being provided by the copyright holders under the * following license. By obtaining, using and/or copying this * software, you agree that you have read, understood, and will comply * with the following terms and conditions: * * Permission to reproduce, use, and prepare derivative works of this * software is granted provided the copyright and "No Warranty" * statements are included with all reproductions and derivative works * and associated documentation. This software may also be * redistributed without charge provided that the copyright and "No * Warranty" statements are included in all redistributions. * * NO WARRANTY. THIS SOFTWARE IS FURNISHED ON AN "AS IS" BASIS. * CARNEGIE MELLON UNIVERSITY MAKES NO WARRANTIES OF ANY KIND, EITHER * EXPRESSED OR IMPLIED AS TO THE MATTER INCLUDING, BUT NOT LIMITED * TO: WARRANTY OF FITNESS FOR PURPOSE OR MERCHANTABILITY, EXCLUSIVITY * OF RESULTS OR RESULTS OBTAINED FROM USE OF THIS SOFTWARE. CARNEGIE * MELLON UNIVERSITY DOES NOT MAKE ANY WARRANTY OF ANY KIND WITH * RESPECT TO FREEDOM FROM PATENT, TRADEMARK, OR COPYRIGHT * INFRINGEMENT. COPYRIGHT HOLDERS WILL BEAR NO LIABILITY FOR ANY USE * OF THIS SOFTWARE OR DOCUMENTATION. */#include "dm.h"#include "modules/modules.h"#include <libparam/libparam.h>#include <libddbg/libddbg.h>#include <stdio.h>// translate the lbn space forwards and backwardsvoid layout_test_simple(struct dm_disk_if *d) { int c, lbn, count = 0, runlbn = 0; struct dm_pbn pbn, trkpbn = {0,0,0}; printf("got a dm_disk with %d sectors!\n", d->dm_sectors); for(c = 0; c < d->dm_sectors; c ++) { int lbn2; dm_angle_t skew, zerol; struct dm_mech_state track; d->layout->dm_translate_ltop(d, c, MAP_FULL, &pbn, 0); lbn2 = d->layout->dm_translate_ptol(d, &pbn, 0); if(c != lbn2) { printf("*** test_0_t: %8d -> (%8d, %3d, %4d) -> %8d\n", c, pbn.cyl, pbn.head, pbn.sector, lbn2); } else { if((lbn > 0) && (trkpbn.head == pbn.head) && (trkpbn.cyl == pbn.cyl) && ((trkpbn.sector+count) == pbn.sector)) { count++; } else { printf("l %d %d %d %d %d\n", runlbn, trkpbn.cyl, trkpbn.head, trkpbn.sector, count); runlbn = c; trkpbn = pbn; count = 1; } } }}void test_rotate(struct dm_disk_if *d) { double t; dm_angle_t a; dm_time_t t2; for(t = 0.0; t < 20.0; t += 0.1) { t2 = dm_time_dtoi(t); a = d->mech->dm_rotate(d, &t2); printf("time %f, angle %f\n", t, dm_angle_itod(a)); } }void layout_test_skew(struct dm_disk_if *d) { int c; dm_angle_t skew; double angle; struct dm_pbn pbn; for(c = 6281; c <= 6704; c++) { pbn.cyl = c; pbn.head = 3; pbn.sector = 250; d->layout->dm_convert_ptoa(d, &pbn, &skew, 0); angle = dm_angle_itod(skew); printf("ptoa (%d,%d,%d): %f, %u\n", pbn.cyl, pbn.head, pbn.sector, angle, skew); } for(c = 0; c < 1000000000; c += 10000000) { struct dm_mech_state a; a.head = 3; a.cyl = 0; a.theta = c; d->layout->dm_convert_atop(d, &a, &pbn); printf("atop (%d,%d,%d) -> (%d,%d,%d)\n", a.head, a.cyl, a.theta, pbn.head, pbn.cyl, pbn.sector); }}// single-cyl switchvoid mech_test_postime1(struct dm_disk_if *d) { struct dm_mech_state begin, end; dm_time_t result; double time; int c; begin.head = 0; begin.cyl = 0; begin.theta = 0; end.head = 0; end.theta = 0; for(c = 0; c < 1000; c++) { end.cyl = c; result = d->mech->dm_seek_time(d, &begin, &end, 0); time = dm_time_itod(result); printf("cyl switch %d: %lld, %e\n", c, result, time); }}// single-head switchvoid mech_test_postime2(struct dm_disk_if *d) { struct dm_mech_state begin, end; dm_time_t result; double time; begin.head = 0; begin.cyl = 0; begin.theta = 0; end.head = 1; end.cyl = 0; end.theta = 0; result = d->mech->dm_seek_time(d, &begin, &end, 0); time = dm_time_itod(result); printf("single-head switch: %lld, %e\n", result, time);}void mech_test_xfertime(struct dm_disk_if *d) { int sectors; struct dm_mech_state m; dm_time_t xfertime; double time; m.head = 0; m.cyl = 0; m.theta = 0; // how long to transfer half a track? sectors = d->layout->dm_get_sectors_lbn(d, 0); sectors >>= 1; xfertime = d->mech->dm_xfertime(d, &m, sectors); time = dm_time_itod(xfertime); printf("half-track xfer: %lld, %e\n", xfertime, time);}void mech_test_access(struct dm_disk_if *d) { // very basic access int sectors; struct dm_mech_state m; dm_time_t result; struct dm_pbn startpbn; double time; m.head = 0; m.cyl = 0; m.theta = 0; // how long to transfer half a track? sectors = d->layout->dm_get_sectors_lbn(d, 0); sectors /= 2; startpbn.head = 0; startpbn.cyl = 0; startpbn.sector = 0; // result = d->mech->dm_acctime(d, &m, &startpbn, sectors, 0, 0, 0, 0); time = dm_time_itod(result); printf("half-track access: %lld, %e\n", result, time);}void mech_pos_vs_acc(struct dm_disk_if *d) { // very basic access int sectors; struct dm_mech_state m; dm_time_t postime, acctime; struct dm_pbn startpbn; double time; struct dm_mech_acctimes bacc, bpos; m.head = 0; m.cyl = 0; m.theta = 0; // how long to transfer half a track? sectors = d->layout->dm_get_sectors_lbn(d, 0); sectors /= 2; d->layout->dm_translate_ltop(d, 8955874, MAP_FULL, &startpbn, 0); sectors = 1; bzero(&bacc, sizeof(bacc)); bzero(&bpos, sizeof(bpos)); acctime = d->mech->dm_acctime(d, &m, &startpbn, sectors, 0, 0, 0, &bacc); postime = d->mech->dm_pos_time(d, &m, &startpbn, sectors, 0, 0, &bpos); printf("half-track pos: %lld, acc: %lld\n", postime, acctime);}void mech_test_access2(struct dm_disk_if *d) { // half a rotation, read the rest of the track int sectors; struct dm_mech_state m; dm_time_t result; struct dm_pbn startpbn; double time; m.head = 0; m.cyl = 0; m.theta = 4282107939; sectors = d->layout->dm_get_sectors_lbn(d, 0); sectors >>= 1; startpbn.head = 1; startpbn.cyl = 0; startpbn.sector = 0; result = d->mech->dm_acctime(d, &m, &startpbn, sectors, 0, 0, 0, 0); time = dm_time_itod(result); printf("access2 (track switch): %lld, %e\n", result, time);}void mech_test_access3(struct dm_disk_if *d) { // half a rotation, read the rest of the track int sectors; struct dm_mech_state m; dm_time_t result; struct dm_pbn startpbn; double time; m.head = 0; m.cyl = 0; m.theta = 0; sectors = d->layout->dm_get_sectors_lbn(d, 0); sectors >>= 1; startpbn.head = 0; startpbn.cyl = 1; startpbn.sector = 0; result = d->mech->dm_acctime(d, &m, &startpbn, sectors, 0, 0, 0, 0); time = dm_time_itod(result); printf("access3 (cyl switch): %lld, %e\n", result, time);}void mech_test_access_big(struct dm_disk_if *d) { // half a rotation, read the rest of the track int c,h; int sectors; struct dm_mech_state m = {0,0,0}, tempm, resultstate = {0,0,0}; dm_time_t result; struct dm_pbn startpbn; double time; int tracks, lbn = 0; // tracks = d->dm_cyls * d->dm_surfaces; tracks = 10 * d->dm_surfaces; for(c = 0; c < tracks; c++) { sectors = d->layout->dm_get_sectors_lbn(d, c); lbn = c * sectors; d->layout->dm_translate_ltop(d, lbn, MAP_FULL, &startpbn, 0); result = d->mech->dm_acctime(d, &m, &startpbn, 1, // len 1, // read? 0, // zero-latency?
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -