nachos.kernel.devices
Class NetworkDriver

java.lang.Object
  extended by nachos.kernel.devices.NetworkDriver

public class NetworkDriver
extends java.lang.Object

This class defines a "synchronous" network abstraction for sending and receiving packets on the network. As with other I/O devices, the raw physical network is an asynchronous device -- requests to send or receive packets return immediately, and an interrupt occurs later to signal that the operation completed. This class provides synchronization so that its methods (send and receive) return when the network operation finishes. It also provides synchronization to ensure that the next send operation starts only after the previous send operation (if any) finished; this is required for the network to work correctly.

See Also:
Packet, Network

Nested Class Summary
private  class NetworkDriver.ReceiveHandler
          Network driver interrupt handler class.
private  class NetworkDriver.SendHandler
          Network driver interrupt handler class.
 
Field Summary
private  byte id
          Network address of this machine.
private  nachos.machine.Network network
          Raw network device.
private  Semaphore receiveSemaphore
          Semaphore used to synchronize receiving threads with the interrupt handler.
private  Lock sendLock
          Lock used to ensure that the previous send request finished before the next send request starts.
private  Semaphore sendSemaphore
          Semaphore used to synchronize sending threads with the interrupt handler.
 
Constructor Summary
NetworkDriver(java.lang.String[] args)
          Initialize the synchronous interface to the physical network, in turn initializing the physical network.
 
Method Summary
 nachos.machine.Packet receive()
          Receive a network packet.
 void send(nachos.machine.Packet p)
          Send a network packet.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

network

private nachos.machine.Network network
Raw network device.


sendSemaphore

private Semaphore sendSemaphore
Semaphore used to synchronize sending threads with the interrupt handler.


receiveSemaphore

private Semaphore receiveSemaphore
Semaphore used to synchronize receiving threads with the interrupt handler.


sendLock

private Lock sendLock
Lock used to ensure that the previous send request finished before the next send request starts.


id

private byte id
Network address of this machine.

Constructor Detail

NetworkDriver

public NetworkDriver(java.lang.String[] args)
Initialize the synchronous interface to the physical network, in turn initializing the physical network.

Parameters:
args - Array containing command-line arguments
Method Detail

receive

public nachos.machine.Packet receive()
Receive a network packet. Return only after a packet has been received.


send

public void send(nachos.machine.Packet p)
Send a network packet. Return only after the packet has been sent.

Parameters:
p - The packet to send.