コード例 #1
0
ファイル: aReadY.c プロジェクト: wuarthur/Schduling
/**
 * Read numBlocks blocks from disk sequentially starting at block 0.
 */
void run (int numBlocks) {
  for (int blockno = 0; blockno < numBlocks; blockno++) {
	  struct PendingRead* item = queue_dequeue (&prq);
	  char* buf = item->buf;
	  int nbytes = item->nbytes;
      int blockno = item->blockno;
      void (*handler) (char*, int, int) = item->handler;
	//TODO, ask TA  uthread_create (asyncRead(buf, nbytes, item->blockno, void (*handler) (char*, int, int) ), &blockno);
    // call asyncRead to schedule read TODO
  }
  disk_waitForReads();
}
コード例 #2
0
ファイル: aReadY.c プロジェクト: wuarthur/Schduling
void asyncRead (char* buf, int nbytes, int blockno, void (*handler) (char*, int, int)) {
  // call disk_scheduleRead to schedule a read TODO
  struct PendingRead* PR = malloc(sizeof *PR);
  PR->buf = buf;
  PR->nbytes = nbytes;
  PR->blockno = blockno;
  PR->handler = handler;
  queue_enqueue (&prq, PR);
  disk_scheduleRead (buf, nbytes, blockno);
  disk_waitForReads ();
  
  
}
コード例 #3
0
ファイル: sRead.c プロジェクト: buyunwang/CPSC-213
void syncRead (char* buf, int nBytes, int blockNo) {
  disk_scheduleRead (buf, 4096, blockNo);
  disk_waitForReads ();
  assert (*((int*) buf) == blockNo);
}