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

? 歡迎來(lái)到蟲(chóng)蟲(chóng)下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲(chóng)蟲(chóng)下載站

?? disk.cc

?? linux的例子,就是下載后到自己的機(jī)子上去運(yùn)行
?? CC
字號(hào):
// 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);}

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产成人免费视频网站| 欧美专区日韩专区| 日韩欧美另类在线| 亚洲国产精品久久人人爱蜜臀 | 欧美手机在线视频| 亚洲视频在线一区| 成年人网站91| 日韩美女啊v在线免费观看| 成人一区二区在线观看| 国产日韩成人精品| av一区二区久久| 一区在线观看免费| 91影院在线观看| 一区二区视频免费在线观看| 99re在线视频这里只有精品| 亚洲激情网站免费观看| 欧美性做爰猛烈叫床潮| 日韩精品电影在线观看| 337p粉嫩大胆噜噜噜噜噜91av| 九九热在线视频观看这里只有精品| 日韩午夜在线观看视频| 精品一区二区免费| 国产精品国产三级国产专播品爱网 | 精品国产百合女同互慰| 国产99久久久精品| 亚洲综合色区另类av| 欧美成人一区二区三区在线观看 | 激情综合色播激情啊| 中文字幕免费不卡| 在线不卡一区二区| 成人夜色视频网站在线观看| 亚洲国产成人tv| 中文字幕不卡一区| 日韩一区二区三| 99国产精品久久久久久久久久| 午夜视频久久久久久| 国产校园另类小说区| 欧美亚洲国产一区二区三区va| 国产一区二三区| 丝袜诱惑亚洲看片| 一区二区三区.www| 中文字幕在线不卡一区| 欧美成人在线直播| 日韩久久精品一区| 欧美理论电影在线| 欧美性色欧美a在线播放| av在线一区二区| 国产成人av影院| 欧美日韩在线一区二区| 国产在线不卡一区| 青青草91视频| 另类综合日韩欧美亚洲| 麻豆精品精品国产自在97香蕉| 日本va欧美va瓶| 色婷婷av一区二区| 麻豆91在线播放免费| 毛片不卡一区二区| 久久不见久久见免费视频7 | 日韩欧美一卡二卡| 欧美一级理论片| 欧美一级日韩一级| 久久亚洲春色中文字幕久久久| www日韩大片| 国产农村妇女精品| 亚洲va国产va欧美va观看| 亚洲国产精品人人做人人爽| 秋霞影院一区二区| 国产成人8x视频一区二区 | 久久66热re国产| 成人精品免费网站| 欧美日韩国产影片| 久久亚洲精品国产精品紫薇| 国产精品理论在线观看| 一区二区三区在线免费视频| 男男视频亚洲欧美| 99v久久综合狠狠综合久久| 欧美日韩中文字幕一区二区| 久久女同性恋中文字幕| 免费视频最近日韩| 色视频一区二区| 欧美va在线播放| 亚洲成人在线免费| 国产成人免费在线| 欧美电影免费观看高清完整版在线 | 成人免费毛片片v| 欧美日韩国产高清一区二区三区| 国产丝袜在线精品| 美女视频一区二区三区| 色欧美片视频在线观看在线视频| 国产日韩欧美a| 日本一不卡视频| 欧美日韩一区二区三区四区 | 日韩午夜激情av| 亚洲香肠在线观看| 91成人在线免费观看| 一区精品在线播放| 91一区二区在线| 国产精品国产a| 国产精品91xxx| 久久久美女毛片| 国产精品一卡二| 精品91自产拍在线观看一区| 日韩影院精彩在线| 精品嫩草影院久久| 国产91精品一区二区麻豆网站 | 欧美一区二区三区四区视频| 香蕉加勒比综合久久| 欧美色老头old∨ideo| 天堂成人国产精品一区| 欧美电影免费观看高清完整版| 蜜桃精品视频在线| 精品日产卡一卡二卡麻豆| 成人午夜视频福利| 一区二区日韩av| 欧美一卡在线观看| 成人午夜精品一区二区三区| 在线不卡的av| 国产精品成人免费在线| 欧美日韩一区二区三区在线| 久久国产精品第一页| 国产欧美日韩激情| 欧美日韩视频专区在线播放| 久久机这里只有精品| 一色屋精品亚洲香蕉网站| 欧美影院午夜播放| 成人黄色网址在线观看| 日韩综合一区二区| 亚洲婷婷在线视频| 久久品道一品道久久精品| 欧美亚洲国产怡红院影院| 风流少妇一区二区| 日日骚欧美日韩| 一区二区三区在线高清| 欧美videofree性高清杂交| 欧美图区在线视频| 91在线视频18| 成人a级免费电影| 国内精品写真在线观看| 婷婷综合另类小说色区| 亚洲欧美另类小说视频| 中文成人综合网| 久久精品人人做人人爽97 | 国产精品一级在线| 九九精品一区二区| 精品一区二区三区影院在线午夜| 亚洲成人av中文| 午夜av一区二区| 天涯成人国产亚洲精品一区av| 亚洲美女视频在线观看| 亚洲猫色日本管| 亚洲一区二区三区自拍| 亚洲综合男人的天堂| 五月天亚洲婷婷| 老司机免费视频一区二区| 久久精品国产亚洲aⅴ| 激情久久五月天| 国产成人免费在线视频| 成人国产在线观看| 欧美日韩一区精品| 678五月天丁香亚洲综合网| 欧美一区二区日韩一区二区| 欧美成人一区二区三区在线观看| 亚洲精品一区二区三区四区高清| 精品国产免费久久| 国产精品久久久久久妇女6080| 亚洲视频一区在线| 日韩一区精品视频| 成人午夜大片免费观看| 日本精品一级二级| 久久色成人在线| 亚洲色欲色欲www| 日本不卡不码高清免费观看| 国产成人精品免费在线| 777xxx欧美| 中文字幕一区视频| 精品一区精品二区高清| 91在线精品一区二区| 亚洲精品在线免费播放| 亚洲视频一区在线| 懂色一区二区三区免费观看 | 夫妻av一区二区| 日韩一区二区三区在线视频| 亚洲欧美日韩国产一区二区三区| 日韩av高清在线观看| 色av综合在线| 国产精品电影院| 狠狠网亚洲精品| 91精品一区二区三区久久久久久| 亚洲三级在线看| 国产成人日日夜夜| 久久先锋影音av| 精品一区二区在线观看| 在线不卡的av| 麻豆国产精品官网| 日韩亚洲欧美成人一区| 日韩精品成人一区二区三区 | 91浏览器打开| 欧美一级免费大片| 国产精品国产三级国产普通话99| 日本va欧美va精品发布|