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

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

?? disk.cpp

?? LINUX 下的 NACHOS 系統(tǒng) 實(shí)現(xiàn)系統(tǒng)調(diào)度的算法功能
?? CPP
字號(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一区二区三区免费野_久草精品视频
色呦呦网站一区| 美女视频黄 久久| 天天av天天翘天天综合网| 日欧美一区二区| 国产在线不卡视频| 91福利社在线观看| 精品久久久久一区| 亚洲欧美电影院| 久久se这里有精品| 91原创在线视频| 日韩欧美电影一二三| 国产精品午夜春色av| 午夜激情久久久| 国产**成人网毛片九色 | 国产欧美综合在线| 一区二区三区四区在线| 九九热在线视频观看这里只有精品| 国产二区国产一区在线观看| 欧美日韩国产综合一区二区 | 成人高清视频在线| 欧美日本在线看| 中文文精品字幕一区二区| 日韩国产欧美三级| 99久久夜色精品国产网站| 日韩亚洲欧美在线| 亚洲精品乱码久久久久久久久| 狠狠色丁香久久婷婷综合丁香| 日本精品免费观看高清观看| 久久久一区二区三区捆绑**| 亚洲一二三四区不卡| 成人综合婷婷国产精品久久| 欧美一区二区三区精品| 亚洲男女毛片无遮挡| 国产激情视频一区二区在线观看| 欧美日本高清视频在线观看| 一区视频在线播放| 国产精品亚洲а∨天堂免在线| 91麻豆精品91久久久久同性| 日韩伦理电影网| 成人激情图片网| 2021中文字幕一区亚洲| 三级欧美在线一区| 在线观看国产日韩| 亚洲欧美一区二区在线观看| 国产美女av一区二区三区| 欧美一区二区三区在线观看| 亚洲国产日韩av| 色婷婷久久99综合精品jk白丝| 国产精品麻豆视频| 国产精品亚洲第一区在线暖暖韩国| 91精品一区二区三区在线观看| 亚洲久本草在线中文字幕| 成人免费不卡视频| 国产丝袜美腿一区二区三区| 韩国av一区二区| 精品处破学生在线二十三| 免费的成人av| 日韩欧美国产综合在线一区二区三区| 亚洲国产精品一区二区www | 亚洲超丰满肉感bbw| 91美女精品福利| 亚洲色图.com| 不卡电影一区二区三区| 国产日韩欧美电影| 国产成人免费在线观看不卡| 精品国产不卡一区二区三区| 国模套图日韩精品一区二区| 日韩三级视频在线观看| 久久se精品一区二区| 精品成人佐山爱一区二区| 精品无人码麻豆乱码1区2区| 精品国产乱码久久久久久1区2区 | 久久九九全国免费| 国产伦精品一区二区三区免费迷| 精品国产sm最大网站免费看| 久久 天天综合| 久久精品一区二区| 国产99久久久国产精品免费看| 国产日产欧美一区二区三区| av在线这里只有精品| 亚洲美女视频在线| 欧美性大战xxxxx久久久| 视频一区二区欧美| 精品电影一区二区| 成人美女在线视频| 亚洲黄色尤物视频| 欧美欧美午夜aⅴ在线观看| 男人的j进女人的j一区| 久久综合九色综合97婷婷女人 | 日韩一区在线免费观看| 91福利社在线观看| 蜜臀精品一区二区三区在线观看| 欧美成人高清电影在线| 丁香啪啪综合成人亚洲小说| 亚洲黄色免费电影| 91精品久久久久久久91蜜桃| 狠狠色狠狠色合久久伊人| 国产精品系列在线| 欧美唯美清纯偷拍| 男人的j进女人的j一区| 日本一区二区高清| 一本色道久久综合狠狠躁的推荐| 亚洲电影中文字幕在线观看| 精品国产一区二区在线观看| hitomi一区二区三区精品| 亚洲午夜精品17c| 欧美电视剧在线观看完整版| 国产99久久久国产精品潘金| 亚洲国产日日夜夜| 精品国产凹凸成av人网站| 99re在线精品| 欧美aa在线视频| 中文字幕一区二区三区精华液| 欧美视频一区二区| 国产一区二区三区四区五区入口| 一色屋精品亚洲香蕉网站| 欧美一卡2卡三卡4卡5免费| 国产成人精品免费一区二区| 亚洲h精品动漫在线观看| 国产视频一区不卡| 7777精品伊人久久久大香线蕉完整版 | 色综合中文字幕国产| 亚洲va欧美va人人爽| 久久久久久久性| 欧美揉bbbbb揉bbbbb| 国产精品亚洲第一| 石原莉奈在线亚洲三区| 中文字幕一区二区三区蜜月| 欧美电影精品一区二区| 在线精品视频小说1| 精品亚洲aⅴ乱码一区二区三区| 亚洲色图另类专区| 久久久一区二区三区捆绑**| 欧美日韩不卡视频| 91免费看`日韩一区二区| 久久精品国产一区二区三| 亚洲免费在线观看视频| 久久一区二区视频| 欧美人与z0zoxxxx视频| 成人高清视频在线观看| 精品一区二区三区蜜桃| 亚洲国产精品自拍| 日韩毛片精品高清免费| 国产视频一区在线观看| 日韩一区二区不卡| 欧美三级在线视频| av不卡一区二区三区| 国产精品99久久久| 蜜桃视频在线一区| 亚洲国产欧美另类丝袜| 亚洲天堂免费在线观看视频| 国产欧美一区二区精品秋霞影院| 欧美一级夜夜爽| 欧美三级三级三级爽爽爽| 91一区二区在线观看| 国产精品一区二区三区乱码| 久久精品国产一区二区三区免费看 | 豆国产96在线|亚洲| 久久福利视频一区二区| 日韩av电影免费观看高清完整版 | 欧美一区二区美女| 在线视频国产一区| 成人18视频在线播放| 国产91在线观看| 久久99精品一区二区三区| 蜜臂av日日欢夜夜爽一区| 图片区小说区国产精品视频| 一区二区三区免费在线观看| 亚洲天堂精品在线观看| 国产精品国产馆在线真实露脸| 欧美国产欧美综合| 国产女人18水真多18精品一级做| 亚洲精品一线二线三线无人区| 欧美一区二区在线免费播放| 91精品国产一区二区三区蜜臀 | 黑人巨大精品欧美一区| 日日夜夜一区二区| 午夜精品aaa| 日本免费新一区视频| 蜜桃av一区二区| 久久爱另类一区二区小说| 国模无码大尺度一区二区三区| 国内久久婷婷综合| 国产精品亚洲一区二区三区在线| 国产精品99久| 波多野结衣欧美| 色哟哟亚洲精品| 欧美性色黄大片| 日韩一二在线观看| 精品日韩在线一区| 久久精品无码一区二区三区| 久久看人人爽人人| 中文字幕日韩一区| 一区二区久久久久| 日韩制服丝袜av| 久久国产精品第一页| 国产aⅴ综合色| 91丨porny丨国产入口| 欧美自拍丝袜亚洲| 日韩精品在线看片z|