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

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

?? disk.cc

?? nachos test 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一区二区三区免费野_久草精品视频
成人久久视频在线观看| 欧美一区二区三区视频| 亚洲国产综合人成综合网站| 欧美色综合久久| 日韩国产在线观看| 精品少妇一区二区三区视频免付费 | 丝袜a∨在线一区二区三区不卡| 欧美精品一二三四| 经典三级一区二区| 中文字幕中文乱码欧美一区二区| 95精品视频在线| 亚洲成在线观看| 欧美tk—视频vk| 亚洲欧美在线aaa| 色综合天天综合在线视频| 亚洲国产美女搞黄色| 日韩精品最新网址| eeuss鲁片一区二区三区| 亚洲图片一区二区| 亚洲精品一区二区三区99| 成人白浆超碰人人人人| 亚洲资源中文字幕| 精品日产卡一卡二卡麻豆| aaa亚洲精品| 日韩专区欧美专区| 国产午夜精品一区二区三区嫩草| 色综合天天在线| 青青草国产精品97视觉盛宴| 欧美国产欧美综合| 欧美天天综合网| 国产精品一区在线| 亚洲一区免费在线观看| 欧美一区二区三区啪啪| 波多野结衣一区二区三区 | 亚洲精品视频在线观看网站| 6080亚洲精品一区二区| 粉嫩绯色av一区二区在线观看| 7777精品伊人久久久大香线蕉超级流畅 | 日韩一区二区免费高清| 成人丝袜高跟foot| 香蕉影视欧美成人| 中文字幕成人av| 欧美精品一卡二卡| 9色porny自拍视频一区二区| 石原莉奈一区二区三区在线观看| 欧美国产在线观看| 欧美二区三区91| 97se亚洲国产综合在线| 激情六月婷婷久久| 亚洲妇熟xx妇色黄| 中文在线资源观看网站视频免费不卡| 欧美三级在线看| 粉嫩欧美一区二区三区高清影视| 午夜电影一区二区| 亚洲人成精品久久久久久| 91精品国产91综合久久蜜臀| 一个色综合av| 久久免费国产精品 | 欧美在线不卡视频| 国产成人av电影| 美女一区二区三区| 亚洲国产成人91porn| 国产精品麻豆视频| 精品三级av在线| 欧美剧情片在线观看| 91在线无精精品入口| 国产美女视频91| 青草av.久久免费一区| 亚洲免费观看高清完整| 国产欧美一区二区在线| 欧美一级高清大全免费观看| 色婷婷国产精品| 风间由美一区二区av101| 麻豆专区一区二区三区四区五区| 亚洲制服丝袜av| 综合亚洲深深色噜噜狠狠网站| 久久夜色精品一区| 欧美一区二区三区免费观看视频 | 欧美精品v国产精品v日韩精品| 91香蕉视频污| 成人av综合在线| 国产成人在线色| 国产一区二区三区久久久| 免费观看30秒视频久久| 日韩欧美国产1| 欧美日本一道本| 在线免费观看一区| 色欧美日韩亚洲| 91影院在线观看| 99精品久久久久久| 99国产精品久| 91在线小视频| 99久久99久久精品免费看蜜桃| 粉嫩绯色av一区二区在线观看| 国产一本一道久久香蕉| 韩国一区二区视频| 久久99国产精品久久99果冻传媒| 美日韩一区二区| 美女一区二区视频| 看片的网站亚洲| 麻豆专区一区二区三区四区五区| 免费看欧美美女黄的网站| 天天综合日日夜夜精品| 亚洲高清免费观看高清完整版在线观看| 一区二区在线看| 亚洲精品精品亚洲| 一区二区三区日韩欧美精品| 亚洲精品乱码久久久久久久久 | 久久亚洲春色中文字幕久久久| 国产高清亚洲一区| 国产一区二区91| 国产乱子轮精品视频| 国产精品一区在线| 成人av电影在线播放| hitomi一区二区三区精品| 不卡一区在线观看| 91农村精品一区二区在线| 91麻豆福利精品推荐| 在线免费观看视频一区| 欧美裸体bbwbbwbbw| 日韩亚洲欧美在线| 久久亚洲一区二区三区明星换脸| 精品久久人人做人人爱| 久久久久久日产精品| 欧美激情资源网| 国产精品九色蝌蚪自拍| 亚洲欧美精品午睡沙发| 亚洲国产精品天堂| 蜜臀av性久久久久蜜臀aⅴ流畅| 精品一区二区三区在线观看国产| 国精品**一区二区三区在线蜜桃| 国产成a人亚洲| 色综合 综合色| 欧美精品乱码久久久久久| 日韩欧美在线一区二区三区| 久久一日本道色综合| 亚洲丝袜另类动漫二区| 亚洲高清免费观看高清完整版在线观看| 天天操天天干天天综合网| 精品一区二区在线视频| 国产精品丝袜在线| 亚洲女人****多毛耸耸8| 五月激情六月综合| 激情综合亚洲精品| 91猫先生在线| 日韩丝袜美女视频| 中文字幕精品一区二区三区精品| 亚洲精品美国一| 久久99精品国产麻豆婷婷洗澡| 成人精品鲁一区一区二区| 欧美亚洲一区三区| 精品日韩av一区二区| 亚洲日本在线观看| 日本特黄久久久高潮| 国产成人久久精品77777最新版本| 91成人看片片| 欧美电视剧免费全集观看| 国产精品久久精品日日| 天天av天天翘天天综合网色鬼国产| 国产在线观看一区二区| 色成人在线视频| 精品国产乱码久久久久久闺蜜| 欧美国产日韩精品免费观看| 亚洲v中文字幕| 国产精品1区2区3区在线观看| 色狠狠一区二区三区香蕉| 欧美大尺度电影在线| ●精品国产综合乱码久久久久| 天天综合天天综合色| 成人av在线播放网址| 91麻豆精品国产| 中文字幕一区不卡| 久久久久久久网| 一区二区高清视频在线观看| 国产一区二区女| 欧美日韩一级片网站| 国产网站一区二区| 三级一区在线视频先锋 | 最好看的中文字幕久久| 久久国产剧场电影| 欧美艳星brazzers| 国产精品沙发午睡系列990531| 男人的j进女人的j一区| 91小视频免费看| 久久―日本道色综合久久| 午夜精品福利一区二区三区av| 波多野结衣精品在线| 日韩欧美国产成人一区二区| 夜夜亚洲天天久久| caoporn国产一区二区| 日韩欧美一区二区三区在线| 亚洲精品国久久99热| 成人午夜短视频| 精品国产乱子伦一区| 五月婷婷激情综合| 在线免费不卡电影| 亚洲欧洲一区二区在线播放| 国产麻豆欧美日韩一区| 日韩亚洲欧美在线| 日精品一区二区|