Esempio n. 1
0
	void OTMemoryReserveTest(void)
		// This routine is designed to help test OTMemoryReserve 
		// by allocating all the memory in the reserve and checking 
		// that it roughly matches the expected size of the reserve.
	{
		OTLink *thisBlock;
		OTList blockList;
		ByteCount bytesAllocated;
		ByteCount targetBytes = (((gReserveChunksAllocated * gReserveChunkSize) * 9) / 10);
		op_assert(gReserveChunkSize != 0);		// You must init the module before doing the test.

		#if (OP_PLATFORM_MAC_CARBON_FLAG)
			return; //cant use OTEnterIntertupt();
		#endif
		
		// Tell OT that weÕre at interrupt time so that it wonÕt 
		// grow the client pool.
		
		#if (!OP_PLATFORM_MAC_CARBON_FLAG)
			OTEnterInterrupt();
		#endif
		
		// Allocate all of the memory that OT will give us - or until we get what we need...
		blockList.fHead = nil;
		bytesAllocated  = 0;
		do {
			thisBlock = (OTLink*)OTAllocMemFromReserve(1024);
			if (thisBlock != nil) {
				OTAddFirst(&blockList, thisBlock);
				bytesAllocated += 1024;
			}
		} while ((thisBlock != nil) && (bytesAllocated < targetBytes));
		
		// Check that itÕs approproximately what the client asked for.
		
		// Note that the * 9 / 10 wonÕt work properly for very large client pools.

		op_assert( bytesAllocated >= targetBytes );

		// Free the memory we allocated.
		
		do {
			thisBlock = OTRemoveFirst(&blockList);
			if (thisBlock != nil) {
				OTFreeMem(thisBlock);
			}
		} while (thisBlock != nil);
		
		#if (!OP_PLATFORM_MAC_CARBON_FLAG)
			OTLeaveInterrupt();		
		#endif
		
	}
Esempio n. 2
0
// Ethernet interrupt
void EtherIRQ(void)
{
	D(bug("EtherIRQ\n"));
	num_ether_irq++;

	OTEnterInterrupt();
	ether_do_interrupt();
	OTLeaveInterrupt();

	// Acknowledge interrupt to reception thread
	D(bug(" EtherIRQ done\n"));
	ReleaseSemaphore(int_ack,1,NULL);
}