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

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

?? post.cc

?? Nachos platform for Ubuntu
?? CC
字號:
// post.cc // 	Routines to deliver incoming network messages to the correct//	"address" -- a mailbox, or a holding area for incoming messages.//	This module operates just like the US postal service (in other//	words, it works, but it's slow, and you can't really be sure if//	your mail really got through!).////	Note that once we prepend the MailHdr to the outgoing message data,//	the combination (MailHdr plus data) looks like "data" to the Network //	device.//// 	The implementation synchronizes incoming messages with threads//	waiting for those messages.//// 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 "post.h"#ifdef HOST_SPARC#include <strings.h>#endif//----------------------------------------------------------------------// Mail::Mail//      Initialize a single mail message, by concatenating the headers to//	the data.////	"pktH" -- source, destination machine ID's//	"mailH" -- source, destination mailbox ID's//	"data" -- payload data//----------------------------------------------------------------------Mail::Mail(PacketHeader pktH, MailHeader mailH, char *msgData){    ASSERT(mailH.length <= MaxMailSize);    pktHdr = pktH;    mailHdr = mailH;    bcopy(msgData, data, mailHdr.length);}//----------------------------------------------------------------------// MailBox::MailBox//      Initialize a single mail box within the post office, so that it//	can receive incoming messages.////	Just initialize a list of messages, representing the mailbox.//----------------------------------------------------------------------MailBox::MailBox(){     messages = new SynchList(); }//----------------------------------------------------------------------// MailBox::~MailBox//      De-allocate a single mail box within the post office.////	Just delete the mailbox, and throw away all the queued messages //	in the mailbox.//----------------------------------------------------------------------MailBox::~MailBox(){     delete messages; }//----------------------------------------------------------------------// PrintHeader// 	Print the message header -- the destination machine ID and mailbox//	#, source machine ID and mailbox #, and message length.////	"pktHdr" -- source, destination machine ID's//	"mailHdr" -- source, destination mailbox ID's//----------------------------------------------------------------------static void PrintHeader(PacketHeader pktHdr, MailHeader mailHdr){    printf("From (%d, %d) to (%d, %d) bytes %d\n",    	    pktHdr.from, mailHdr.from, pktHdr.to, mailHdr.to, mailHdr.length);}//----------------------------------------------------------------------// MailBox::Put// 	Add a message to the mailbox.  If anyone is waiting for message//	arrival, wake them up!////	We need to reconstruct the Mail message (by concatenating the headers//	to the data), to simplify queueing the message on the SynchList.////	"pktHdr" -- source, destination machine ID's//	"mailHdr" -- source, destination mailbox ID's//	"data" -- payload message data//----------------------------------------------------------------------void MailBox::Put(PacketHeader pktHdr, MailHeader mailHdr, char *data){     Mail *mail = new Mail(pktHdr, mailHdr, data);     messages->Append((void *)mail);	// put on the end of the list of 					// arrived messages, and wake up 					// any waiters}//----------------------------------------------------------------------// MailBox::Get// 	Get a message from a mailbox, parsing it into the packet header,//	mailbox header, and data. ////	The calling thread waits if there are no messages in the mailbox.////	"pktHdr" -- address to put: source, destination machine ID's//	"mailHdr" -- address to put: source, destination mailbox ID's//	"data" -- address to put: payload message data//----------------------------------------------------------------------void MailBox::Get(PacketHeader *pktHdr, MailHeader *mailHdr, char *data) {     DEBUG('n', "Waiting for mail in mailbox\n");    Mail *mail = (Mail *) messages->Remove();	// remove message from list;						// will wait if list is empty    *pktHdr = mail->pktHdr;    *mailHdr = mail->mailHdr;    if (DebugIsEnabled('n')) {	printf("Got mail from mailbox: ");	PrintHeader(*pktHdr, *mailHdr);    }    bcopy(mail->data, data, mail->mailHdr.length);					// copy the message data into					// the caller's buffer    delete mail;			// we've copied out the stuff we					// need, we can now discard the message}//----------------------------------------------------------------------// PostalHelper, ReadAvail, WriteDone// 	Dummy functions because C++ can't indirectly invoke member functions//	The first is forked as part of the "postal worker thread; the//	later two are called by the network interrupt handler.////	"arg" -- pointer to the Post Office managing the Network//----------------------------------------------------------------------static void PostalHelper(int arg){ PostOffice* po = (PostOffice *) arg; po->PostalDelivery(); }static void ReadAvail(int arg){ PostOffice* po = (PostOffice *) arg; po->IncomingPacket(); }static void WriteDone(int arg){ PostOffice* po = (PostOffice *) arg; po->PacketSent(); }//----------------------------------------------------------------------// PostOffice::PostOffice// 	Initialize a post office as a collection of mailboxes.//	Also initialize the network device, to allow post offices//	on different machines to deliver messages to one another.////      We use a separate thread "the postal worker" to wait for messages //	to arrive, and deliver them to the correct mailbox.  Note that//	delivering messages to the mailboxes can't be done directly//	by the interrupt handlers, because it requires a Lock.////	"addr" is this machine's network ID //	"reliability" is the probability that a network packet will//	  be delivered (e.g., reliability = 1 means the network never//	  drops any packets; reliability = 0 means the network never//	  delivers any packets)//	"nBoxes" is the number of mail boxes in this Post Office//----------------------------------------------------------------------PostOffice::PostOffice(NetworkAddress addr, double reliability, int nBoxes){// First, initialize the synchronization with the interrupt handlers    messageAvailable = new Semaphore("message available", 0);    messageSent = new Semaphore("message sent", 0);    sendLock = new Lock("message send lock");// Second, initialize the mailboxes    netAddr = addr;     numBoxes = nBoxes;    boxes = new MailBox[nBoxes];// Third, initialize the network; tell it which interrupt handlers to call    network = new Network(addr, reliability, ReadAvail, WriteDone, (int) this);// Finally, create a thread whose sole job is to wait for incoming messages,//   and put them in the right mailbox.     Thread *t = new Thread("postal worker");    t->Fork(PostalHelper, (int) this);}//----------------------------------------------------------------------// PostOffice::~PostOffice// 	De-allocate the post office data structures.//----------------------------------------------------------------------PostOffice::~PostOffice(){    delete network;    delete [] boxes;    delete messageAvailable;    delete messageSent;    delete sendLock;}//----------------------------------------------------------------------// PostOffice::PostalDelivery// 	Wait for incoming messages, and put them in the right mailbox.////      Incoming messages have had the PacketHeader stripped off,//	but the MailHeader is still tacked on the front of the data.//----------------------------------------------------------------------voidPostOffice::PostalDelivery(){    PacketHeader pktHdr;    MailHeader mailHdr;    char *buffer = new char[MaxPacketSize];    for (;;) {        // first, wait for a message        messageAvailable->P();	        pktHdr = network->Receive(buffer);        mailHdr = *(MailHeader *)buffer;        if (DebugIsEnabled('n')) {	    printf("Putting mail into mailbox: ");	    PrintHeader(pktHdr, mailHdr);        }	// check that arriving message is legal!	ASSERT(0 <= mailHdr.to && mailHdr.to < numBoxes);	ASSERT(mailHdr.length <= MaxMailSize);	// put into mailbox        boxes[mailHdr.to].Put(pktHdr, mailHdr, buffer + sizeof(MailHeader));    }}//----------------------------------------------------------------------// PostOffice::Send// 	Concatenate the MailHeader to the front of the data, and pass //	the result to the Network for delivery to the destination machine.////	Note that the MailHeader + data looks just like normal payload//	data to the Network.////	"pktHdr" -- source, destination machine ID's//	"mailHdr" -- source, destination mailbox ID's//	"data" -- payload message data//----------------------------------------------------------------------voidPostOffice::Send(PacketHeader pktHdr, MailHeader mailHdr, char* data){    char* buffer = new char[MaxPacketSize];	// space to hold concatenated						// mailHdr + data    if (DebugIsEnabled('n')) {	printf("Post send: ");	PrintHeader(pktHdr, mailHdr);    }    ASSERT(mailHdr.length <= MaxMailSize);    ASSERT(0 <= mailHdr.to && mailHdr.to < numBoxes);        // fill in pktHdr, for the Network layer    pktHdr.from = netAddr;    pktHdr.length = mailHdr.length + sizeof(MailHeader);    // concatenate MailHeader and data    bcopy(&mailHdr, buffer, sizeof(MailHeader));    bcopy(data, buffer + sizeof(MailHeader), mailHdr.length);    sendLock->Acquire();   		// only one message can be sent					// to the network at any one time    network->Send(pktHdr, buffer);    messageSent->P();			// wait for interrupt to tell us					// ok to send the next message    sendLock->Release();    delete [] buffer;			// we've sent the message, so					// we can delete our buffer}//----------------------------------------------------------------------// PostOffice::Send// 	Retrieve a message from a specific box if one is available, //	otherwise wait for a message to arrive in the box.////	Note that the MailHeader + data looks just like normal payload//	data to the Network.//////	"box" -- mailbox ID in which to look for message//	"pktHdr" -- address to put: source, destination machine ID's//	"mailHdr" -- address to put: source, destination mailbox ID's//	"data" -- address to put: payload message data//----------------------------------------------------------------------voidPostOffice::Receive(int box, PacketHeader *pktHdr, 				MailHeader *mailHdr, char* data){    ASSERT((box >= 0) && (box < numBoxes));    boxes[box].Get(pktHdr, mailHdr, data);    ASSERT(mailHdr->length <= MaxMailSize);}//----------------------------------------------------------------------// PostOffice::IncomingPacket// 	Interrupt handler, called when a packet arrives from the network.////	Signal the PostalDelivery routine that it is time to get to work!//----------------------------------------------------------------------voidPostOffice::IncomingPacket(){     messageAvailable->V(); }//----------------------------------------------------------------------// PostOffice::PacketSent// 	Interrupt handler, called when the next packet can be put onto the //	network.////	The name of this routine is a misnomer; if "reliability < 1",//	the packet could have been dropped by the network, so it won't get//	through.//----------------------------------------------------------------------void PostOffice::PacketSent(){     messageSent->V();}

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩福利视频网| 国产一区高清在线| 久久天天做天天爱综合色| 成人黄色免费短视频| 偷拍一区二区三区四区| 1024国产精品| 精品国产1区2区3区| 欧美日韩一级片在线观看| 不卡的av中国片| 韩国成人在线视频| 日韩av中文在线观看| 一区二区三区在线免费视频| 国产网站一区二区| 欧美电视剧在线看免费| 欧美体内she精视频| av电影在线观看完整版一区二区| 久久国产欧美日韩精品| 亚洲一二三四久久| 亚洲美女区一区| 中文字幕中文字幕在线一区| 精品国精品国产| 777精品伊人久久久久大香线蕉| 91黄色免费网站| 99v久久综合狠狠综合久久| 国产麻豆91精品| 国模无码大尺度一区二区三区| 丝袜美腿亚洲一区二区图片| 亚洲精品国久久99热| 中文字幕综合网| 国产精品欧美久久久久无广告 | 国产精品天天看| 久久精品免视看| 国产偷国产偷亚洲高清人白洁| 欧美刺激脚交jootjob| 欧美tk—视频vk| 欧美一区二区三区性视频| 欧美日韩国产小视频| 欧美在线小视频| 欧美久久久久久久久中文字幕| 欧洲av在线精品| 欧美日韩久久一区| 在线成人免费观看| 日韩精品一区二区三区在线播放 | 美女视频网站黄色亚洲| 日韩一区精品字幕| 蜜桃传媒麻豆第一区在线观看| 日本不卡高清视频| 国产专区欧美精品| 波多野结衣中文一区| 色婷婷一区二区三区四区| 91国模大尺度私拍在线视频| 在线视频综合导航| 91精品蜜臀在线一区尤物| 日韩视频国产视频| 久久久久国产成人精品亚洲午夜| 久久九九99视频| 国产精品毛片久久久久久| 最新国产成人在线观看| 亚洲欧美成人一区二区三区| 一区二区三区四区乱视频| 三级成人在线视频| 久草精品在线观看| 成人一区二区三区视频| 色呦呦网站一区| 日韩欧美国产系列| 国产精品美女久久久久aⅴ| 亚洲女子a中天字幕| 午夜视黄欧洲亚洲| 久久99精品国产麻豆婷婷洗澡| 国产高清不卡一区| 色成人在线视频| 精品国产第一区二区三区观看体验| 久久嫩草精品久久久久| 亚洲素人一区二区| 美女在线一区二区| 成人黄色在线看| 日韩一区二区三免费高清| 中文字幕不卡在线观看| 亚洲一级在线观看| 国产一区二区在线免费观看| 99视频国产精品| 日韩欧美亚洲一区二区| 自拍偷拍国产亚洲| 久久狠狠亚洲综合| 色狠狠av一区二区三区| 精品久久一区二区三区| 亚洲免费观看高清完整版在线观看熊| 日日欢夜夜爽一区| 不卡视频一二三四| 亚洲精品一区二区三区影院| 一区二区三区四区乱视频| 狠狠色2019综合网| 欧美日韩一区中文字幕| 国产精品乱码人人做人人爱| 日日摸夜夜添夜夜添国产精品| eeuss鲁片一区二区三区| 日韩欧美国产电影| 一区二区三区久久| av中文字幕在线不卡| 日韩精品一区在线| 亚洲高清不卡在线观看| 成人av免费在线观看| 日韩免费视频一区二区| 亚洲成在人线免费| 99久久er热在这里只有精品15| 2014亚洲片线观看视频免费| 亚洲一区二区五区| aa级大片欧美| 国产精品天天看| 国产精品夜夜嗨| 精品日韩av一区二区| 视频一区在线播放| 91蜜桃网址入口| 国产精品麻豆一区二区| 国产美女一区二区三区| 欧美一区二区福利在线| 亚洲第一av色| 日本道在线观看一区二区| 最新国产の精品合集bt伙计| 国产精品亚洲人在线观看| 精品乱码亚洲一区二区不卡| 视频一区二区中文字幕| 欧美专区在线观看一区| 亚洲在线观看免费| 91网页版在线| 亚洲人成网站影音先锋播放| 懂色一区二区三区免费观看| 久久久精品国产免费观看同学| 久久精品国产亚洲a| 日韩欧美在线1卡| 奇米精品一区二区三区在线观看| 欧美精品 日韩| 日韩高清不卡一区二区| 91精品久久久久久久99蜜桃| 日韩黄色免费网站| 91精品黄色片免费大全| 麻豆久久久久久| 精品国产乱码久久久久久夜甘婷婷| 麻豆91精品视频| 久久亚洲春色中文字幕久久久| 国产美女精品一区二区三区| 国产亚洲1区2区3区| 不卡一区二区中文字幕| 中文字幕欧美一| 色呦呦国产精品| 午夜精品一区二区三区电影天堂| 91麻豆精品国产91久久久久久久久| 日韩国产欧美三级| 精品国产自在久精品国产| 国产激情一区二区三区| 最新热久久免费视频| 欧洲日韩一区二区三区| 亚洲成人综合网站| 日韩精品一区二区在线| 国产成人在线免费| 亚洲免费视频中文字幕| 欧美人与z0zoxxxx视频| 狠狠色丁香婷婷综合久久片| 国产精品久久久久久久久搜平片| 色哟哟国产精品| 日韩精品欧美精品| 精品电影一区二区| 91亚洲国产成人精品一区二区三| 伊人一区二区三区| 日韩一区二区免费高清| 国产成人午夜精品影院观看视频| 国产精品传媒视频| 欧美丰满高潮xxxx喷水动漫| 国内精品久久久久影院一蜜桃| 国产亚洲欧美在线| 在线看日本不卡| 久久99最新地址| 亚洲欧美一区二区三区久本道91| 欧美在线不卡视频| 国产一区二区在线电影| 亚洲综合在线观看视频| 日韩欧美成人激情| 97精品国产97久久久久久久久久久久| 午夜欧美2019年伦理| 欧美国产一区在线| 欧美日本一区二区三区四区| 国产一区二区0| 天堂一区二区在线| 日本一区二区三区dvd视频在线| 欧美在线不卡一区| 国产iv一区二区三区| 日韩专区中文字幕一区二区| 中文欧美字幕免费| 欧美一级二级三级蜜桃| 91一区二区在线观看| 国内精品自线一区二区三区视频| 一区二区高清在线| 国产精品麻豆欧美日韩ww| 欧美一区二区三区影视| 91福利视频网站| 岛国精品在线观看| 国内成人精品2018免费看| 亚洲成人免费在线| 亚洲欧美日韩久久| 欧美国产一区二区在线观看|