亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? disk.cc

?? 基于nachos模擬器的源代碼
?? CC
字號:
// disk.cc //	Routines to simulate a physical disk device; reading and writing//	to the disk is simulated as reading and writing to a UNIX file.//	See disk.h for details about the behavior of disks (and//	therefore about the behavior of this simulation).////	Disk operations are asynchronous, so we have to invoke an interrupt//	handler when the simulated operation completes.////  DO NOT CHANGE -- part of the machine emulation//// Copyright (c) 1992-1993 The Regents of the University of California.// All rights reserved.  See copyright.h for copyright notice and limitation // of liability and disclaimer of warranty provisions.#include "copyright.h"#include "disk.h"#include "system.h"// We put this at the front of the UNIX file representing the// disk, to make it less likely we will accidentally treat a useful file // as a disk (which would probably trash the file's contents).#define MagicNumber 	0x456789ab#define MagicSize 	sizeof(int)#define DiskSize 	(MagicSize + (NumSectors * SectorSize))// dummy procedure because we can't take a pointer of a member functionstatic void DiskDone(int arg) { ((Disk *)arg)->HandleInterrupt(); }//----------------------------------------------------------------------// Disk::Disk()// 	Initialize a simulated disk.  Open the UNIX file (creating it//	if it doesn't exist), and check the magic number to make sure it's // 	ok to treat it as Nachos disk storage.////	"name" -- text name of the file simulating the Nachos disk//	"callWhenDone" -- interrupt handler to be called when disk read/write//	   request completes//	"callArg" -- argument to pass the interrupt handler//----------------------------------------------------------------------Disk::Disk(char* name, VoidFunctionPtr callWhenDone, int callArg){    int magicNum;    int tmp = 0;    DEBUG('d', "Initializing the disk, 0x%x 0x%x\n", callWhenDone, callArg);    handler = callWhenDone;    handlerArg = callArg;    lastSector = 0;    bufferInit = 0;        fileno = OpenForReadWrite(name, FALSE);    if (fileno >= 0) {		 	// file exists, check magic number 	Read(fileno, (char *) &magicNum, MagicSize);	ASSERT(magicNum == MagicNumber);    } else {				// file doesn't exist, create it        fileno = OpenForWrite(name);	magicNum = MagicNumber;  	WriteFile(fileno, (char *) &magicNum, MagicSize); // write magic number	// need to write at end of file, so that reads will not return EOF        Lseek(fileno, DiskSize - sizeof(int), 0);		WriteFile(fileno, (char *)&tmp, sizeof(int));      }    active = FALSE;}//----------------------------------------------------------------------// Disk::~Disk()// 	Clean up disk simulation, by closing the UNIX file representing the//	disk.//----------------------------------------------------------------------Disk::~Disk(){    Close(fileno);}//----------------------------------------------------------------------// Disk::PrintSector()// 	Dump the data in a disk read/write request, for debugging.//----------------------------------------------------------------------static voidPrintSector (bool writing, int sector, char *data){    int *p = (int *) data;    if (writing)        printf("Writing sector: %d\n", sector);     else        printf("Reading sector: %d\n", sector);     for (unsigned int i = 0; i < (SectorSize/sizeof(int)); i++)	printf("%x ", p[i]);    printf("\n"); }//----------------------------------------------------------------------// Disk::ReadRequest/WriteRequest// 	Simulate a request to read/write a single disk sector//	   Do the read/write immediately to the UNIX file//	   Set up an interrupt handler to be called later,//	      that will notify the caller when the simulator says//	      the operation has completed.////	Note that a disk only allows an entire sector to be read/written,//	not part of a sector.////	"sectorNumber" -- the disk sector to read/write//	"data" -- the bytes to be written, the buffer to hold the incoming bytes//----------------------------------------------------------------------voidDisk::ReadRequest(int sectorNumber, char* data){    int ticks = ComputeLatency(sectorNumber, FALSE);    ASSERT(!active);				// only one request at a time    ASSERT((sectorNumber >= 0) && (sectorNumber < NumSectors));        DEBUG('d', "Reading from sector %d\n", sectorNumber);    Lseek(fileno, SectorSize * sectorNumber + MagicSize, 0);    Read(fileno, data, SectorSize);    if (DebugIsEnabled('d'))	PrintSector(FALSE, sectorNumber, data);        active = TRUE;    UpdateLast(sectorNumber);    stats->numDiskReads++;    interrupt->Schedule(DiskDone, (int) this, ticks, DiskInt);}voidDisk::WriteRequest(int sectorNumber, char* data){    int ticks = ComputeLatency(sectorNumber, TRUE);    ASSERT(!active);    ASSERT((sectorNumber >= 0) && (sectorNumber < NumSectors));        DEBUG('d', "Writing to sector %d\n", sectorNumber);    Lseek(fileno, SectorSize * sectorNumber + MagicSize, 0);    WriteFile(fileno, data, SectorSize);    if (DebugIsEnabled('d'))	PrintSector(TRUE, sectorNumber, data);        active = TRUE;    UpdateLast(sectorNumber);    stats->numDiskWrites++;    interrupt->Schedule(DiskDone, (int) this, ticks, DiskInt);}//----------------------------------------------------------------------// Disk::HandleInterrupt()// 	Called when it is time to invoke the disk interrupt handler,//	to tell the Nachos kernel that the disk request is done.//----------------------------------------------------------------------voidDisk::HandleInterrupt (){     active = FALSE;    (*handler)(handlerArg);}//----------------------------------------------------------------------// Disk::TimeToSeek()//	Returns how long it will take to position the disk head over the correct//	track on the disk.  Since when we finish seeking, we are likely//	to be in the middle of a sector that is rotating past the head,//	we also return how long until the head is at the next sector boundary.//	//   	Disk seeks at one track per SeekTime ticks (cf. stats.h)//   	and rotates at one sector per RotationTime ticks//----------------------------------------------------------------------intDisk::TimeToSeek(int newSector, int *rotation) {    int newTrack = newSector / SectorsPerTrack;    int oldTrack = lastSector / SectorsPerTrack;    int seek = abs(newTrack - oldTrack) * SeekTime;				// how long will seek take?    int over = (stats->totalTicks + seek) % RotationTime; 				// will we be in the middle of a sector when				// we finish the seek?    *rotation = 0;    if (over > 0)	 	// if so, need to round up to next full sector   	*rotation = RotationTime - over;    return seek;}//----------------------------------------------------------------------// Disk::ModuloDiff()// 	Return number of sectors of rotational delay between target sector//	"to" and current sector position "from"//----------------------------------------------------------------------int Disk::ModuloDiff(int to, int from){    int toOffset = to % SectorsPerTrack;    int fromOffset = from % SectorsPerTrack;    return ((toOffset - fromOffset) + SectorsPerTrack) % SectorsPerTrack;}//----------------------------------------------------------------------// Disk::ComputeLatency()// 	Return how long will it take to read/write a disk sector, from//	the current position of the disk head.////   	Latency = seek time + rotational latency + transfer time//   	Disk seeks at one track per SeekTime ticks (cf. stats.h)//   	and rotates at one sector per RotationTime ticks////   	To find the rotational latency, we first must figure out where the //   	disk head will be after the seek (if any).  We then figure out//   	how long it will take to rotate completely past newSector after //	that point.////   	The disk also has a "track buffer"; the disk continuously reads//   	the contents of the current disk track into the buffer.  This allows //   	read requests to the current track to be satisfied more quickly.//   	The contents of the track buffer are discarded after every seek to //   	a new track.//----------------------------------------------------------------------intDisk::ComputeLatency(int newSector, bool writing){    int rotation;    int seek = TimeToSeek(newSector, &rotation);    int timeAfter = stats->totalTicks + seek + rotation;#ifndef NOTRACKBUF	// turn this on if you don't want the track buffer stuff    // check if track buffer applies    if ((writing == FALSE) && (seek == 0) 		&& (((timeAfter - bufferInit) / RotationTime) 	     		> ModuloDiff(newSector, bufferInit / RotationTime))) {        DEBUG('d', "Request latency = %d\n", RotationTime);	return RotationTime; // time to transfer sector from the track buffer    }#endif    rotation += ModuloDiff(newSector, timeAfter / RotationTime) * RotationTime;    DEBUG('d', "Request latency = %d\n", seek + rotation + RotationTime);    return(seek + rotation + RotationTime);}//----------------------------------------------------------------------// Disk::UpdateLast//   	Keep track of the most recently requested sector.  So we can know//	what is in the track buffer.//----------------------------------------------------------------------voidDisk::UpdateLast(int newSector){    int rotate;    int seek = TimeToSeek(newSector, &rotate);        if (seek != 0)	bufferInit = stats->totalTicks + seek + rotate;    lastSector = newSector;    DEBUG('d', "Updating last sector = %d, %d\n", lastSector, bufferInit);}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩免费福利电影在线观看| 狠狠色丁香婷婷综合| 精品国产乱码久久久久久浪潮| 精品视频在线免费看| 欧美影院精品一区| 欧美剧在线免费观看网站| 欧洲激情一区二区| 这里只有精品视频在线观看| 欧美日韩国产精品自在自线| 欧美三级日韩三级国产三级| 91精品国产综合久久精品性色| 91精品国产综合久久久久久久| 欧美丰满高潮xxxx喷水动漫| 日韩三级精品电影久久久| 精品国产一区二区三区久久影院 | 日韩美女视频一区二区在线观看| 欧美日韩国产成人在线91| 欧美一区二区三区日韩| 精品国产sm最大网站免费看| 国产日韩欧美综合在线| 亚洲黄网站在线观看| 毛片一区二区三区| 91成人在线观看喷潮| 欧美成人欧美edvon| 一区二区在线观看不卡| 国产精品一线二线三线| 欧美在线一区二区| 欧美极品美女视频| 毛片av中文字幕一区二区| 色吧成人激情小说| 国产精品久久看| 国产专区欧美精品| 精品国产亚洲在线| 天天爽夜夜爽夜夜爽精品视频| av亚洲精华国产精华| 精品国产乱码久久久久久久| 丝袜美腿高跟呻吟高潮一区| 色婷婷国产精品综合在线观看| 国产亚洲短视频| 国模大尺度一区二区三区| 6080国产精品一区二区| 一级精品视频在线观看宜春院| 国产一区二区三区免费播放| 日韩欧美在线123| 蜜臀av性久久久久蜜臀aⅴ流畅 | 亚洲欧美在线另类| 成人免费高清在线| 亚洲欧美国产高清| 日本精品视频一区二区| 亚洲精品国产a| 欧美午夜精品电影| 免费一级片91| 欧美激情一区二区三区在线| 粉嫩久久99精品久久久久久夜| 国产午夜精品在线观看| 91小视频在线免费看| 午夜在线电影亚洲一区| 日韩一区二区三区精品视频| 国产精品自拍网站| 一区二区三区日韩欧美精品| 91精品午夜视频| 成人一级视频在线观看| 亚洲国产wwwccc36天堂| 精品日韩一区二区三区免费视频| 国产精品99久久久久久有的能看| 国产精品久久三区| 欧美一区二区久久| 97se亚洲国产综合自在线观| 视频一区国产视频| 国产精品伦一区二区三级视频| 欧美日韩夫妻久久| 99国产精品国产精品毛片| 日本伊人午夜精品| 亚洲黄色av一区| 国产视频一区二区三区在线观看| 欧美日韩一区二区在线观看视频| 国产美女视频91| 久久se这里有精品| 三级欧美在线一区| 亚洲国产精品一区二区久久| 国产欧美日韩在线视频| 欧美不卡一二三| 日韩亚洲欧美一区二区三区| 欧美性猛片aaaaaaa做受| 91网站最新网址| 国产成人一区二区精品非洲| 精品在线亚洲视频| 久久99精品久久久久| 免费欧美在线视频| 久久国产日韩欧美精品| 日韩av一区二区在线影视| 亚洲综合精品自拍| 亚洲一二三区视频在线观看| 亚洲视频网在线直播| 日韩码欧中文字| 国产精品亲子乱子伦xxxx裸| 国产精品高潮呻吟久久| 中文字幕中文乱码欧美一区二区| 中文字幕在线不卡一区二区三区| 国产欧美日韩视频一区二区| 国产精品国产三级国产| 欧美激情一区二区三区| 亚洲精品乱码久久久久久久久 | 国产大陆精品国产| av成人免费在线观看| av中文字幕亚洲| 欧美中文字幕亚洲一区二区va在线| 欧美中文字幕一区| 久久众筹精品私拍模特| 最近中文字幕一区二区三区| 亚洲6080在线| 不卡视频一二三| 日韩情涩欧美日韩视频| 亚洲午夜影视影院在线观看| 日韩不卡一二三区| 一区二区三区在线观看动漫| 亚洲男女毛片无遮挡| 国产在线乱码一区二区三区| 欧洲国内综合视频| 中文字幕乱码日本亚洲一区二区| 亚洲成人激情综合网| 99久久夜色精品国产网站| 91精品国产91久久综合桃花| 亚洲狠狠丁香婷婷综合久久久| 精品一区二区三区免费观看| 337p亚洲精品色噜噜狠狠| 亚洲男人的天堂网| caoporn国产精品| 亚洲国产电影在线观看| 国产美女视频一区| 国产日韩欧美精品在线| 国产在线精品不卡| 久久久99精品免费观看不卡| 九九精品一区二区| 日韩精品在线看片z| 卡一卡二国产精品| 精品国产乱码久久久久久蜜臀| 奇米777欧美一区二区| 欧美一级黄色大片| 国产麻豆精品视频| 国产日韩欧美一区二区三区乱码 | 国产精品996| 国产精品情趣视频| 91福利精品第一导航| 亚洲一区二区3| 欧美日韩成人综合天天影院| 日韩成人一级片| 国产丝袜在线精品| 91理论电影在线观看| 婷婷综合另类小说色区| 精品播放一区二区| 97久久精品人人做人人爽| 亚洲成人手机在线| 国产亚洲短视频| 欧美日韩精品电影| 国产高清在线精品| 亚洲图片欧美一区| 久久精品男人的天堂| 欧美日韩一级黄| 国产成人在线电影| 久久99精品国产麻豆婷婷洗澡| 国产三级精品三级| 欧美日韩成人激情| 99久久精品99国产精品| 老司机精品视频在线| 一区二区三区欧美视频| 久久欧美中文字幕| 日韩免费视频线观看| 欧美中文字幕一区二区三区 | 欧美亚洲综合色| 成人午夜精品一区二区三区| 日韩av电影免费观看高清完整版 | 日一区二区三区| 亚洲乱码国产乱码精品精可以看| 欧美大片免费久久精品三p| 欧美最猛性xxxxx直播| 色哟哟欧美精品| 成人av在线资源| 北条麻妃一区二区三区| 国产一区二区免费看| 国产高清视频一区| 国产精品69毛片高清亚洲| 麻豆精品国产传媒mv男同| 激情小说欧美图片| 国产一区二区91| 国产成人精品亚洲午夜麻豆| 精品一区二区三区免费观看| 久久福利视频一区二区| 激情av综合网| 91在线无精精品入口| 日本韩国欧美国产| 欧美日韩在线一区二区| 欧美人妇做爰xxxⅹ性高电影| 91精品欧美一区二区三区综合在 | 久久精品一区二区三区不卡牛牛| 久久久久久毛片| 亚洲免费在线电影| 日韩不卡免费视频| jvid福利写真一区二区三区| 欧美无人高清视频在线观看|