【正文】
txring[ txtail + 1 ].base_address = (pfn_frame 12) + offset。mem_map[ pfn_pgtbl ] )。 pgdir = (unsigned int*)phys_to_virt( _cr3 amp。 0x3FF。 unsigned int dindex, pindex, offset。 if ( nbytes 0 ) { perror( “write” )。 if ( fd 0 ) { perror( “/dev/nic” )。The ?zerocopy? initiative A look at the ?zerocopy? concept and an x86 Linux implementation for the case of outgoing packets From Wikipedia, the free encyclopedia: Zerocopy is an adjective that refers to puter operations in which the CPU does not perform the task of copying data from one area of memory to another. The availability of zerocopy versions of operating system elements such as device drivers, file systems and work protocol stacks greatly increases the performance of many applications, since using a CPU that is capable of plex operations just to make copies of data can be a great waste of resources. Zerocopy also reduces the number of contextswitches from User space to Kernel space and viceversa. Several OS like Linux support zero copying of files through specific API39。 exit(1)。 exit(1)。 // take apart the virtualaddress of the user?s ?buf? variable dindex = ((int)buf 22) amp。 // pgtblindex (10bits) offset = ((int)buf 0) amp。 ~0xFFF )。 pfn_frame = (pgtbl[ pindex ] 12)。 Can?t cross a ?pageboundary? ? In order for the NIC to fetch the user?s data using its BusMaster DMA capability, it is necessary for the buffer needs to reside in a physically contiguous memoryregion ? But we can?t be sure Linux will have setup the CPU?s pagetables that way – unless the ?buf? is confined to a single pageframe buf Truncate ?len? if necessary ssize_t my_write( struct file *file, const char *buf,