#include "copyright.h"#include <stdio.h>#include <string.h>Go to the source code of this file.
Functions | |
| bool | PollFile (int fd) |
| int | OpenForWrite (char *name) |
| int | OpenForReadWrite (char *name, bool crashOnError) |
| void | Read (int fd, char *buffer, int nBytes) |
| int | ReadPartial (int fd, char *buffer, int nBytes) |
| void | WriteFile (int fd, char *buffer, int nBytes) |
| void | Lseek (int fd, int offset, int whence) |
| int | Tell (int fd) |
| void | Close (int fd) |
| bool | Unlink (char *name) |
| int | OpenSocket () |
| void | CloseSocket (int sockID) |
| void | AssignNameToSocket (char *socketName, int sockID) |
| void | DeAssignNameToSocket (char *socketName) |
| bool | PollSocket (int sockID) |
| void | ReadFromSocket (int sockID, char *buffer, int packetSize) |
| void | SendToSocket (int sockID, char *buffer, int packetSize, char *toName) |
| void | Abort () |
| void | Exit (int exitCode) |
| void | Delay (int seconds) |
| void | CallOnUserAbort (VoidNoArgFunctionPtr cleanUp) |
| void | RandomInit (unsigned seed) |
| int | Random () |
| char * | AllocBoundedArray (int size) |
| void | DeallocBoundedArray (char *p, int size) |
| int | atoi (const char *str) |
| double | atof (const char *str) |
| int | abs (int i) |
|
|
Definition at line 430 of file sysdep.cc.
00431 {
00432 abort();
00433 }
|
|
|
Referenced by Disk::TimeToSeek. |
|
|
Definition at line 482 of file sysdep.cc. Referenced by Thread::StackAllocate.
00483 {
00484 int pgSize = getpagesize();
00485 char *ptr = new char[pgSize * 2 + size];
00486
00487 mprotect(ptr, pgSize, 0);
00488 mprotect(ptr + pgSize + size, pgSize, 0);
00489 return ptr + pgSize;
00490 }
|
|
||||||||||||
|
Definition at line 319 of file sysdep.cc. Referenced by Network::Network.
00320 {
00321 struct sockaddr_un uName;
00322 int retVal;
00323
00324 (void) unlink(socketName); // in case it's still around from last time
00325
00326 InitSocketName(&uName, socketName);
00327 retVal = bind(sockID, (struct sockaddr *) &uName, sizeof(uName));
00328 ASSERT(retVal >= 0);
00329 DEBUG('n', "Created socket %s\n", socketName);
00330 }
|
|
|
Referenced by Initialize. |
|
|
Referenced by Initialize, and main. |
|
|
Definition at line 406 of file sysdep.cc. Referenced by Initialize.
00407 {
00408 (void)signal(SIGINT, (VoidFunctionPtr) func);
00409 }
|
|
|
|
|
|
Definition at line 295 of file sysdep.cc. Referenced by Network::~Network.
00296 {
00297 (void) close(sockID);
00298 }
|
|
||||||||||||
|
Definition at line 501 of file sysdep.cc. Referenced by Thread::~Thread.
00502 {
00503 int pgSize = getpagesize();
00504
00505 mprotect(ptr - pgSize, pgSize, PROT_READ | PROT_WRITE | PROT_EXEC);
00506 mprotect(ptr + size, pgSize, PROT_READ | PROT_WRITE | PROT_EXEC);
00507 delete [] (ptr - pgSize);
00508 }
|
|
|
Definition at line 337 of file sysdep.cc. Referenced by Network::~Network.
00338 {
00339 (void) unlink(socketName);
00340 }
|
|
|
Definition at line 419 of file sysdep.cc. Referenced by main.
00420 {
00421 (void) sleep((unsigned) seconds);
00422 }
|
|
|
|
|
||||||||||||||||
|
Definition at line 226 of file sysdep.cc. Referenced by Disk::Disk, Disk::ReadRequest, and Disk::WriteRequest.
|
|
||||||||||||
|
Definition at line 175 of file sysdep.cc. Referenced by Console::Console, and Disk::Disk.
|
|
|
Definition at line 158 of file sysdep.cc. Referenced by Console::Console, and Disk::Disk.
|
|
|
Definition at line 279 of file sysdep.cc.
|
|
|
Definition at line 124 of file sysdep.cc. Referenced by Console::CheckCharAvail, and PollSocket.
00125 {
00126 int rfd = (1 << fd), wfd = 0, xfd = 0, retVal;
00127 struct timeval pollTime;
00128
00129 // decide how long to wait if there are no characters on the file
00130 pollTime.tv_sec = 0;
00131 if (interrupt->getStatus() == IdleMode)
00132 pollTime.tv_usec = 20000; // delay to let other nachos run
00133 else
00134 pollTime.tv_usec = 0; // no delay
00135
00136 // poll file or socket
00137 #if defined(HOST_i386) || defined(HOST_SVR4)
00138 retVal = select(32, (fd_set*)&rfd, (fd_set*)&wfd, (fd_set*)&xfd, &pollTime);
00139 #else
00140 retVal = select(32, &rfd, &wfd, &xfd, &pollTime);
00141 #endif
00142
00143 ASSERT((retVal == 0) || (retVal == 1));
00144 if (retVal == 0)
00145 return FALSE; // no char waiting to be read
00146 return TRUE;
00147 }
|
|
|
Definition at line 348 of file sysdep.cc. Referenced by Network::CheckPktAvail.
00349 {
00350 return PollFile(sockID); // on UNIX, socket ID's are just file ID's
00351 }
|
|
|
Definition at line 464 of file sysdep.cc.
00465 {
00466 return rand();
00467 }
|
|
|
Definition at line 453 of file sysdep.cc. Referenced by Initialize.
00454 {
00455 srand(seed);
00456 }
|
|
||||||||||||||||
|
|
|
||||||||||||||||
|
Definition at line 358 of file sysdep.cc. Referenced by Network::CheckPktAvail.
00359 {
00360 int retVal;
00361 extern int errno;
00362 struct sockaddr_un uName;
00363 int size = sizeof(uName);
00364
00365 retVal = recvfrom(sockID, buffer, packetSize, 0,
00366 (struct sockaddr *) &uName, &size);
00367
00368 if (retVal != packetSize) {
00369 perror("in recvfrom");
00370 printf("called: %x, got back %d, %d\n", (unsigned int) buffer,
00371 retVal, errno);
00372 }
00373 ASSERT(retVal == packetSize);
00374 }
|
|
||||||||||||||||
|
Definition at line 202 of file sysdep.cc.
00203 {
00204 return read(fd, buffer, nBytes);
00205 }
|
|
||||||||||||||||||||
|
Definition at line 382 of file sysdep.cc. Referenced by Network::Send.
00383 {
00384 struct sockaddr_un uName;
00385 int retVal;
00386
00387 InitSocketName(&uName, toName);
00388 retVal = sendto(sockID, buffer, packetSize, 0,
00389 #ifdef HOST_SVR4
00390 (sockaddr *) &uName,
00391 #else
00392 (char *) &uName,
00393 #endif /* HOST_SVR4 */
00394 sizeof(uName));
00395 ASSERT(retVal == packetSize);
00396 }
|
|
|
Definition at line 238 of file sysdep.cc.
|
|
|
Definition at line 266 of file sysdep.cc.
00267 {
00268 return unlink(name);
00269 }
|
|
||||||||||||||||
|
Definition at line 214 of file sysdep.cc. Referenced by Disk::Disk, Console::PutChar, and Disk::WriteRequest.
|
1.2.14 written by Dimitri van Heesch,
© 1997-2002